mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-11-29 08:29:22 +00:00
* Remove dead binary message, NoiseMessage, ReadReceipt, and InputValidator code * Remove dead MessageFormattingEngine body and port single-pass hint scanner * Remove dead AppEventStream, coordinator methods, and write-only ViewModel state * Remove dead BLE/Sync helpers, obsolete ingress lock, and gate debug diagnostics * Remove dead Noise, Nostr, TorManager, and BitFoundation code * Remove dead Identity ephemeral sessions, nicknameIndex, and favorite APIs * Remove StoreAndForwardMetrics, dead service APIs, and gate test-only helpers * Remove dead UI verify sheet, ImageUtils NSImage path, voice metering, and stale strings * Remove obsolete isConnected assertions in coordinator context tests * Address PR 1903 review: preserve legacy panic cleanup and remove Periphery leftovers --------- Co-authored-by: jack <jackjackbits@users.noreply.github.com>
46 lines
1.6 KiB
Swift
46 lines
1.6 KiB
Swift
//
|
|
// NicknameNormalizationTests.swift
|
|
// bitchatTests
|
|
//
|
|
// Nicknames must compare equal regardless of how the user's keyboard
|
|
// produced them: "café" as precomposed U+00E9 and as "e" + combining
|
|
// U+0301 are canonically equivalent but bytewise different, which broke
|
|
// mention matching, DM resolution, and autocomplete (#214). Storage and
|
|
// comparison both canonicalize to NFC via String.normalizedNickname.
|
|
// This is free and unencumbered software released into the public domain.
|
|
// For more information, see <https://unlicense.org>
|
|
//
|
|
|
|
import Foundation
|
|
import Testing
|
|
@testable import bitchat
|
|
|
|
struct NicknameNormalizationTests {
|
|
/// "café" with a combining acute accent (NFD form)
|
|
private let decomposed = "cafe\u{0301}"
|
|
/// "café" with precomposed é (NFC form)
|
|
private let precomposed = "caf\u{00E9}"
|
|
|
|
@Test
|
|
func canonicallyEquivalentFormsNormalizeIdentically() {
|
|
// Sanity: the raw forms really are different strings byte-wise …
|
|
#expect(decomposed.unicodeScalars.count != precomposed.unicodeScalars.count)
|
|
// … and normalization unifies them.
|
|
#expect(decomposed.normalizedNickname == precomposed.normalizedNickname)
|
|
#expect(decomposed.normalizedNickname == precomposed)
|
|
}
|
|
|
|
@Test
|
|
func asciiNicknamesPassThroughUnchanged() {
|
|
#expect("alice_42".normalizedNickname == "alice_42")
|
|
#expect("".normalizedNickname == "")
|
|
}
|
|
|
|
@Test
|
|
func collisionSuffixSplittingSurvivesNormalization() {
|
|
let (base, suffix) = (decomposed.normalizedNickname + "#ab12").splitSuffix()
|
|
#expect(base == precomposed)
|
|
#expect(suffix == "#ab12")
|
|
}
|
|
}
|