Class | ConstraintSolver::VariableTest |
In: |
test/VariableTest.rb
|
Parent: | Test::Unit::TestCase |
# File test/VariableTest.rb, line 11 def setup @variable = Variable.new("test", Domain.new([ 3, 4, 5 ].to_set)) end
# File test/VariableTest.rb, line 28 def testAssignment assert_raise(ArgumentError) { @variable.value = 2 } assert_nothing_raised { @variable.value = nil } assert_nothing_raised { @variable.value = 3 } assert(@variable.assigned?) assert_equal(3, @variable.value) @variable.reset assert_equal(false, @variable.assigned?) assert_equal(nil, @variable.value) end
# File test/VariableTest.rb, line 15 def testConstructor assert_raise(ArgumentError) { Variable.new } assert_raise(ArgumentError) { Variable.new(nil) } assert_raise(ArgumentError) { Variable.new(3) } assert_raise(ArgumentError) { Variable.new("name", Domain.new([ 3 ].to_set), 4) } assert_nothing_raised { var = Variable.new("name", nil, 3) assert_equal([ 3 ].to_set, var.domain.values) } assert_nothing_raised { Variable.new("name", Domain.new([ 3 ].to_set)) } assert_nothing_raised { Variable.new("name", Domain.new([ 3 ].to_set), 3) } end
# File test/VariableTest.rb, line 39 def testEquals assert_equal(@variable, Variable.new("test", Domain.new([ 3, 4, 5 ].to_set))) assert_not_equal(@variable, Variable.new("test", nil, 3)) assert_not_equal(@variable, Variable.new("test", Domain.new([ 3, 4, 5 ].to_set), 3)) assert_not_equal(@variable, Variable.new("tester", Domain.new([ 3, 4, 5 ].to_set))) end