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
|
import Foundation
import Testing
@testable import NorgKit
struct InlineStyleTests {
@Test func combinesAndContains() {
let style: InlineStyle = [.bold, .italic]
#expect(style.contains(.bold))
#expect(style.contains(.italic))
#expect(!style.contains(.underline))
}
@Test func distinctRawValues() {
let all: [InlineStyle] = [
.bold, .italic, .underline, .strikethrough,
.verbatim, .superscript, .subscript, .spoiler, .math,
]
#expect(Set(all.map(\.rawValue)).count == all.count)
}
@Test func encodesAsSingleInteger() throws {
let style: InlineStyle = [.bold, .verbatim]
let data = try JSONEncoder().encode(style)
#expect(String(data: data, encoding: .utf8) == "\(style.rawValue)")
}
@Test func roundTripsThroughJSON() throws {
let style: InlineStyle = [.italic, .math, .spoiler]
let data = try JSONEncoder().encode(style)
let decoded = try JSONDecoder().decode(InlineStyle.self, from: data)
#expect(decoded == style)
}
}
|