-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathprint_combos_test.rb
52 lines (45 loc) · 1.71 KB
/
print_combos_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
require_relative "../../test_helper"
require_relative "print_combos"
describe PrintCombos do
describe "edge cases" do
it "should print an empty string given an empty array" do
expected = ""
subject = -> { PrintCombos.run([], Array.new(0), 0, 0) }
expect(subject).must_output expected
end
it "should print an empty string when x > arr.length" do
expected = ""
subject = -> { PrintCombos.run([1, 2, 3], Array.new(4), 0, 0) }
expect(subject).must_output expected
end
end
describe "base cases" do
it "should print results when x = 1, arr.length == 1" do
expected = print_results [1]
subject = -> { PrintCombos.run([1], Array.new(1), 0, 0) }
expect(subject).must_output expected
end
it "should print results when x = 1, arr.length == 2" do
expected = print_results [1], [2]
subject = -> { PrintCombos.run([1, 2], Array.new(1), 0, 0) }
expect(subject).must_output expected
end
end
describe "regular cases" do
it "should print results when = 2, arr.length == 3" do
expected = print_results [1, 2], [1, 3], [2, 3]
subject = -> { PrintCombos.run([1, 2, 3], Array.new(2), 0, 0) }
expect(subject).must_output expected
end
it "should print results when x = 3, arr.length == 4" do
expected = print_results [1, 2, 3], [1, 2, 4], [1, 3, 4], [2, 3, 4]
subject = -> { PrintCombos.run([1, 2, 3, 4], Array.new(3), 0, 0) }
expect(subject).must_output expected
end
it "should print results when x = 3, arr.length == 3" do
expected = print_results [1, 2, 3]
subject = -> { PrintCombos.run([1, 2, 3], Array.new(3), 0, 0) }
expect(subject).must_output expected
end
end
end