Created
September 23, 2010 15:03
-
-
Save soveran/593761 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "go/gtp/board" | |
require "cutest" | |
setup do | |
string = <<-EOS.gsub(/^ {2}/, "") | |
A B C D E F G H J | |
9 . . . . . . . . . 9 | |
8 . . . . . . . . . 8 | |
7 . . X . . . + . . 7 | |
6 . . . . . . . . . 6 | |
5 . . . . + . . . . 5 | |
4 . . . . . . . . . 4 | |
3 . . + . . O + . . 3 | |
2 . . . . . . . . . 2 WHITE (O) has captured 10 stones | |
1 . . . . . . . . . 1 BLACK (X) has captured 11 stones | |
A B C D E F G H J | |
EOS | |
[Go::GTP::Board.new(string), string] | |
end | |
test "should stringify to what it was created from" do |board, string| | |
assert board.to_s == string | |
end | |
test "should support indexing by coordinates" do |board| | |
assert board[0, 0].nil? | |
assert board[2, 6] == "black" | |
assert board[5, 2] == "white" | |
end | |
test "should support indexing by vertices" do |board| | |
assert board["A1"].nil? | |
assert board["C7"] == "black" | |
assert board["F3"] == "white" | |
end | |
test "should fail to index for any other combination" do |board| | |
assert_raise(ArgumentError) do | |
board["A", "1"] | |
end | |
end | |
test "should be able to count captures by color name" do |board| | |
assert board.captures("white") == 10 | |
assert board.captures("WHITE") == 10 | |
assert board.captures("black") == 11 | |
assert board.captures("BLACK") == 11 | |
end | |
test "should be able to count captures by stone type" do |board| | |
assert board.captures("o") == 10 | |
assert board.captures("O") == 10 | |
assert board.captures("x") == 11 | |
assert board.captures("X") == 11 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment