ruby-oci8 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,8 @@
1
1
  require 'oci8'
2
2
  require 'test/unit'
3
3
  require File.dirname(__FILE__) + '/config'
4
+ require 'bigdecimal'
5
+ require 'rational'
4
6
 
5
7
  class TestOCI8 < Test::Unit::TestCase
6
8
 
@@ -366,4 +368,39 @@ EOS
366
368
  drop_table('test_table')
367
369
  end
368
370
 
371
+ def test_bind_number_with_implicit_conversions
372
+ src = [1, 1.2, BigDecimal("1.2"), Rational(12, 10)]
373
+ int = [1, 1, 1, 1]
374
+ flt = [1, 1.2, 1.2, 1.2]
375
+
376
+ cursor = @conn.parse("begin :1 := :2; end;")
377
+
378
+ # Float
379
+ cursor.bind_param(1, nil, Float)
380
+ cursor.bind_param(2, nil, Float)
381
+ src.each_with_index do |s, idx|
382
+ cursor[2] = s
383
+ cursor.exec
384
+ assert_equal(cursor[1], flt[idx])
385
+ end
386
+
387
+ # Fixnum
388
+ cursor.bind_param(1, nil, Fixnum)
389
+ cursor.bind_param(2, nil, Fixnum)
390
+ src.each_with_index do |s, idx|
391
+ cursor[2] = s
392
+ cursor.exec
393
+ assert_equal(cursor[1], int[idx])
394
+ end
395
+
396
+ # Integer
397
+ cursor.bind_param(1, nil, Integer)
398
+ cursor.bind_param(2, nil, Integer)
399
+ src.each_with_index do |s, idx|
400
+ cursor[2] = s
401
+ cursor.exec
402
+ assert_equal(cursor[1], int[idx])
403
+ end
404
+ end
405
+
369
406
  end # TestOCI8
@@ -3,6 +3,8 @@ require 'oci8'
3
3
  require 'test/unit'
4
4
  require File.dirname(__FILE__) + '/config'
5
5
  require 'yaml'
6
+ require 'bigdecimal'
7
+ require 'rational'
6
8
 
7
9
  class TestOraNumber < Test::Unit::TestCase
8
10
 
@@ -480,4 +482,26 @@ class TestOraNumber < Test::Unit::TestCase
480
482
  assert_equal(expected_val, actual_val, x)
481
483
  end
482
484
  end
485
+
486
+ def test_new_from_bigdecimal
487
+ ["+Infinity", "-Infinity", "NaN"].each do |n|
488
+ assert_raise TypeError do
489
+ OraNumber.new(BigDecimal.new(n))
490
+ end
491
+ end
492
+
493
+ LARGE_RANGE_VALUES.each do |val|
494
+ assert_equal(val, OraNumber.new(BigDecimal.new(val)).to_s)
495
+ end
496
+ end
497
+
498
+ def test_new_from_rational
499
+ [
500
+ [Rational(1, 2), "0.5"],
501
+ [Rational(3, 5), "0.6"],
502
+ [Rational(10, 3), "3.3333333333333333333333333333333333333"],
503
+ ].each do |ary|
504
+ assert_equal(ary[1], OraNumber.new(ary[0]).to_s)
505
+ end
506
+ end
483
507
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-oci8
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - KUBO Takehiro
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-18 00:00:00 +09:00
12
+ date: 2009-05-17 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -67,6 +67,7 @@ files:
67
67
  - lib/oci8.rb.in
68
68
  - lib/dbd/OCI8.rb
69
69
  - lib/oci8/.document
70
+ - lib/oci8/bindtype.rb
70
71
  - lib/oci8/compat.rb
71
72
  - lib/oci8/datetime.rb
72
73
  - lib/oci8/encoding-init.rb
@@ -78,12 +79,14 @@ files:
78
79
  - test/README
79
80
  - test/config.rb
80
81
  - test/test_all.rb
82
+ - test/test_appinfo.rb
81
83
  - test/test_array_dml.rb
82
84
  - test/test_bind_raw.rb
83
85
  - test/test_bind_time.rb
84
86
  - test/test_break.rb
85
87
  - test/test_clob.rb
86
88
  - test/test_connstr.rb
89
+ - test/test_encoding.rb
87
90
  - test/test_datetime.rb
88
91
  - test/test_dbi.rb
89
92
  - test/test_dbi_clob.rb
@@ -116,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
119
  requirements: []
117
120
 
118
121
  rubyforge_project: ruby-oci8
119
- rubygems_version: 1.2.0
122
+ rubygems_version: 1.3.1
120
123
  signing_key:
121
124
  specification_version: 2
122
125
  summary: Ruby interface for Oracle using OCI8 API