Class: MyListClassTests
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- MyListClassTests
- Defined in:
- lib/testing.rb,
lib/testing.rb,
lib/testing.rb
Class Method Summary collapse
Instance Method Summary collapse
- #test_append ⇒ Object
- #test_contents ⇒ Object
- #test_find_first_position_of ⇒ Object
- #test_find_positions_of ⇒ Object
- #test_maximum ⇒ Object
- #test_min_max ⇒ Object
- #test_minimum ⇒ Object
- #test_new ⇒ Object
Class Method Details
.in_sequence(sequence) ⇒ Object
127 128 129 |
# File 'lib/testing.rb', line 127 def self.in_sequence(sequence) ARGV[0] =~ /#{sequence}/ || ARGV[0].nil? || ARGV[0] =~ /RECORD/ end |
Instance Method Details
#test_append ⇒ Object
142 143 144 145 146 147 |
# File 'lib/testing.rb', line 142 def test_append my_list = MyList.new([1, 2, 3]) my_list.append(4) assert_equal [1, 2, 3, 4], my_list.contents assert_includes my_list.contents, 4 end |
#test_contents ⇒ Object
137 138 139 |
# File 'lib/testing.rb', line 137 def test_contents assert_equal [1, 2, 3], MyList.new([1, 2, 3]).contents end |
#test_find_first_position_of ⇒ Object
150 151 152 153 154 155 |
# File 'lib/testing.rb', line 150 def test_find_first_position_of my_list = MyList.new([1, 2, 3, 2, 5]) assert_equal 1, my_list.find_first_position_of(2) assert_equal 0, my_list.find_first_position_of(1) assert_equal 4, my_list.find_first_position_of(5) end |
#test_find_positions_of ⇒ Object
159 160 161 162 163 164 |
# File 'lib/testing.rb', line 159 def test_find_positions_of my_list = MyList.new([1, 2, 3, 2, 5]) assert_equal [1, 3], my_list.find_positions_of(2) assert_equal [0], my_list.find_positions_of(1) assert_equal [4], my_list.find_positions_of(5) end |
#test_maximum ⇒ Object
167 168 169 170 171 172 |
# File 'lib/testing.rb', line 167 def test_maximum my_list = MyList.new([1, 2, 3, 2, 5, 16, 7, 12]) assert_equal 16, my_list.maximum my_list = MyList.new([12, 2, 33, 2, 5, 16, 7, 12]) assert_equal 33, my_list.maximum end |
#test_min_max ⇒ Object
183 184 185 186 187 188 189 190 |
# File 'lib/testing.rb', line 183 def test_min_max my_list = MyList.new([1, 2, 3, 2, 5, 16, 7, 12]) assert_equal [1, 16], my_list.min_max my_list = MyList.new([12, 2, 33, 2, 5, 16, 7, 12]) assert_equal [2, 33], my_list.min_max my_list = MyList.new([12, 1, 2, 3, 2, 25, 16, 7]) assert_equal [1, 25], my_list.min_max end |
#test_minimum ⇒ Object
175 176 177 178 179 180 |
# File 'lib/testing.rb', line 175 def test_minimum my_list = MyList.new([1, 2, 3, 2, 5, 16, 7, 12]) assert_equal 1, my_list.minimum my_list = MyList.new([12, 1, 2, 3, 2, 25, 16, 7]) assert_equal 1, my_list.minimum end |
#test_new ⇒ Object
132 133 134 |
# File 'lib/testing.rb', line 132 def test_new assert_kind_of MyList, MyList.new([1, 2, 3]) end |