-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathboard_test.rb
More file actions
44 lines (36 loc) · 1.02 KB
/
board_test.rb
File metadata and controls
44 lines (36 loc) · 1.02 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
require 'test/unit'
require './board'
class BoardTest < Test::Unit::TestCase
def test_setting_numbers
board = Board.new(2)
board.put_number(5, Location.new(1, 1))
assert_equal(5, board.get_number(Location.new(1, 1)))
end
def test_full
board = Board.new(2)
board.put_number(1, Location.new(0, 0))
board.put_number(1, Location.new(0, 1))
board.put_number(1, Location.new(1, 0))
board.put_number(1, Location.new(1, 1))
assert_equal(true, board.full?)
end
def test_not_full
board = Board.new(2)
assert_equal(false, board.full?)
end
def test_number_of_empty
board = Board.new(2)
assert_equal(4, board.empty_fields_count)
board.put_number(1, Location.new(1, 1))
assert_equal(3, board.empty_fields_count)
end
def test_put_at_random_location
board = Board.new(2)
board.put_at_random_location(2)
assert_equal(3, board.empty_fields_count)
end
def test_empty_locations
board = Board.new(2)
assert_equal 4, board.empty_locations.count
end
end