-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrains_test.rb
71 lines (58 loc) · 1.68 KB
/
grains_test.rb
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
require 'minitest/autorun'
require_relative 'grains'
# Common test data version: 1.0.0 2e0e77e
class GrainsTest < Minitest::Test
def test_1
# skip
assert_equal 1, Grains.square(1)
end
def test_2
assert_equal 2, Grains.square(2)
end
def test_3
assert_equal 4, Grains.square(3)
end
def test_4
assert_equal 8, Grains.square(4)
end
def test_16
assert_equal 32_768, Grains.square(16)
end
def test_32
assert_equal 2_147_483_648, Grains.square(32)
end
def test_64
assert_equal 9_223_372_036_854_775_808, Grains.square(64)
end
def test_square_0_raises_an_exception
assert_raises(ArgumentError) { Grains.square(0) }
end
def test_negative_square_raises_an_exception
assert_raises(ArgumentError) { Grains.square(-1) }
end
def test_square_greater_than_64_raises_an_exception
assert_raises(ArgumentError) { Grains.square(65) }
end
def test_returns_the_total_number_of_grains_on_the_board
assert_equal 18_446_744_073_709_551_615, Grains.total
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, which may be placed near the end of your file.
#
# 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
assert_equal 1, BookKeeping::VERSION
end
end