1
+ package com.memoizr.assertk
2
+
3
+ import com.memoizr.assertk.CharSequenceAssertTest.*
4
+ import org.assertj.core.api.AbstractCharSequenceAssert
5
+ import org.assertj.core.api.Assertions.assertThat
6
+ import java.util.regex.Pattern
7
+
8
+ enum class CharSequenceAssertTest {
9
+ nullOrEmpty, empty, notEmpty
10
+ }
11
+
12
+ class CharSequenceAssert internal constructor(
13
+ private val subject : CharSequence? ,
14
+ override val assertion : AbstractCharSequenceAssert <* , out CharSequence > = assertThat(subject)) :
15
+ AbstractAssertBuilder <CharSequenceAssert , CharSequence >(subject, CharSequenceAssert ::class .java) {
16
+
17
+ object onlyDigits
18
+
19
+ infix fun _is (assertionTest : CharSequenceAssertTest ): CharSequenceAssert {
20
+ when (assertionTest) {
21
+ empty -> assertion.isEmpty()
22
+ notEmpty -> assertion.isNotEmpty()
23
+ nullOrEmpty -> assertion.isNullOrEmpty()
24
+ }
25
+ return this
26
+ }
27
+
28
+ infix fun hasSize (expectedSize : Int ): CharSequenceAssert {
29
+ assertion.hasSize(expectedSize)
30
+ return this
31
+ }
32
+
33
+ infix fun hasLineCount (expectedLineCount : Int ): CharSequenceAssert {
34
+ assertion.hasLineCount(expectedLineCount)
35
+ return this
36
+ }
37
+
38
+ infix fun isEqualToIgnoringCase (expected : CharSequence ): CharSequenceAssert {
39
+ assertion.isEqualToIgnoringCase(expected)
40
+ return this
41
+ }
42
+
43
+ infix fun isNotEqualToIgnoringCase (expected : CharSequence ): CharSequenceAssert {
44
+ assertion.isNotEqualToIgnoringCase(expected)
45
+ return this
46
+ }
47
+
48
+ infix fun contains (onlyDigits : onlyDigits): CharSequenceAssert {
49
+ assertion.containsOnlyDigits()
50
+ return this
51
+ }
52
+
53
+ infix fun contains (expected : CharSequence ): CharSequenceAssert {
54
+ assertion.contains(expected)
55
+ return this
56
+ }
57
+
58
+ infix fun containsOnlyOnce (expected : CharSequence ): CharSequenceAssert {
59
+ assertion.containsOnlyOnce(expected)
60
+ return this
61
+ }
62
+
63
+ infix fun contains (expected : Iterable <CharSequence >): CharSequenceAssert {
64
+ assertion.contains(expected)
65
+ return this
66
+ }
67
+
68
+ infix fun containsSequence (expected : Iterable <CharSequence >): CharSequenceAssert {
69
+ assertion.containsSequence(expected)
70
+ return this
71
+ }
72
+
73
+ infix fun containsIgnoringCase (expected : CharSequence ): CharSequenceAssert {
74
+ assertion.containsIgnoringCase(expected)
75
+ return this
76
+ }
77
+
78
+ infix fun doesNotContain (expected : CharSequence ): CharSequenceAssert {
79
+ assertion.doesNotContain(expected)
80
+ return this
81
+ }
82
+
83
+ infix fun startsWith (expected : CharSequence ): CharSequenceAssert {
84
+ assertion.startsWith(expected)
85
+ return this
86
+ }
87
+
88
+ infix fun doesNotStartWith (expected : CharSequence ): CharSequenceAssert {
89
+ assertion.doesNotStartWith(expected)
90
+ return this
91
+ }
92
+
93
+ infix fun endsWith (expected : CharSequence ): CharSequenceAssert {
94
+ assertion.endsWith(expected)
95
+ return this
96
+ }
97
+
98
+ infix fun doesNotEndWith (expected : CharSequence ): CharSequenceAssert {
99
+ assertion.doesNotEndWith(expected)
100
+ return this
101
+ }
102
+
103
+ infix fun matches (expected : Pattern ): CharSequenceAssert {
104
+ assertion.matches(expected)
105
+ return this
106
+ }
107
+
108
+ infix fun doesNotMatch (expected : Pattern ): CharSequenceAssert {
109
+ assertion.doesNotMatch(expected)
110
+ return this
111
+ }
112
+
113
+ infix fun matches (expected : CharSequence ): CharSequenceAssert {
114
+ assertion.matches(expected)
115
+ return this
116
+ }
117
+
118
+ infix fun doesNotMatch (expected : CharSequence ): CharSequenceAssert {
119
+ assertion.doesNotMatch(expected)
120
+ return this
121
+ }
122
+
123
+ infix fun isEqualToIgnoringWhitespace (expected : CharSequence ): CharSequenceAssert {
124
+ assertion.isEqualToIgnoringWhitespace(expected)
125
+ return this
126
+ }
127
+
128
+ infix fun isNotEqualToIgnoringWhitespace (expected : CharSequence ): CharSequenceAssert {
129
+ assertion.isNotEqualToIgnoringWhitespace(expected)
130
+ return this
131
+ }
132
+
133
+ infix fun isSubstringOf (expected : CharSequence ): CharSequenceAssert {
134
+ assertion.isSubstringOf(expected)
135
+ return this
136
+ }
137
+
138
+ infix fun containsPattern (pattern : CharSequence ): CharSequenceAssert {
139
+ assertion.containsPattern(pattern)
140
+ return this
141
+ }
142
+
143
+ infix fun containsPattern (pattern : Pattern ): CharSequenceAssert {
144
+ assertion.containsPattern(pattern)
145
+ return this
146
+ }
147
+ }
0 commit comments