-
Notifications
You must be signed in to change notification settings - Fork 2
/
Style+Hidden.swift
66 lines (51 loc) · 2.21 KB
/
Style+Hidden.swift
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//=----------------------------------------------------------------------------=
// This source file is part of the DiffableTextViews open source project.
//
// Copyright (c) 2022 Oscar Byström Ericsson
// Licensed under Apache License, Version 2.0
//
// See http://www.apache.org/licenses/LICENSE-2.0 for license information.
//=----------------------------------------------------------------------------=
#if DEBUG
@testable import DiffableTextKitXPattern
import XCTest
//*============================================================================*
// MARK: * Style x Hidden
//*============================================================================*
final class StyleTestsOnHidden: XCTestCase, StyleTests {
//=------------------------------------------------------------------------=
// MARK: State
//=------------------------------------------------------------------------=
let style = PatternTextStyle<String>
.pattern("+## (###) ###-##-##")
.placeholders("#") { $0.isASCII && $0.isNumber }
.hidden(true)
//=------------------------------------------------------------------------=
// MARK: Tests
//=------------------------------------------------------------------------=
func testNone() {
OKFormat___("", format: "+")
OKInterpret("", format: "+", value: "")
}
func testSome() {
OKFormat___("12000345", format: "+12 (000) 345")
OKInterpret("12000345", format: "+12 (000) 345", value: "12000345")
}
func testFull() {
OKFormat___("120003456789", format: "+12 (000) 345-67-89")
OKInterpret("120003456789", format: "+12 (000) 345-67-89", value: "120003456789")
}
func testMore() {
OKFormat___("120003456789000", format: "+12 (000) 345-67-89|000")
OKInterpret("120003456789000", format: "+12 (000) 345-67-89", value: "120003456789")
}
func testNoneMismatch() {
OKFormat___("ABC", format: "+|ABC")
OKInterpret("ABC", format: "+", value: "")
}
func testSomeMismatch() {
OKFormat___("12000345ABC", format: "+12 (000) 345|ABC")
OKInterpret("12000345ABC", format: "+12 (000) 345", value: "12000345")
}
}
#endif