# file: testnet.rb
require 'test/unit'
require 'net'
class TestNet < Test::Unit::TestCase
def setup
@net = Net.new
end
def test_tied
assert_equal true, ! @net.tied?(1,1)
end
def test_tie
@net.tie(1,1)
assert_equal true, @net.tied?(1,1)
end
def test_multiple_positions
@net.tie(1,1)
assert_equal true, @net.tied?(1,1)
assert_equal false, @net.tied?(1,2)
assert_equal false, @net.tied?(2,1)
assert_equal false, @net.tied?(2,2)
end
def test_untie
@net.tie(1,1)
@net.untie(1,1)
assert_equal false, @net.tied?(1,1)
end
def test_max_matrix_size
check_location(1,1)
check_location(1,5)
check_location(5,1)
check_location(5,5)
end
def check_location(x,y)
assert_equal false, @net.tied?(x,y)
@net.tie(x,y)
assert_equal true, @net.tied?(x,y)
@net.untie(x,y)
assert_equal false, @net.tied?(x,y)
end
end
|