Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add spec for currency columns

  • Loading branch information...
commit e962acc2a8a110fbd4471b529765101422676379 1 parent b25bd21
@infused authored
Showing with 9 additions and 1 deletion.
  1. +1 −1  lib/dbf/column/base.rb
  2. +8 −0 spec/dbf/column_spec.rb
View
2  lib/dbf/column/base.rb
@@ -28,7 +28,7 @@ def type_cast(value)
when 'N' then unpack_number(value)
when 'I' then unpack_unsigned_long(value)
when 'F' then value.to_f
- when 'Y' then unpack_unsigned_long(value)/10000.0
+ when 'Y' then unpack_unsigned_long(value) / 10000.0
when 'D' then decode_date(value)
when 'T' then decode_datetime(value)
when 'L' then boolean(value)
View
8 spec/dbf/column_spec.rb
@@ -137,6 +137,14 @@
end
end
+ context 'with type Y (currency)' do
+ let(:column) { DBF::Column::Dbase.new "ColumnName", "Y", 8, 4, "31" }
+
+ it 'casts to float' do
+ column.type_cast(" \xBF\x02\x00\x00\x00\x00\x00").should == 18.0
+ end
+ end
+
context "#schema_definition" do
context 'with type N (number)' do
it "outputs an integer column" do
Please sign in to comment.
Something went wrong with that request. Please try again.