Sha256: f39607ddf695c8f72719e2e4f5ed0041234d35325b38edb7f3db822a58e6aebb
Contents?: true
Size: 1022 Bytes
Versions: 3
Compression:
Stored size: 1022 Bytes
Contents
require File.dirname(__FILE__) + '/test_helper' class SdbFloatTest < Test::Unit::TestCase include DeadSimpleDb should "cast a string to float" do float = SdbFloat.new('10') assert_equal 10.0, float.casted end should "be identical if provided a float" do float = SdbFloat.new(10.0) assert_equal 10.0, float.casted end should "be casted if provided an integer" do float = SdbFloat.new(10) assert_equal 10.0, float.casted end should "be padded if printed as string" do float = SdbFloat.new(100.1, :digits => 6) assert_equal '0100.10', float.to_s end should "be trimmed if string is too long" do float = SdbFloat.new(100.11231312312, :digits => 6) assert_equal '0100.11', float.to_s end should "handle negative string" do float = SdbFloat.new('-100.1', :digits => 6) assert_equal '-0100.10', float.to_s end should "handle negative float" do float = SdbFloat.new('-100.5', :digits => 6) assert_equal '-0100.50', float.to_s end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
hungryblank-dead_simple_db-0.0.1 | test/sdb_float_test.rb |
hungryblank-dead_simple_db-0.0.2 | test/sdb_float_test.rb |
hungryblank-dead_simple_db-0.0.3 | test/sdb_float_test.rb |