-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy patharray_subsets_test.rb
49 lines (42 loc) · 1.24 KB
/
array_subsets_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
require_relative "../../test_helper"
require_relative "array_subsets"
describe ArraySubsets do
describe "edge cases" do
it "should print an empty string given an empty array" do
arr = []
subject = -> { ArraySubsets.run(arr, Array.new(arr.length), 0, 0) }
expect(subject).must_output ""
end
end
describe "base cases" do
it "should print subsets of an array with length 1" do
expected = print_results([], [1])
arr = [1]
subject = -> { ArraySubsets.run(arr, Array.new(arr.length), 0, 0) }
expect(subject).must_output expected
end
it "should print subsets of an array with length 2" do
expected = print_results([], [1], [1, 2], [2])
arr = [1, 2]
subject = -> { ArraySubsets.run(arr, Array.new(arr.length), 0, 0) }
expect(subject).must_output expected
end
end
describe "regular cases" do
it "should print subsets of an array with length > 2" do
expected = print_results(
[],
[1],
[1, 2],
[1, 2, 3],
[1, 3],
[2],
[2, 3],
[3]
)
arr = [1, 2, 3]
subject = -> { ArraySubsets.run(arr, Array.new(arr.length), 0, 0) }
expect(subject).must_output expected
end
end
end