forked from AdaGold/array-equals
-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy patharray_equals_spec.rb
More file actions
73 lines (55 loc) · 1.62 KB
/
array_equals_spec.rb
File metadata and controls
73 lines (55 loc) · 1.62 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
require 'minitest/autorun'
require 'minitest/reporters'
require 'minitest/skip_dsl'
require_relative '../lib/array_equals'
describe "array equals" do
describe "basic tests" do
it "arrays are equal" do
array1 = [10, 20, 30, 40, 50, 60]
array2 = [10, 20, 30, 40, 50, 60]
array_equals(array1, array2).must_equal true
end
it "arrays not equal: first six elements are same" do
array1 = [10, 20, 30, 40, 50, 60]
array2 = [10, 20, 30, 40, 50, 60, 70]
array_equals(array1, array2).must_equal false
end
it "arrays not equal: same count of elements" do
array1 = [10, 20, 30, 40, 50, 60]
array2 = [20, 3, 50, 10, 68, 74]
array_equals(array1, array2).must_equal false
end
end
describe "edge cases" do
it "arrays are empty: equal" do
array1 = []
array2 = []
array_equals(array1, array2).must_equal true
end
it "only first array is empty: not equal" do
array1 = []
array2 = [50, 30]
array_equals(array1, array2).must_equal false
end
it "only second array is empty: not equal" do
array1 = [20]
array2 = []
array_equals(array1, array2).must_equal false
end
it "arrays are nil: equal" do
array1 = nil
array2 = nil
array_equals(array1, array2).must_equal true
end
it "only first array is nil: not equal" do
array1 = nil
array2 = [10, 20]
array_equals(array1, array2).must_equal false
end
it "only second array is nil: not equal" do
array1 = [20]
array2 = nil
array_equals(array1, array2).must_equal false
end
end
end