more tests

This commit is contained in:
Ward Wouts 2005-03-09 18:15:30 +00:00
parent 004d012d1b
commit 33c7202530

View file

@ -81,6 +81,36 @@ class TestSetIntspan < Test::Unit::TestCase
assert_equal("4-5,7", set.to_s)
set.insert(6)
assert_equal("4-7", set.to_s)
set.set_neg_inf(true)
set.insert(16)
assert_equal("4-7,16", set.to_s)
set.insert(10)
assert_equal("4-7,10,16", set.to_s)
set.insert(3)
assert_equal("3-7,10,16", set.to_s)
set.insert(1)
assert_equal("1,3-7,10,16", set.to_s)
set.insert(17)
assert_equal("1,3-7,10,16-17", set.to_s)
end
def test_finite
assert_equal(true, Set::IntSpan.new("1-3,5").finite?)
assert_equal(false, Set::IntSpan.new("(-1,3,5").finite?)
assert_equal(false, Set::IntSpan.new("1-3,5-)").finite?)
assert_equal(false, Set::IntSpan.new("(-1,3,5-)").finite?)
assert_equal(false, Set::IntSpan.new("1-3,5").infinite?)
assert_equal(true, Set::IntSpan.new("(-1,3,5").infinite?)
assert_equal(true, Set::IntSpan.new("1-3,5-)").infinite?)
assert_equal(true, Set::IntSpan.new("(-1,3,5-)").infinite?)
end
def test_remove
set = Set::IntSpan.new("1-3,5")
set.remove!(3)
assert_equal("1-2,5", set.to_s)
assert_equal("1-2,5", Set::IntSpan.new("1-3,5").remove!(3).to_s)
assert_equal("(-1,5", Set::IntSpan.new("(-1,3,5").remove!(3).to_s)
assert_equal("1-2,5-)", Set::IntSpan.new("1-3,5-)").remove!(3).to_s)
assert_equal("(-1,5-)", Set::IntSpan.new("(-1,3,5-)").remove!(3).to_s)
end
end