#!/usr/bin/ruby $:.unshift File.join(File.dirname(__FILE__), "..", "lib") require 'test/unit' require 'Problem' require 'Variable' require 'BinaryConstraint' require 'ConstraintList' require 'Domain' module ConstraintSolver class ProblemTest < Test::Unit::TestCase def setup @var1 = Variable.new("var1", nil, 1) var2 = Variable.new("var2", nil, 2) var3 = Variable.new("var3", nil, 3) @c1 = BinaryConstraint.new(@var1, var2, Proc.new {|a, b| a == b }) c2 = BinaryConstraint.new(var2, var3, Proc.new {|a, b| a < b }) @problem = Problem.new([ @var1, var2, var3 ], ConstraintList.new([ @c1, c2 ])) end def testConstructor assert_raise(ArgumentError) { Problem.new } assert_raise(ArgumentError) { Problem.new(Array.new, Array.new) } assert_nothing_raised { Problem.new(@var1, @c1) } assert_nothing_raised { Problem.new([ @var1 ], [ @c1 ]) } assert_nothing_raised { Problem.new([ @var1 ], [ @c1 ], {}) } assert_nothing_raised { Problem.new([ @var1 ], [ @c1 ], {}, true) } assert_nothing_raised { Problem.new([ @var1 ], [ @c1 ], {}, true, 0) } end end end