diff options
| author | Tommaso Negri <me@tommasongr.com> | 2026-10-27 16:45:21 +0100 |
|---|---|---|
| committer | Tommaso Negri <me@tommasongr.com> | 2026-10-27 16:45:21 +0100 |
| commit | 4fba7cae5867f4457b66dec6ba38e8e7d9231f0b (patch) | |
| tree | a21930b4aebc537bb21c31cf64468fe33f2e5f5e /Tests/barTests/CellTests.swift | |
| parent | 9ce5b3b6d52368b9333a9d5f98c3cd2b1a3cb038 (diff) | |
| download | bar-4fba7cae5867f4457b66dec6ba38e8e7d9231f0b.tar.gz bar-4fba7cae5867f4457b66dec6ba38e8e7d9231f0b.zip | |
Diffstat (limited to 'Tests/barTests/CellTests.swift')
| -rw-r--r-- | Tests/barTests/CellTests.swift | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/Tests/barTests/CellTests.swift b/Tests/barTests/CellTests.swift new file mode 100644 index 0000000..c7aae13 --- /dev/null +++ b/Tests/barTests/CellTests.swift @@ -0,0 +1,38 @@ +import SwiftUI +import Testing +@testable import bar + +@Test(arguments: [ + "", "ordinary text", "text &!1 more", " &!1 text", + "&!", "&!1", "&!12", "&!0", "&!999999999999999999999999999999", + "&! text", "&!-1 text", "&!+1 text", "&!1 text", "&!١ text", +]) func literalCellText(_ input: String) { + let cell = Cell(rawValue: input) + #expect(cell.rawValue == input) + #expect(cell.background == .clear) + #expect(cell.id == "\(input):0") +} + +@Test(arguments: ["0", "12", "999999999999999999999999999999"]) func invalidCellLevels(_ level: String) { + let cell = Cell(rawValue: "&!\(level) text") + #expect(cell.rawValue == " text") + #expect(cell.background == .clear) + #expect(cell.id == " text:0") +} + +@Test func configuredCellHighlights() { + for level in 1...Config.highlights.count { + for body in ["hello", " hello", " ", "\t", "\n", "&!2 nested"] { + let cell = Cell(rawValue: "&!\(level)\(body)") + #expect(cell.rawValue == body) + #expect(cell.background == Config.highlights[level - 1]) + #expect(cell.id == "\(body):\(level)") + } + } + let cell = Cell(rawValue: "&!01 hello") + #expect(cell.background == Config.highlights[0]) + #expect(cell.rawValue == " hello") + let outOfRange = Cell(rawValue: "&!\(Config.highlights.count + 1) text") + #expect(outOfRange.rawValue == " text") + #expect(outOfRange.background == .clear) +} |
