Sha256: 7bb2c95b28646fa43b45546b91f38a813113817ae1a0ea994acd52b87d3b22dd
Contents?: true
Size: 1.33 KB
Versions: 3
Compression:
Stored size: 1.33 KB
Contents
# Test for facets/comparable/cmp.rb require 'facets/comparable/cmp.rb' require 'test/unit' class TestComparable < Test::Unit::TestCase def test_cmp assert_equal( -1, 3.cmp(4) ) assert_equal( 0, 3.cmp(3) ) assert_equal( 1, 3.cmp(2) ) end end class TestStringCompare < Test::Unit::TestCase def test_cmp assert_equal( 0, "abc".cmp("abc") ) assert_equal( -1, "abc".cmp("abcd") ) assert_equal( 1, "abcd".cmp("abc") ) assert_equal( -1, "abc".cmp("bcd") ) assert_equal( 1, "bcd".cmp("abc") ) end def test_succ assert_equal( "b", "a".succ ) assert_equal( "b", "a".succ(1) ) assert_equal( "c", "a".succ(2) ) assert_equal( "d", "a".succ(3) ) end end class TestNumericCompare < Test::Unit::TestCase def test_distance assert_equal( 4, 10.distance(6) ) assert_equal( 2, 10.distance(8) ) assert_equal( -2, 7.distance(9) ) end def test_pred assert_equal( 3, 4.pred ) assert_equal( -3, -2.pred ) assert_equal( 2, 4.pred(2) ) assert_equal( -4, -2.pred(2) ) assert_equal( 6, 4.pred(-2) ) assert_equal( 0, -2.pred(-2) ) end def test_succ assert_equal( 5, 4.succ ) assert_equal( -1, -2.succ ) assert_equal( 6, 4.succ(2) ) assert_equal( 0, -2.succ(2) ) assert_equal( 2, 4.succ(-2) ) assert_equal( -4, -2.succ(-2) ) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
facets-2.2.0 | test/unit/comparable/test_cmp.rb |
facets-2.2.1 | test/unit/comparable/test_cmp.rb |
facets-2.3.0 | test/core/comparable/test_cmp.rb |