diff options
| author | Ruben Beltran del Rio <jj@r.bdr.sh> | 2026-06-16 12:08:21 +0200 |
|---|---|---|
| committer | Ruben Beltran del Rio <jj@r.bdr.sh> | 2026-06-16 12:22:47 +0200 |
| commit | 501fdce29e4d2c46c4708ad7f44056878e0db3fa (patch) | |
| tree | db923b77037db9f5b37600a6e34c3bb2e8a971be /Tests/NorgKitTests/Helpers/ASCIIByteSetTests.swift | |
Initial extraction from Norganize1.0.0
Diffstat (limited to 'Tests/NorgKitTests/Helpers/ASCIIByteSetTests.swift')
| -rw-r--r-- | Tests/NorgKitTests/Helpers/ASCIIByteSetTests.swift | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Tests/NorgKitTests/Helpers/ASCIIByteSetTests.swift b/Tests/NorgKitTests/Helpers/ASCIIByteSetTests.swift new file mode 100644 index 0000000..eb29ecb --- /dev/null +++ b/Tests/NorgKitTests/Helpers/ASCIIByteSetTests.swift @@ -0,0 +1,42 @@ +import Testing + +@testable import NorgKit + +struct ASCIIByteSetTests { + + @Test func containsLowBytes() { + // `*` (0x2A) and `-` (0x2D) live in the low 64-bit word. + let set = ASCIIByteSet("*-") + #expect(set.contains(UInt8(ascii: "*"))) + #expect(set.contains(UInt8(ascii: "-"))) + #expect(!set.contains(UInt8(ascii: "/"))) + } + + @Test func containsHighBytes() { + // `~` (0x7E) and `_` (0x5F) live in the high 64-bit word. + let set = ASCIIByteSet("~_") + #expect(set.contains(UInt8(ascii: "~"))) + #expect(set.contains(UInt8(ascii: "_"))) + #expect(!set.contains(UInt8(ascii: "x"))) + } + + @Test func spansBothWords() { + let set = ASCIIByteSet("*~") + #expect(set.contains(UInt8(ascii: "*"))) + #expect(set.contains(UInt8(ascii: "~"))) + } + + @Test func rejectsNonAsciiAndOutOfSetBytes() { + let set = ASCIIByteSet("*") + #expect(!set.contains(0)) // NUL, low word, unset + #expect(!set.contains(200)) // beyond ASCII, never stored + #expect(!set.contains(127)) // high word, unset + } + + @Test func emptySetContainsNothing() { + let set = ASCIIByteSet("") + #expect(!set.contains(UInt8(ascii: "*"))) + #expect(!set.contains(0)) + #expect(!set.contains(127)) + } +} |