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.3.9 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.3.8 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.3.6 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.3.5 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.3.4 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.3.3 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.3.2 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.3.1 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.3.0 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.55 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.54 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.53 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.52 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.51 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.50 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.49 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.48 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.47 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.46 test/types/decimal_type_test.rb
sessionm-cassandra_object-2.2.45 test/types/decimal_type_test.rb