-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclock_test.rb
More file actions
executable file
·310 lines (257 loc) · 6.7 KB
/
clock_test.rb
File metadata and controls
executable file
·310 lines (257 loc) · 6.7 KB
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
#!/usr/bin/env ruby
gem 'minitest', '>= 5.0.0'
require 'minitest/autorun'
require_relative 'clock'
# Test data version:
# deb225e Implement canonical dataset for scrabble-score problem (#255)
class ClockTest < Minitest::Test
def test_on_the_hour
# skip
assert_equal '08:00', Clock.at(8, 0).to_s
end
def test_past_the_hour
skip
assert_equal '11:09', Clock.at(11, 9).to_s
end
def test_midnight_is_zero_hours
skip
assert_equal '00:00', Clock.at(24, 0).to_s
end
def test_hour_rolls_over
skip
assert_equal '01:00', Clock.at(25, 0).to_s
end
def test_hour_rolls_over_continuously
skip
assert_equal '04:00', Clock.at(100, 0).to_s
end
def test_sixty_minutes_is_next_hour
skip
assert_equal '02:00', Clock.at(1, 60).to_s
end
def test_minutes_roll_over
skip
assert_equal '02:40', Clock.at(0, 160).to_s
end
def test_minutes_roll_over_continuously
skip
assert_equal '04:43', Clock.at(0, 1723).to_s
end
def test_hour_and_minutes_roll_over
skip
assert_equal '03:40', Clock.at(25, 160).to_s
end
def test_hour_and_minutes_roll_over_continuously
skip
assert_equal '11:01', Clock.at(201, 3001).to_s
end
def test_hour_and_minutes_roll_over_to_exactly_midnight
skip
assert_equal '00:00', Clock.at(72, 8640).to_s
end
def test_negative_hour
skip
assert_equal '23:15', Clock.at(-1, 15).to_s
end
def test_negative_hour_rolls_over
skip
assert_equal '23:00', Clock.at(-25, 0).to_s
end
def test_negative_hour_rolls_over_continuously
skip
assert_equal '05:00', Clock.at(-91, 0).to_s
end
def test_negative_minutes
skip
assert_equal '00:20', Clock.at(1, -40).to_s
end
def test_negative_minutes_roll_over
skip
assert_equal '22:20', Clock.at(1, -160).to_s
end
def test_negative_minutes_roll_over_continuously
skip
assert_equal '16:40', Clock.at(1, -4820).to_s
end
def test_negative_hour_and_minutes_both_roll_over
skip
assert_equal '20:20', Clock.at(-25, -160).to_s
end
def test_negative_hour_and_minutes_both_roll_over_continuously
skip
assert_equal '22:10', Clock.at(-121, -5810).to_s
end
def test_add_minutes
skip
assert_equal '10:03', (Clock.at(10, 0) + 3).to_s
end
def test_add_no_minutes
skip
assert_equal '06:41', (Clock.at(6, 41) + 0).to_s
end
def test_add_to_next_hour
skip
assert_equal '01:25', (Clock.at(0, 45) + 40).to_s
end
def test_add_more_than_one_hour
skip
assert_equal '11:01', (Clock.at(10, 0) + 61).to_s
end
def test_add_more_than_two_hours_with_carry
skip
assert_equal '03:25', (Clock.at(0, 45) + 160).to_s
end
def test_add_across_midnight
skip
assert_equal '00:01', (Clock.at(23, 59) + 2).to_s
end
def test_add_more_than_one_day__1500_min_is_equal_to_25_hrs
skip
assert_equal '06:32', (Clock.at(5, 32) + 1500).to_s
end
def test_add_more_than_two_days
skip
assert_equal '11:21', (Clock.at(1, 1) + 3500).to_s
end
def test_subtract_minutes
skip
assert_equal '10:00', (Clock.at(10, 3) + -3).to_s
end
def test_subtract_to_previous_hour
skip
assert_equal '09:33', (Clock.at(10, 3) + -30).to_s
end
def test_subtract_more_than_an_hour
skip
assert_equal '08:53', (Clock.at(10, 3) + -70).to_s
end
def test_subtract_across_midnight
skip
assert_equal '23:59', (Clock.at(0, 3) + -4).to_s
end
def test_subtract_more_than_two_hours
skip
assert_equal '21:20', (Clock.at(0, 0) + -160).to_s
end
def test_subtract_more_than_two_hours_with_borrow
skip
assert_equal '03:35', (Clock.at(6, 15) + -160).to_s
end
def test_subtract_more_than_one_day__1500_min_is_equal_to_25_hrs
skip
assert_equal '04:32', (Clock.at(5, 32) + -1500).to_s
end
def test_subtract_more_than_two_days
skip
assert_equal '00:20', (Clock.at(2, 20) + -3000).to_s
end
def test_clocks_with_same_time
skip
clock1 = Clock.at(15, 37)
clock2 = Clock.at(15, 37)
assert clock1 == clock2
end
def test_clocks_a_minute_apart
skip
clock1 = Clock.at(15, 36)
clock2 = Clock.at(15, 37)
refute clock1 == clock2
end
def test_clocks_an_hour_apart
skip
clock1 = Clock.at(14, 37)
clock2 = Clock.at(15, 37)
refute clock1 == clock2
end
def test_clocks_with_hour_overflow
skip
clock1 = Clock.at(10, 37)
clock2 = Clock.at(34, 37)
assert clock1 == clock2
end
def test_clocks_with_hour_overflow_by_several_days
skip
clock1 = Clock.at(3, 11)
clock2 = Clock.at(99, 11)
assert clock1 == clock2
end
def test_clocks_with_negative_hour
skip
clock1 = Clock.at(22, 40)
clock2 = Clock.at(-2, 40)
assert clock1 == clock2
end
def test_clocks_with_negative_hour_that_wraps
skip
clock1 = Clock.at(17, 3)
clock2 = Clock.at(-31, 3)
assert clock1 == clock2
end
def test_clocks_with_negative_hour_that_wraps_multiple_times
skip
clock1 = Clock.at(13, 49)
clock2 = Clock.at(-83, 49)
assert clock1 == clock2
end
def test_clocks_with_minute_overflow
skip
clock1 = Clock.at(0, 1)
clock2 = Clock.at(0, 1441)
assert clock1 == clock2
end
def test_clocks_with_minute_overflow_by_several_days
skip
clock1 = Clock.at(2, 2)
clock2 = Clock.at(2, 4322)
assert clock1 == clock2
end
def test_clocks_with_negative_minute
skip
clock1 = Clock.at(2, 40)
clock2 = Clock.at(3, -20)
assert clock1 == clock2
end
def test_clocks_with_negative_minute_that_wraps
skip
clock1 = Clock.at(4, 10)
clock2 = Clock.at(5, -1490)
assert clock1 == clock2
end
def test_clocks_with_negative_minute_that_wraps_multiple_times
skip
clock1 = Clock.at(6, 15)
clock2 = Clock.at(6, -4305)
assert clock1 == clock2
end
def test_clocks_with_negative_hours_and_minutes
skip
clock1 = Clock.at(7, 32)
clock2 = Clock.at(-12, -268)
assert clock1 == clock2
end
def test_clocks_with_negative_hours_and_minutes_that_wrap
skip
clock1 = Clock.at(18, 7)
clock2 = Clock.at(-54, -11_513)
assert clock1 == clock2
end
# Problems in exercism evolve over time, as we find better ways to ask
# questions.
# The version number refers to the version of the problem you solved,
# not your solution.
#
# Define a constant named VERSION inside of the top level BookKeeping
# module.
# In your file, it will look like this:
#
# module BookKeeping
# VERSION = 1 # Where the version number matches the one in the test.
# end
#
# If you are curious, read more about constants on RubyDoc:
# http://ruby-doc.org/docs/ruby-doc-bundle/UsersGuide/rg/constants.html
def test_bookkeeping
skip
assert_equal 2, BookKeeping::VERSION
end
end