forked from tiyd-rails-2015-01/odd_array
-
Notifications
You must be signed in to change notification settings - Fork 0
/
odd_array_test.rb
62 lines (51 loc) · 1.41 KB
/
odd_array_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
gem 'minitest'
require 'minitest/autorun'
require 'minitest/pride'
require './odd_array'
class OddArrayTest < Minitest::Test
#This is not good practice, AND it forces you to do dumb things like test_c_
# in the code. However, it's easier to follow as you're learning if the
# tests always run in the same order.
def self.test_order
:alpha
end
def test_a_class_exists
assert OddArray
end
def test_b_initializer_takes_array_parameter
assert OddArray.new([1, 3, 5])
end
def test_c_to_a
odd_array = OddArray.new([1, 3, 5])
assert_equal [1, 3, 5], odd_array.to_a
end
def test_d_add_number
odd_array = OddArray.new([1, 3, 5])
odd_array.add(7)
assert_equal [1, 3, 5, 7], odd_array.to_a
end
def test_e_initialize_with_evens
odd_array = OddArray.new([1, 2, 3, 4, 5])
assert_equal [1, 3, 5], odd_array.to_a
end
def test_f_add_evens
odd_array = OddArray.new([1, 3, 5])
odd_array.add(2)
assert_equal [1, 3, 5], odd_array.to_a
end
def test_g_add_negatives
odd_array = OddArray.new([-1, -2, 3, 4, -5])
odd_array.add(-4)
assert_equal [-1, 3, -5], odd_array.to_a
end
def test_h_add_decimals
odd_array = OddArray.new([1, 3.2, 5])
odd_array.add(2.1)
assert_equal [1, 5], odd_array.to_a
end
def test_i_add_strings
odd_array = OddArray.new([1, "Bob", 2])
odd_array.add("Jen")
assert_equal [1], odd_array.to_a
end
end