require 'test/unit' $LOAD_PATH << 'lib' require 'dm/utils' include DataMapper::Utils::ClassMethods class DmUtilsTestCase < Test::Unit::TestCase def test_merge_conditions assert_equal ["(foo = ?) AND (bar = ? OR bar = ?)", 1, 2, 3], merge_conditions(["foo = ?", 1], ["bar = ? OR bar = ?", 2, 3]) assert_equal ["(foo = ?) AND (bar IN (?))", 1, [2, 3]], merge_conditions(["foo = ?", 1], ["bar IN (?)", [2, 3]]) assert_equal ["(foo = ?)", 1], merge_conditions(["foo = ?", 1], nil) assert_equal ["(foo = ?)", 1], merge_conditions(nil, ["foo = ?", 1]) assert_equal [""], merge_conditions(nil, nil) assert_equal ["(foo IS NULL)"], merge_conditions(["foo IS NULL"], nil) assert_equal ["(foo IS NOT NULL)"], merge_conditions(nil, ["foo IS NOT NULL"]) end end