-
Notifications
You must be signed in to change notification settings - Fork 0
/
boardrender_test.rb
43 lines (38 loc) · 1.31 KB
/
boardrender_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
require 'minitest/autorun'
require_relative 'board'
require_relative 'boardrender'
class BoardRenderTest < MiniTest::Test
def test_render_empty_rank
expected_row = "| | | | | | | | |"
board = Board.empty
renderer = BoardRender.new board
assert_equal expected_row, renderer.render_rank(?1)
end
def test_render_empty
expected_row = "|*R | | | | | | | Q |"
board = Board.new({a1: Rook.black, h1: Queen.white})
renderer = BoardRender.new board
assert_equal expected_row, renderer.render_rank(?1)
end
def test_render_board
expected =
"|*R |*N |*B |*Q |*K |*B |*N |*R |\n" +
"---------------------------------\n" +
"|*P |*P |*P |*P |*P |*P |*P |*P |\n" +
"---------------------------------\n" +
"| | | | | | | | |\n" +
"---------------------------------\n" +
"| | | | | | | | |\n" +
"---------------------------------\n" +
"| | | | | | | | |\n" +
"---------------------------------\n" +
"| | | | | | | | |\n" +
"---------------------------------\n" +
"| P | P | P | P | P | P | P | P |\n" +
"---------------------------------\n" +
"| R | N | B | Q | K | B | N | R |\n"
board = Board.new.setup
renderer = BoardRender.new board
assert_equal expected, renderer.render
end
end