Class: Interval::TestMethods
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- Interval::TestMethods
- Includes:
- Assertions
- Defined in:
- lib/interval.rb
Overview
Tests other Interval methods.
Instance Method Summary collapse
- #test_conversion_from_range ⇒ Object
- #test_empty? ⇒ Boolean
- #test_hull ⇒ Object
- #test_include? ⇒ Boolean
- #test_sharp? ⇒ Boolean
- #test_simple? ⇒ Boolean
Methods included from Assertions
#assert_fuzzy, #assert_include, #assert_outside, #assert_sharp, #assert_solution, #assert_subset
Instance Method Details
#test_conversion_from_range ⇒ Object
1013 1014 1015 1016 1017 1018 |
# File 'lib/interval.rb', line 1013 def test_conversion_from_range assert_equal(Interval[1.2, 5.3], (1.2 .. 5.3).to_interval) assert_equal(Interval[1, 4], (1 .. 4).to_interval) assert_equal(Interval[1, 3], (1 ... 4).to_interval) assert_raise(NoMethodError){ (1 ... 3.1).to_interval } end |
#test_empty? ⇒ Boolean
984 985 986 987 988 |
# File 'lib/interval.rb', line 984 def test_empty? assert(!Interval[1,2].empty?) assert(!Interval[[1,2],[4,3]].empty?) assert(Interval[].empty?) end |
#test_hull ⇒ Object
1007 1008 1009 1010 1011 |
# File 'lib/interval.rb', line 1007 def test_hull assert_equal(Interval[1,4], Interval[[1,2],[3,4]].hull) assert_equal(Interval[1,4], Interval[1,4].hull) assert_equal(Interval[], Interval[].hull) end |
#test_include? ⇒ Boolean
971 972 973 974 975 976 977 |
# File 'lib/interval.rb', line 971 def test_include? assert_include(Interval[1,2], 1.5) assert_include(Interval[1,2], 1) assert_include(Interval[1,2], 2) assert_outside(Interval[1,2], 0) assert_outside(Interval[1,2], 4) end |
#test_sharp? ⇒ Boolean
990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 |
# File 'lib/interval.rb', line 990 def test_sharp? assert_sharp(Interval[5,5]) assert_sharp(Interval[[1],[2]]) assert_fuzzy(Interval[[1],[2,3]]) assert_fuzzy(Interval[5,6]) assert_fuzzy(Interval[1.1,1.2]) assert_fuzzy(Interval[Struct::Float[-1,0,1].to_f,Struct::Float[+1,0,1].to_f]) assert_sharp(Interval[Struct::Float[1,1022,2**52-1].to_f,1]) assert_sharp(Interval[Struct::Float[1,1029,2**52-1].to_f,128]) assert_sharp(Interval[-0.0,0.0]) assert_sharp(Interval[0.0,Struct::Float[1,0,1].to_f]) assert_sharp(Interval[6369051672525772, 6369051672525773] * 2.0 ** -52) assert_sharp(Interval[6369051672525772, 6369051672525772] * 2.0 ** -52) assert_fuzzy(Interval[6369051672525771, 6369051672525773] * 2.0 ** -52) assert_fuzzy(Interval[6369051672525771, 6369051672525785] * 2.0 ** -52) end |