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-2.2.44 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.43 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.42 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.41 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.40 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.39 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.38 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.37 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.36 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.35 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.34 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.33 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.32 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.31 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.30 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.29 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.28 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.27 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.26 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.24 test/types/decimal_type_test.rb