diff --git a/test/comparable_types_test.rb b/test/comparable_types_test.rb index c24a75f..8d24a56 100644 --- a/test/comparable_types_test.rb +++ b/test/comparable_types_test.rb @@ -8,15 +8,15 @@ def test_long_sort 10.times { ary << Long.new } assert_equal ary.sort, ary end - + def test_long_equality long = Long.new - assert_equal long, Long.new(long) - assert_equal long, Long.new(long.to_s) - assert_equal long, Long.new(long.to_i) - assert_equal long, Long.new(long.to_guid) + assert_equal long, Long.new(long) + assert_equal long, Long.new(long.to_s) + assert_equal long, Long.new(long.to_i) + assert_equal long, Long.new(long.to_guid) end - + def test_long_error assert_raises(Cassandra::Comparable::TypeError) do Long.new("bogus") @@ -29,23 +29,33 @@ def test_uuid_sort assert_equal ary.map { |_| _.seconds }.sort, ary.sort.map { |_| _.seconds } assert_not_equal ary.sort, ary.sort_by {|_| _.to_guid } end - + def test_uuid_equality uuid = UUID.new - assert_equal uuid, UUID.new(uuid) - assert_equal uuid, UUID.new(uuid.to_s) - assert_equal uuid, UUID.new(uuid.to_i) - assert_equal uuid, UUID.new(uuid.to_guid) + assert_equal uuid, UUID.new(uuid) + assert_equal uuid, UUID.new(uuid.to_s) + assert_equal uuid, UUID.new(uuid.to_i) + assert_equal uuid, UUID.new(uuid.to_guid) end - + def test_uuid_error assert_raises(Cassandra::Comparable::TypeError) do UUID.new("bogus") end end - + def test_types_behave_well assert !(UUID.new() == false) assert !(Long.new() == false) end + + def test_casting_unknown_class + assert_raises(Cassandra::Comparable::TypeError) do + Cassandra::Long.new({}) + end + end + + def test_inspect + assert_equal '', Long.new("\000\000\000\000\000\000\000\000").inspect + end end \ No newline at end of file