Sha256: 1360054f2a562d2f3263490b67f67fddea81a6b3c6d11801338543806a62a286

Contents?: true

Size: 936 Bytes

Versions: 107

Compression:

Stored size: 936 Bytes

Contents

require File.join(File.dirname(__FILE__), '..', 'test_helper')

class CassandraObject::Types::DecimalTypeTest < CassandraObject::TestCase
  test 'encode' do
    assert_equal nil, CassandraObject::Types::DecimalType.encode(nil)
    assert_equal '3', CassandraObject::Types::DecimalType.encode(3)
    assert_equal '3.14', CassandraObject::Types::DecimalType.encode(3.14)
    assert_equal '3.14', CassandraObject::Types::DecimalType.encode(BigDecimal.new('3.14'))
  end

  test 'decode' do
    assert_equal nil, CassandraObject::Types::DecimalType.decode(nil)
    assert_equal BigDecimal.new('0.001'), CassandraObject::Types::DecimalType.decode(0.001)
    assert_equal BigDecimal.new('0.001'), CassandraObject::Types::DecimalType.decode('.001')
    assert_equal [9, 18], CassandraObject::Types::DecimalType.decode('.001').precs
    assert_equal [9, 27], CassandraObject::Types::DecimalType.decode('.001', :precision => 14).precs
  end
end

Version data entries

107 entries across 107 versions & 1 rubygems

Version Path
sessionm-cassandra_object-4.0.32 test/types/decimal_type_test.rb
sessionm-cassandra_object-4.0.31 test/types/decimal_type_test.rb
sessionm-cassandra_object-4.0.30 test/types/decimal_type_test.rb
sessionm-cassandra_object-4.0.29 test/types/decimal_type_test.rb
sessionm-cassandra_object-4.0.28 test/types/decimal_type_test.rb
sessionm-cassandra_object-4.0.27 test/types/decimal_type_test.rb
sessionm-cassandra_object-4.0.26 test/types/decimal_type_test.rb
sessionm-cassandra_object-4.0.25 test/types/decimal_type_test.rb
sessionm-cassandra_object-4.0.24 test/types/decimal_type_test.rb
sessionm-cassandra_object-4.0.23 test/types/decimal_type_test.rb
sessionm-cassandra_object-4.0.22 test/types/decimal_type_test.rb
sessionm-cassandra_object-4.0.21 test/types/decimal_type_test.rb
sessionm-cassandra_object-4.0.20 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.7.5 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.7.4 test/types/decimal_type_test.rb
sessionm-cassandra_object-4.0.18 test/types/decimal_type_test.rb
sessionm-cassandra_object-4.0.17 test/types/decimal_type_test.rb
sessionm-cassandra_object-4.0.16 test/types/decimal_type_test.rb
sessionm-cassandra_object-4.0.15 test/types/decimal_type_test.rb
sessionm-cassandra_object-4.0.14 test/types/decimal_type_test.rb