-
Notifications
You must be signed in to change notification settings - Fork 0
/
DivisibilityRuleExecutionTest.groovy
187 lines (168 loc) · 4.65 KB
/
DivisibilityRuleExecutionTest.groovy
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
package com.lemiorhanergin.divisibilityrules
import groovy.util.logging.Slf4j
import spock.lang.Specification
@Slf4j
class DivisibilityRuleExecutionTest extends Specification {
def "should find divisibility results"() {
given:
def divisibilityRule = new DivisibilityRule()
DivisibilityRule.isLogEnabled = true
when:
log.info("==============[{}/{}]==============", dividend, divisor)
def isDivisible = divisibilityRule.isDivisible(dividend, divisor)
then:
isDivisible ? (dividend % divisor == 0) : (dividend % divisor != 0)
where:
dividend | divisor
// divisible - simple numbers
10 | 2
18 | 3
8 | 4
15 | 5
12 | 6
21 | 7
24 | 8
18 | 9
// NOT divisible - simple numbers
11 | 2
19 | 3
9 | 4
16 | 5
13 | 6
22 | 7
25 | 8
19 | 9
// divisible - two digit numbers
74283 | 11
1044 | 12
175789 | 23
22406 | 34
41490 | 45
132832 | 56
38391 | 67
650286 | 78
515221 | 89
// NOT divisible - two digit numbers
74284 | 11
1045 | 12
175788 | 23
22407 | 34
41491 | 45
132833 | 56
38390 | 67
650287 | 78
515222 | 89
// divisible - five digit numbers
7162290074 | 10961
6027414224 | 16882
9448278984 | 20637
13386093162 | 37414
23021493432 | 49251
25916917952 | 55456
13092489839 | 60073
75939187148 | 73778
222387483957 | 89909
// NOT divisible - five digit numbers
7162290073 | 10961
6027414222 | 16882
9448278985 | 20637
13386093161 | 37414
23021493430 | 49251
25916917953 | 55456
13092489836 | 60073
75939187142 | 73778
222387483951 | 89909
}
def "should find divisibility results2"() {
given:
def divisibilityRule = new DivisibilityRule()
DivisibilityRule.isLogEnabled = true
when:
log.info("==============[{}/{}]==============", dividend, divisor)
def isDivisible = divisibilityRule.isDivisible(dividend, divisor)
then:
isDivisible ? (dividend % divisor == 0) : (dividend % divisor != 0)
where:
dividend | divisor
837 | 216
837 | 558
838 | 16
838 | 27
839 | 16
839 | 27
840 | 16
840 | 27
840 | 96
840 | 336
841 | 16
841 | 27
841 | 58
841 | 87
841 | 116
841 | 145
842 | 16
842 | 27
843 | 16
843 | 27
844 | 16
844 | 27
845 | 16
845 | 27
845 | 117
24 | 16
32 | 16
27 | 18
28 | 16
36 | 16
36 | 27
38 | 16
39 | 27
40 | 16
3 | 2
4 | 3
5 | 2
240 | 36
240 | 9
6 | 2
8 | 2
186 | 3
270 | 45
104 | 16
108 | 16
108 | 45
116 | 16
117 | 18
117 | 27
117 | 36
117 | 45
120 | 16
124 | 16
126 | 27
126 | 36
126 | 45
132 | 16
135 | 18
135 | 36
}
def "should find divisibility results3"() {
given:
def divisibilityRule = new DivisibilityRule()
DivisibilityRule.isLogEnabled = true
when:
log.info("==============[{}/{}]==============", dividend, divisor)
def isDivisible = divisibilityRule.isDivisible(dividend, divisor)
then:
isDivisible ? (dividend % divisor == 0) : (dividend % divisor != 0)
where:
dividend | divisor
18 | 3
1044 | 12
175789 | 23
24 | 8
19 | 3
41490 | 45
74284 | 11
25916917952 | 55456
23021493430 | 49251
}
}