import Foundation import XCTest @testable import OldFella final class ComposerTextTests: XCTestCase { func testCandidatesUseUTF8OffsetsAfterUnicode() throws { let text = "🌍 café @alice.example #日本語 https://example.com" let candidates = ComposerText.facetCandidates(in: text) XCTAssertEqual(candidates.map(\.kind), [.mention, .tag, .link]) XCTAssertEqual(candidates.map(\.value), ["alice.example", "日本語", "https://example.com"]) let expected = ["@alice.example", "#日本語", "https://example.com"] for (candidate, substring) in zip(candidates, expected) { let range = try XCTUnwrap(text.range(of: substring)) XCTAssertEqual(candidate.byteStart, text[..