1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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)
}
|