forked from AdaGold/dynamic-programming
-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathnewman_conway_test.rb
More file actions
53 lines (39 loc) · 842 Bytes
/
newman_conway_test.rb
File metadata and controls
53 lines (39 loc) · 842 Bytes
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
require_relative "test_helper"
describe "Newman Conway Tests" do
it "works with 13" do
# Arrange
input = 13
# Act
answer = newman_conway(input)
# Assert
expect(answer).must_equal "1 1 2 2 3 4 4 4 5 6 7 7 8"
end
it "works with 20" do
# Arrange
input = 20
# Act
answer = newman_conway(input)
# Assert
expect(answer).must_equal "1 1 2 2 3 4 4 4 5 6 7 7 8 8 8 8 9 10 11 12"
end
it "works with base cases" do
# Arrange
input = 0
# Act-Assert
expect {
newman_conway(input)
}.must_raise ArgumentError
# Arrange
input = 1
# Act
answer = newman_conway(input)
# Assert
expect(answer).must_equal "1"
# Arrange
input = 2
# Act
answer = newman_conway(input)
# Assert
expect(answer).must_equal "1 1"
end
end