|
21 | 21 | import static org.assertj.core.api.BDDAssertions.then; |
22 | 22 | import static org.assertj.core.api.BDDAssertions.thenThrownBy; |
23 | 23 |
|
24 | | -import java.util.stream.IntStream; |
25 | | - |
26 | 24 | import org.junit.jupiter.api.Test; |
27 | 25 |
|
28 | 26 | import com.navercorp.fixturemonkey.api.exception.FixedValueFilterMissException; |
@@ -53,100 +51,82 @@ void withRange() { |
53 | 51 | @Test |
54 | 52 | void alphabetic() { |
55 | 53 | // when |
56 | | - boolean allAlpha = IntStream.range(0, 100) |
57 | | - .mapToObj(i -> CombinableArbitrary.chars().alphabetic().combined()) |
58 | | - .allMatch(Character::isLetter); |
| 54 | + Character actual = CombinableArbitrary.chars().alphabetic().combined(); |
59 | 55 |
|
60 | 56 | // then |
61 | | - then(allAlpha).isTrue(); |
| 57 | + then(Character.isLetter(actual)).isTrue(); |
62 | 58 | } |
63 | 59 |
|
64 | 60 | @Test |
65 | 61 | void numeric() { |
66 | 62 | // when |
67 | | - boolean allNumeric = IntStream.range(0, 100) |
68 | | - .mapToObj(i -> CombinableArbitrary.chars().numeric().combined()) |
69 | | - .allMatch(c -> c >= '0' && c <= '9'); |
| 63 | + Character actual = CombinableArbitrary.chars().numeric().combined(); |
70 | 64 |
|
71 | 65 | // then |
72 | | - then(allNumeric).isTrue(); |
| 66 | + then(actual).isBetween('0', '9'); |
73 | 67 | } |
74 | 68 |
|
75 | 69 | @Test |
76 | 70 | void alphaNumeric() { |
77 | 71 | // when |
78 | | - boolean allAlphaNumeric = IntStream.range(0, 100) |
79 | | - .mapToObj(i -> CombinableArbitrary.chars().alphaNumeric().combined()) |
80 | | - .allMatch(Character::isLetterOrDigit); |
| 72 | + Character actual = CombinableArbitrary.chars().alphaNumeric().combined(); |
81 | 73 |
|
82 | 74 | // then |
83 | | - then(allAlphaNumeric).isTrue(); |
| 75 | + then(Character.isLetterOrDigit(actual)).isTrue(); |
84 | 76 | } |
85 | 77 |
|
86 | 78 | @Test |
87 | 79 | void ascii() { |
88 | 80 | // when |
89 | | - boolean allAscii = IntStream.range(0, 100) |
90 | | - .mapToObj(i -> CombinableArbitrary.chars().ascii().combined()) |
91 | | - .allMatch(c -> c >= '\u0020' && c <= '\u007E'); |
| 81 | + Character actual = CombinableArbitrary.chars().ascii().combined(); |
92 | 82 |
|
93 | 83 | // then |
94 | | - then(allAscii).isTrue(); |
| 84 | + then(actual).isBetween('\u0020', '\u007E'); |
95 | 85 | } |
96 | 86 |
|
97 | 87 | @Test |
98 | 88 | void uppercase() { |
99 | 89 | // when |
100 | | - boolean allUppercase = IntStream.range(0, 100) |
101 | | - .mapToObj(i -> CombinableArbitrary.chars().uppercase().combined()) |
102 | | - .allMatch(c -> c >= 'A' && c <= 'Z'); |
| 90 | + Character actual = CombinableArbitrary.chars().uppercase().combined(); |
103 | 91 |
|
104 | 92 | // then |
105 | | - then(allUppercase).isTrue(); |
| 93 | + then(actual).isBetween('A', 'Z'); |
106 | 94 | } |
107 | 95 |
|
108 | 96 | @Test |
109 | 97 | void lowercase() { |
110 | 98 | // when |
111 | | - boolean allLowercase = IntStream.range(0, 100) |
112 | | - .mapToObj(i -> CombinableArbitrary.chars().lowercase().combined()) |
113 | | - .allMatch(c -> c >= 'a' && c <= 'z'); |
| 99 | + Character actual = CombinableArbitrary.chars().lowercase().combined(); |
114 | 100 |
|
115 | 101 | // then |
116 | | - then(allLowercase).isTrue(); |
| 102 | + then(actual).isBetween('a', 'z'); |
117 | 103 | } |
118 | 104 |
|
119 | 105 | @Test |
120 | 106 | void korean() { |
121 | 107 | // when |
122 | | - boolean allKorean = IntStream.range(0, 100) |
123 | | - .mapToObj(i -> CombinableArbitrary.chars().korean().combined()) |
124 | | - .allMatch(c -> c >= '\uAC00' && c <= '\uD7AF'); |
| 108 | + Character actual = CombinableArbitrary.chars().korean().combined(); |
125 | 109 |
|
126 | 110 | // then |
127 | | - then(allKorean).isTrue(); |
| 111 | + then(actual).isBetween('\uAC00', '\uD7AF'); |
128 | 112 | } |
129 | 113 |
|
130 | 114 | @Test |
131 | 115 | void emoji() { |
132 | 116 | // when |
133 | | - boolean allEmoji = IntStream.range(0, 100) |
134 | | - .mapToObj(i -> CombinableArbitrary.chars().emoji().combined()) |
135 | | - .allMatch(c -> c >= '\uD83D' && c <= '\uD83F'); |
| 117 | + Character actual = CombinableArbitrary.chars().emoji().combined(); |
136 | 118 |
|
137 | 119 | // then |
138 | | - then(allEmoji).isTrue(); |
| 120 | + then(actual).isBetween('\uD83D', '\uD83F'); |
139 | 121 | } |
140 | 122 |
|
141 | 123 | @Test |
142 | 124 | void whitespace() { |
143 | 125 | // when |
144 | | - boolean allWhitespace = IntStream.range(0, 100) |
145 | | - .mapToObj(i -> CombinableArbitrary.chars().whitespace().combined()) |
146 | | - .allMatch(Character::isWhitespace); |
| 126 | + Character actual = CombinableArbitrary.chars().whitespace().combined(); |
147 | 127 |
|
148 | 128 | // then |
149 | | - then(allWhitespace).isTrue(); |
| 129 | + then(Character.isWhitespace(actual)).isTrue(); |
150 | 130 | } |
151 | 131 |
|
152 | 132 | @Test |
@@ -277,33 +257,27 @@ void fixed() { |
277 | 257 | @Test |
278 | 258 | void lastMethodWinsKoreanOverAscii() { |
279 | 259 | // when - korean() should take precedence over ascii() |
280 | | - boolean allKorean = IntStream.range(0, 30) |
281 | | - .mapToObj(i -> CombinableArbitrary.chars().ascii().korean().combined()) |
282 | | - .allMatch(c -> c >= '\uAC00' && c <= '\uD7AF'); |
| 260 | + Character actual = CombinableArbitrary.chars().ascii().korean().combined(); |
283 | 261 |
|
284 | 262 | // then |
285 | | - then(allKorean).isTrue(); |
| 263 | + then(actual).isBetween('\uAC00', '\uD7AF'); |
286 | 264 | } |
287 | 265 |
|
288 | 266 | @Test |
289 | 267 | void lastMethodWinsRangeOverAlpha() { |
290 | 268 | // when - withRange() should take precedence over alpha() |
291 | | - boolean allInRange = IntStream.range(0, 30) |
292 | | - .mapToObj(i -> CombinableArbitrary.chars().alphabetic().withRange('0', '9').combined()) |
293 | | - .allMatch(c -> c >= '0' && c <= '9'); |
| 269 | + Character actual = CombinableArbitrary.chars().alphabetic().withRange('0', '9').combined(); |
294 | 270 |
|
295 | 271 | // then |
296 | | - then(allInRange).isTrue(); |
| 272 | + then(actual).isBetween('0', '9'); |
297 | 273 | } |
298 | 274 |
|
299 | 275 | @Test |
300 | 276 | void characterFilterWithSpecificCondition() { |
301 | 277 | // when - filtering uppercase only |
302 | | - boolean allUppercase = IntStream.range(0, 30) |
303 | | - .mapToObj(i -> CombinableArbitrary.chars().alphabetic().filter(Character::isUpperCase).combined()) |
304 | | - .allMatch(Character::isUpperCase); |
| 278 | + Character actual = CombinableArbitrary.chars().alphabetic().filter(Character::isUpperCase).combined(); |
305 | 279 |
|
306 | 280 | // then |
307 | | - then(allUppercase).isTrue(); |
| 281 | + then(Character.isUpperCase(actual)).isTrue(); |
308 | 282 | } |
309 | 283 | } |
0 commit comments