Class ConstraintSolver::DomainTest
In: test/DomainTest.rb
Parent: Test::Unit::TestCase
Test::Unit::TestCase AllDifferentConstraintTest SolutionTest ConstraintSolverTest ConstraintListTest VariableTest DomainTest BinaryConstraintTest ProblemTest BinaryRelationTest Exception DomainWipeoutException UndoStackEmptyException AbstractConstraint BinaryConstraint AllDifferentConstraint Array ConstraintList BinaryRelation Variable Solution ConstraintSolver Problem Domain test/DomainTest.rb test/SolutionTest.rb lib/BinaryConstraint.rb lib/Variable.rb test/ConstraintListTest.rb lib/ConstraintList.rb test/ProblemTest.rb lib/Solution.rb test/BinaryConstraintTest.rb lib/ConstraintSolver.rb test/VariableTest.rb test/AllDifferentConstraintTest.rb lib/AllDifferentConstraint.rb lib/Problem.rb test/ConstraintSolverTest.rb lib/Domain.rb lib/AbstractConstraint.rb ConstraintSolver dot/m_19_0.png

Methods

Public Instance methods

[Source]

# File test/DomainTest.rb, line 10
        def setup
            @domain = Domain.new([ 2, 3, 4 ].to_set)
        end

[Source]

# File test/DomainTest.rb, line 14
        def testConstructor
            assert_nothing_raised { Domain.new }
            assert_raise(ArgumentError) { Domain.new(3) }
            assert_raise(ArgumentError) { Domain.new([ 2 ]) }
            assert_nothing_raised { Domain.new([ 2 ].to_set) }
            assert_nothing_raised { Domain.new([ 2, 3, 4 ].to_set) }
        end

[Source]

# File test/DomainTest.rb, line 22
        def testDomainAddDelete
            domain = Domain.new
            assert(domain.empty?)
            domain << 3
            assert(domain.include?(3))
            domain.delete(3)
            assert(domain.empty?)
        end

[Source]

# File test/DomainTest.rb, line 50
        def testEquals
            assert_equal(@domain, Domain.new([ 2, 3, 4 ].to_set))
            assert_not_equal(@domain, Domain.new([ 2, 3 ].to_set))
            @domain.prune(4)
            assert_not_equal(@domain, Domain.new([ 2, 3 ].to_set))
        end

[Source]

# File test/DomainTest.rb, line 38
        def testPruneScalar
            @domain.prune(2)
            assert_equal([ 3, 4 ].to_set, @domain.values)
            @domain.undoPruning
            assert_equal([ 2, 3, 4 ].to_set, @domain.values)
        end

[Source]

# File test/DomainTest.rb, line 31
        def testPruneSet
            @domain.prune([ 2, 3 ].to_set)
            assert_equal([ 4 ].to_set, @domain.values)
            @domain.undoPruning
            assert_equal([ 2, 3, 4 ].to_set, @domain.values)
        end

[Source]

# File test/DomainTest.rb, line 45
        def testPruneWithErrors
            assert_raise(UndoStackEmptyException) { @domain.undoPruning }
            assert_raise(DomainWipeoutException) { @domain.prune([ 2, 3, 4 ].to_set) }
        end

[Validate]