ruby-oci8 1.0.7-x86-mswin32-60 → 2.0.1-x86-mswin32-60
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.
- data/ChangeLog +1289 -383
- data/Makefile +48 -12
- data/NEWS +5 -419
- data/README +56 -385
- data/VERSION +1 -1
- data/dist-files +27 -27
- data/lib/.document +2 -0
- data/lib/dbd/OCI8.rb +2 -17
- data/lib/oci8.rb +48 -1622
- data/lib/oci8.rb.in +48 -1622
- data/lib/oci8/.document +5 -0
- data/lib/oci8/compat.rb +108 -0
- data/lib/oci8/datetime.rb +491 -0
- data/lib/oci8/encoding-init.rb +40 -0
- data/lib/oci8/encoding.yml +537 -0
- data/lib/oci8/metadata.rb +2077 -0
- data/lib/oci8/object.rb +548 -0
- data/lib/oci8/oci8.rb +798 -0
- data/lib/oci8/oracle_version.rb +144 -0
- data/lib/oci8lib_18.so +0 -0
- data/lib/oci8lib_191.so +0 -0
- data/metaconfig +3 -3
- data/ruby-oci8.gemspec +24 -15
- data/setup.rb +4 -4
- data/test/config.rb +64 -84
- data/test/test_all.rb +14 -21
- data/test/test_array_dml.rb +333 -0
- data/test/test_bind_raw.rb +18 -25
- data/test/test_bind_time.rb +78 -91
- data/test/test_break.rb +37 -35
- data/test/test_clob.rb +33 -89
- data/test/test_connstr.rb +5 -4
- data/test/test_datetime.rb +469 -0
- data/test/test_dbi.rb +99 -60
- data/test/test_dbi_clob.rb +3 -8
- data/test/test_metadata.rb +65 -51
- data/test/test_oci8.rb +151 -55
- data/test/test_oracle_version.rb +70 -0
- data/test/test_oradate.rb +76 -83
- data/test/test_oranumber.rb +405 -71
- data/test/test_rowid.rb +6 -11
- metadata +21 -25
- data/ext/oci8/oci8lib.so +0 -0
- data/ruby-oci8.spec +0 -62
- data/support/README +0 -4
- data/support/runit/assert.rb +0 -281
- data/support/runit/cui/testrunner.rb +0 -101
- data/support/runit/error.rb +0 -4
- data/support/runit/method_mappable.rb +0 -20
- data/support/runit/robserver.rb +0 -25
- data/support/runit/setuppable.rb +0 -15
- data/support/runit/teardownable.rb +0 -16
- data/support/runit/testcase.rb +0 -113
- data/support/runit/testfailure.rb +0 -25
- data/support/runit/testresult.rb +0 -121
- data/support/runit/testsuite.rb +0 -43
- data/support/runit/version.rb +0 -3
- data/test/test_describe.rb +0 -137
data/test/test_oci8.rb
CHANGED
@@ -1,18 +1,79 @@
|
|
1
1
|
require 'oci8'
|
2
|
-
require '
|
3
|
-
require 'runit/cui/testrunner'
|
2
|
+
require 'test/unit'
|
4
3
|
require File.dirname(__FILE__) + '/config'
|
5
4
|
|
6
|
-
class TestOCI8 <
|
5
|
+
class TestOCI8 < Test::Unit::TestCase
|
7
6
|
|
8
7
|
def setup
|
9
|
-
@conn =
|
8
|
+
@conn = get_oci8_connection
|
10
9
|
end
|
11
10
|
|
12
11
|
def teardown
|
13
12
|
@conn.logoff
|
14
13
|
end
|
15
14
|
|
15
|
+
def test_rename
|
16
|
+
drop_table('test_table')
|
17
|
+
drop_table('test_rename_table')
|
18
|
+
sql = <<-EOS
|
19
|
+
CREATE TABLE test_rename_table
|
20
|
+
(C CHAR(10) NOT NULL)
|
21
|
+
EOS
|
22
|
+
@conn.exec(sql)
|
23
|
+
@conn.exec("RENAME test_rename_table TO test_table")
|
24
|
+
drop_table('test_rename_table')
|
25
|
+
end
|
26
|
+
|
27
|
+
# USE_DYNAMIC_FETCH doesn't work well...
|
28
|
+
# This test is disabled.
|
29
|
+
def _test_long_type
|
30
|
+
drop_table('test_table')
|
31
|
+
@conn.exec('CREATE TABLE test_table (id number(38), lng long)')
|
32
|
+
test_data1 = 'a' * 70000
|
33
|
+
test_data2 = 'b' * 3000
|
34
|
+
test_data3 = nil
|
35
|
+
test_data4 = 'c' * 70000
|
36
|
+
@conn.exec('insert into test_table values (:1, :2)', 1, test_data1)
|
37
|
+
@conn.exec('insert into test_table values (:1, :2)', 2, [test_data2, :long])
|
38
|
+
@conn.exec('insert into test_table values (:1, :2)', 3, [nil, :long])
|
39
|
+
@conn.exec('insert into test_table values (:1, :2)', 4, [test_data4, :long])
|
40
|
+
|
41
|
+
[8000, 65535, 65536, 80000].each do |read_len|
|
42
|
+
@conn.long_read_len = read_len
|
43
|
+
cursor = @conn.parse('SELECT lng from test_table order by id')
|
44
|
+
cursor.exec
|
45
|
+
assert_equal(test_data1, cursor.fetch[0])
|
46
|
+
assert_equal(test_data2, cursor.fetch[0])
|
47
|
+
assert_equal(test_data3, cursor.fetch[0])
|
48
|
+
assert_equal(test_data4, cursor.fetch[0])
|
49
|
+
cursor.close
|
50
|
+
end
|
51
|
+
drop_table('test_table')
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_long_type
|
55
|
+
@conn.long_read_len = 80000
|
56
|
+
drop_table('test_table')
|
57
|
+
@conn.exec('CREATE TABLE test_table (id number(38), lng long)')
|
58
|
+
test_data1 = 'a' * 70000
|
59
|
+
test_data2 = 'b' * 3000
|
60
|
+
test_data3 = nil
|
61
|
+
test_data4 = 'c' * 70000
|
62
|
+
@conn.exec('insert into test_table values (:1, :2)', 1, test_data1)
|
63
|
+
@conn.exec('insert into test_table values (:1, :2)', 2, [test_data2, :long])
|
64
|
+
@conn.exec('insert into test_table values (:1, :2)', 3, [nil, :long])
|
65
|
+
@conn.exec('insert into test_table values (:1, :2)', 4, [test_data4, :long])
|
66
|
+
|
67
|
+
cursor = @conn.parse('SELECT lng from test_table order by id')
|
68
|
+
cursor.exec
|
69
|
+
assert_equal(test_data1, cursor.fetch[0])
|
70
|
+
assert_equal(test_data2, cursor.fetch[0])
|
71
|
+
assert_equal(test_data3, cursor.fetch[0])
|
72
|
+
assert_equal(test_data4, cursor.fetch[0])
|
73
|
+
cursor.close
|
74
|
+
drop_table('test_table')
|
75
|
+
end
|
76
|
+
|
16
77
|
def test_select
|
17
78
|
drop_table('test_table')
|
18
79
|
sql = <<-EOS
|
@@ -43,7 +104,7 @@ EOS
|
|
43
104
|
cursor = @conn.parse("SELECT * FROM test_table ORDER BY c")
|
44
105
|
cursor.define(5, Time) # define 5th column as Time
|
45
106
|
cursor.define(6, Date) # define 6th column as Date
|
46
|
-
cursor.define(7, DateTime)
|
107
|
+
cursor.define(7, DateTime) # define 7th column as DateTime
|
47
108
|
cursor.define(8, Integer) # define 8th column as Integer
|
48
109
|
cursor.define(9, Bignum) # define 9th column as Bignum
|
49
110
|
cursor.exec
|
@@ -59,11 +120,13 @@ EOS
|
|
59
120
|
assert_nil(rv[5])
|
60
121
|
assert_nil(rv[6])
|
61
122
|
else
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
assert_equal(
|
66
|
-
assert_equal(
|
123
|
+
tm = Time.local(2000 + i, 8, 3, 23, 59, 59)
|
124
|
+
dt = Date.civil(2000 + i, 8, 3)
|
125
|
+
dttm = DateTime.civil(2000 + i, 8, 3, 23, 59, 59, Time.now.utc_offset.to_r/86400)
|
126
|
+
assert_equal(tm, rv[3])
|
127
|
+
assert_equal(tm, rv[4])
|
128
|
+
assert_equal(dt, rv[5])
|
129
|
+
assert_equal(dttm, rv[6])
|
67
130
|
end
|
68
131
|
assert_equal(i * 11111111111, rv[7])
|
69
132
|
assert_equal(i * 10000000000, rv[8])
|
@@ -83,17 +146,19 @@ EOS
|
|
83
146
|
assert_nil(row['D3'])
|
84
147
|
assert_nil(row['D4'])
|
85
148
|
else
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
assert_equal(
|
90
|
-
assert_equal(
|
149
|
+
tm = Time.local(2000 + i, 8, 3, 23, 59, 59)
|
150
|
+
dt = Date.civil(2000 + i, 8, 3)
|
151
|
+
dttm = DateTime.civil(2000 + i, 8, 3, 23, 59, 59, Time.now.utc_offset.to_r/86400)
|
152
|
+
assert_equal(tm, row['D1'])
|
153
|
+
assert_equal(tm, row['D2'])
|
154
|
+
assert_equal(dt, row['D3'])
|
155
|
+
assert_equal(dttm, row['D4'])
|
91
156
|
end
|
92
157
|
assert_equal(i * 11111111111, row['INT'])
|
93
158
|
assert_equal(i * 10000000000, row['BIGNUM'])
|
94
159
|
i += 1
|
95
160
|
end
|
96
|
-
assert_equal(
|
161
|
+
assert_equal(11, i)
|
97
162
|
|
98
163
|
cursor.close
|
99
164
|
drop_table('test_table')
|
@@ -127,7 +192,7 @@ EOS
|
|
127
192
|
end
|
128
193
|
cursor.close
|
129
194
|
plsql = @conn.parse("BEGIN OPEN :cursor FOR SELECT * FROM test_table ORDER BY c; END;")
|
130
|
-
plsql.bind_param(':cursor', OCI8::Cursor)
|
195
|
+
plsql.bind_param(':cursor', nil, OCI8::Cursor)
|
131
196
|
plsql.exec
|
132
197
|
cursor = plsql[':cursor']
|
133
198
|
cursor.define(5, Time) # define 5th column as Time
|
@@ -145,10 +210,12 @@ EOS
|
|
145
210
|
assert_nil(rv[4])
|
146
211
|
assert_nil(rv[5])
|
147
212
|
else
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
assert_equal(
|
213
|
+
dttm = DateTime.civil(2000 + i, 8, 3, 23, 59, 59, Time.now.utc_offset.to_r/86400)
|
214
|
+
tm = Time.local(2000 + i, 8, 3, 23, 59, 59)
|
215
|
+
dt = Date.civil(2000 + i, 8, 3)
|
216
|
+
assert_equal(tm, rv[3])
|
217
|
+
assert_equal(tm, rv[4])
|
218
|
+
assert_equal(dt, rv[5])
|
152
219
|
end
|
153
220
|
assert_equal(i, rv[6])
|
154
221
|
assert_equal(i, rv[7])
|
@@ -197,42 +264,44 @@ EOS
|
|
197
264
|
drop_table('test_table')
|
198
265
|
end
|
199
266
|
|
200
|
-
|
267
|
+
def test_binary_float
|
268
|
+
return if $oracle_version < OCI8::ORAVER_10_1
|
269
|
+
|
201
270
|
# Oracle 10g or upper
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
]
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
assert_equal(num, rv[1])
|
229
|
-
end
|
271
|
+
cursor = @conn.parse("select CAST(:1 AS BINARY_FLOAT), CAST(:2 AS BINARY_DOUBLE) from dual")
|
272
|
+
bind_val = -1.0
|
273
|
+
cursor.bind_param(1, 10.0, :binary_double)
|
274
|
+
cursor.bind_param(2, nil, :binary_double)
|
275
|
+
while bind_val < 10.0
|
276
|
+
cursor[2] = bind_val
|
277
|
+
cursor.exec
|
278
|
+
rv = cursor.fetch
|
279
|
+
assert_equal(10.0, rv[0])
|
280
|
+
assert_equal(bind_val, rv[1])
|
281
|
+
bind_val += 1.234
|
282
|
+
end
|
283
|
+
[-1.0/0.0, # -Infinite
|
284
|
+
+1.0/0.0, # +Infinite
|
285
|
+
0.0/0.0 # NaN
|
286
|
+
].each do |num|
|
287
|
+
cursor[1] = num
|
288
|
+
cursor[2] = num
|
289
|
+
cursor.exec
|
290
|
+
rv = cursor.fetch
|
291
|
+
if num.nan?
|
292
|
+
assert(rv[0].nan?)
|
293
|
+
assert(rv[1].nan?)
|
294
|
+
else
|
295
|
+
assert_equal(num, rv[0])
|
296
|
+
assert_equal(num, rv[1])
|
230
297
|
end
|
231
|
-
cursor.close
|
232
298
|
end
|
299
|
+
cursor.close
|
233
300
|
end
|
234
301
|
|
235
302
|
def test_clob_nclob_and_blob
|
303
|
+
return if OCI8::oracle_client_version < OCI8::ORAVER_8_1
|
304
|
+
|
236
305
|
drop_table('test_table')
|
237
306
|
sql = <<-EOS
|
238
307
|
CREATE TABLE test_table (id number(5), C CLOB, NC NCLOB, B BLOB)
|
@@ -259,6 +328,7 @@ EOS
|
|
259
328
|
assert_instance_of(OCI8::NCLOB, rv[2])
|
260
329
|
assert_instance_of(OCI8::BLOB, rv[3])
|
261
330
|
assert_equal(val, rv[1].read)
|
331
|
+
assert_equal(val.length, rv[2].size)
|
262
332
|
assert_equal(val, rv[2].read)
|
263
333
|
assert_equal(val, rv[3].read)
|
264
334
|
end
|
@@ -266,8 +336,34 @@ EOS
|
|
266
336
|
cursor.close
|
267
337
|
drop_table('test_table')
|
268
338
|
end
|
269
|
-
end # TestOCI8
|
270
339
|
|
271
|
-
|
272
|
-
|
273
|
-
|
340
|
+
def test_select_number
|
341
|
+
drop_table('test_table')
|
342
|
+
@conn.exec(<<EOS)
|
343
|
+
CREATE TABLE test_table (n NUMBER, n20 NUMBER(20), n14_2 NUMBER(14,2), n15_2 NUMBER(15,2), flt FLOAT)
|
344
|
+
STORAGE (
|
345
|
+
INITIAL 100k
|
346
|
+
NEXT 100k
|
347
|
+
MINEXTENTS 1
|
348
|
+
MAXEXTENTS UNLIMITED
|
349
|
+
PCTINCREASE 0)
|
350
|
+
EOS
|
351
|
+
@conn.exec(<<EOS)
|
352
|
+
INSERT INTO test_table values(12345678901234, 12345678901234567890, 123456789012.34, 1234567890123.45, 1234.5)
|
353
|
+
EOS
|
354
|
+
@conn.exec("select * from test_table") do |row|
|
355
|
+
assert_equal(row[0], 12345678901234)
|
356
|
+
assert_equal(row[1], 12345678901234567890)
|
357
|
+
assert_equal(row[2], 123456789012.34)
|
358
|
+
assert_equal(row[3], 1234567890123.45)
|
359
|
+
assert_equal(row[4], 1234.5)
|
360
|
+
assert_instance_of(OraNumber, row[0])
|
361
|
+
assert_instance_of(Bignum, row[1])
|
362
|
+
assert_instance_of(Float, row[2])
|
363
|
+
assert_instance_of(OraNumber, row[3])
|
364
|
+
assert_instance_of(Float, row[4])
|
365
|
+
end
|
366
|
+
drop_table('test_table')
|
367
|
+
end
|
368
|
+
|
369
|
+
end # TestOCI8
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'oci8'
|
2
|
+
require 'test/unit'
|
3
|
+
require File.dirname(__FILE__) + '/config'
|
4
|
+
|
5
|
+
class TestOracleVersion < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def test_init
|
8
|
+
oraver = OCI8::OracleVersion.new('8.1.6.2.3')
|
9
|
+
assert_equal(8, oraver.major)
|
10
|
+
assert_equal(1, oraver.minor)
|
11
|
+
assert_equal(6, oraver.update)
|
12
|
+
assert_equal(2, oraver.patch)
|
13
|
+
assert_equal(3, oraver.port_update)
|
14
|
+
|
15
|
+
oraver = OCI8::OracleVersion.new('8.1.6')
|
16
|
+
assert_equal(8, oraver.major)
|
17
|
+
assert_equal(1, oraver.minor)
|
18
|
+
assert_equal(6, oraver.update)
|
19
|
+
assert_equal(0, oraver.patch)
|
20
|
+
assert_equal(0, oraver.port_update)
|
21
|
+
|
22
|
+
oraver = OCI8::OracleVersion.new('10')
|
23
|
+
assert_equal(10, oraver.major)
|
24
|
+
assert_equal(0, oraver.minor)
|
25
|
+
assert_equal(0, oraver.update)
|
26
|
+
assert_equal(0, oraver.patch)
|
27
|
+
assert_equal(0, oraver.port_update)
|
28
|
+
|
29
|
+
oraver = OCI8::OracleVersion.new(0x08106203)
|
30
|
+
assert_equal(8, oraver.major)
|
31
|
+
assert_equal(1, oraver.minor)
|
32
|
+
assert_equal(6, oraver.update)
|
33
|
+
assert_equal(2, oraver.patch)
|
34
|
+
assert_equal(3, oraver.port_update)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_compare
|
38
|
+
oraver = OCI8::OracleVersion.new('8.1.6.2.3')
|
39
|
+
assert_operator(oraver, :==, OCI8::OracleVersion.new('8.1.6.2.3'))
|
40
|
+
assert_operator(oraver, :<, OCI8::OracleVersion.new('9.1.6.2.3'))
|
41
|
+
assert_operator(oraver, :<, OCI8::OracleVersion.new('8.2.6.2.3'))
|
42
|
+
assert_operator(oraver, :<, OCI8::OracleVersion.new('8.1.7.2.3'))
|
43
|
+
assert_operator(oraver, :<, OCI8::OracleVersion.new('8.1.6.3.3'))
|
44
|
+
assert_operator(oraver, :<, OCI8::OracleVersion.new('8.1.6.2.4'))
|
45
|
+
assert_operator(oraver, :>, OCI8::OracleVersion.new('7.1.6.2.3'))
|
46
|
+
assert_operator(oraver, :>, OCI8::OracleVersion.new('8.0.6.2.3'))
|
47
|
+
assert_operator(oraver, :>, OCI8::OracleVersion.new('8.1.5.2.3'))
|
48
|
+
assert_operator(oraver, :>, OCI8::OracleVersion.new('8.1.6.1.3'))
|
49
|
+
assert_operator(oraver, :>, OCI8::OracleVersion.new('8.1.6.2.2'))
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_to_s
|
53
|
+
oraver = OCI8::OracleVersion.new('8.1.6.2.3')
|
54
|
+
assert_equal('8.1.6.2.3', oraver.to_s)
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_to_i
|
58
|
+
oraver = OCI8::OracleVersion.new('8.1.6.2.3')
|
59
|
+
assert_equal(0x08106203, oraver.to_i)
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_eql
|
63
|
+
oraver = OCI8::OracleVersion.new('8.1.6.2.3')
|
64
|
+
assert_equal(true, oraver.eql?(OCI8::OracleVersion.new('8.1.6.2.3')))
|
65
|
+
assert_equal(false, oraver.eql?(OCI8::OracleVersion.new('8.2.6.2.3')))
|
66
|
+
assert_equal(false, oraver.eql?('8.1.6.2.3'))
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
Test::Unit::AutoRunner.run() if $0 == __FILE__
|
data/test/test_oradate.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
# Low-level API
|
2
2
|
require 'oci8'
|
3
|
-
require '
|
4
|
-
require 'runit/cui/testrunner'
|
3
|
+
require 'test/unit'
|
5
4
|
require File.dirname(__FILE__) + '/config'
|
6
5
|
|
7
|
-
class TestOraDate <
|
6
|
+
class TestOraDate < Test::Unit::TestCase
|
8
7
|
|
9
8
|
YEAR_CHECK_TARGET = [-4712, -1, 1, 1192, 1868, 2002, 9999]
|
10
9
|
MONTH_CHECK_TARGET = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
|
@@ -14,7 +13,7 @@ class TestOraDate < RUNIT::TestCase
|
|
14
13
|
SECOND_CHECK_TARGET = [0, 15, 30, 45, 59]
|
15
14
|
|
16
15
|
def setup
|
17
|
-
@
|
16
|
+
@conn = get_oci8_connection
|
18
17
|
end
|
19
18
|
|
20
19
|
def check_oradate(target, year, month, day, hour, minute, second)
|
@@ -31,170 +30,170 @@ class TestOraDate < RUNIT::TestCase
|
|
31
30
|
end
|
32
31
|
|
33
32
|
def test_set_year
|
34
|
-
@
|
35
|
-
|
36
|
-
|
33
|
+
cursor = @conn.parse("BEGIN :year := TO_NUMBER(TO_CHAR(:date, 'SYYYY'), '9999'); END;")
|
34
|
+
cursor.bind_param(:date, OraDate)
|
35
|
+
cursor.bind_param(:year, Fixnum)
|
37
36
|
date = OraDate.new()
|
38
37
|
YEAR_CHECK_TARGET.each do |i|
|
39
38
|
# set year
|
40
39
|
date.year = i
|
41
40
|
# check result via oracle.
|
42
|
-
|
43
|
-
|
44
|
-
assert_equal(i,
|
41
|
+
cursor[:date] = date
|
42
|
+
cursor.exec
|
43
|
+
assert_equal(i, cursor[:year])
|
45
44
|
end
|
46
45
|
end
|
47
46
|
|
48
47
|
def test_get_year
|
49
|
-
@
|
50
|
-
|
51
|
-
|
48
|
+
cursor = @conn.parse("BEGIN :date := TO_DATE(TO_CHAR(:year, '0999'), 'SYYYY'); END;")
|
49
|
+
cursor.bind_param(:year, Fixnum)
|
50
|
+
cursor.bind_param(:date, OraDate)
|
52
51
|
YEAR_CHECK_TARGET.each do |i|
|
53
52
|
# set date via oracle.
|
54
|
-
|
55
|
-
|
53
|
+
cursor[:year] = i
|
54
|
+
cursor.exec
|
56
55
|
# check OraDate#year
|
57
|
-
assert_equal(i,
|
56
|
+
assert_equal(i, cursor[:date].year)
|
58
57
|
end
|
59
58
|
end
|
60
59
|
|
61
60
|
def test_set_month
|
62
|
-
@
|
63
|
-
|
64
|
-
|
61
|
+
cursor = @conn.parse("BEGIN :month := TO_NUMBER(TO_CHAR(:date, 'MM'), '99'); END;")
|
62
|
+
cursor.bind_param(:date, OraDate)
|
63
|
+
cursor.bind_param(:month, Fixnum)
|
65
64
|
date = OraDate.new()
|
66
65
|
MONTH_CHECK_TARGET.each do |i|
|
67
66
|
# set month
|
68
67
|
date.month = i
|
69
68
|
# check result via oracle.
|
70
|
-
|
71
|
-
|
72
|
-
assert_equal(i,
|
69
|
+
cursor[:date] = date
|
70
|
+
cursor.exec
|
71
|
+
assert_equal(i, cursor[:month])
|
73
72
|
end
|
74
73
|
end
|
75
74
|
|
76
75
|
def test_get_month
|
77
|
-
@
|
78
|
-
|
79
|
-
|
76
|
+
cursor = @conn.parse("BEGIN :date := TO_DATE(TO_CHAR(:month, '99'), 'MM'); END;")
|
77
|
+
cursor.bind_param(:month, Fixnum)
|
78
|
+
cursor.bind_param(:date, OraDate)
|
80
79
|
MONTH_CHECK_TARGET.each do |i|
|
81
80
|
# set date via oracle.
|
82
|
-
|
83
|
-
|
81
|
+
cursor[:month] = i
|
82
|
+
cursor.exec
|
84
83
|
# check OraDate#month
|
85
|
-
assert_equal(i,
|
84
|
+
assert_equal(i, cursor[:date].month)
|
86
85
|
end
|
87
86
|
end
|
88
87
|
|
89
88
|
def test_set_day
|
90
|
-
@
|
91
|
-
|
92
|
-
|
89
|
+
cursor = @conn.parse("BEGIN :day := TO_NUMBER(TO_CHAR(:date, 'DD'), '99'); END;")
|
90
|
+
cursor.bind_param(:date, OraDate)
|
91
|
+
cursor.bind_param(:day, Fixnum)
|
93
92
|
date = OraDate.new()
|
94
93
|
DAY_CHECK_TARGET.each do |i|
|
95
94
|
# set day
|
96
95
|
date.day = i
|
97
96
|
# check result via oracle.
|
98
|
-
|
99
|
-
|
100
|
-
assert_equal(i,
|
97
|
+
cursor[:date] = date
|
98
|
+
cursor.exec
|
99
|
+
assert_equal(i, cursor[:day])
|
101
100
|
end
|
102
101
|
end
|
103
102
|
|
104
103
|
def test_get_day
|
105
|
-
@
|
106
|
-
|
107
|
-
|
104
|
+
cursor = @conn.parse("BEGIN :date := TO_DATE('200101' || TO_CHAR(:day, 'FM00'), 'YYYYMMDD'); END;")
|
105
|
+
cursor.bind_param(:day, Fixnum)
|
106
|
+
cursor.bind_param(:date, OraDate)
|
108
107
|
DAY_CHECK_TARGET.each do |i|
|
109
108
|
# set date via oracle.
|
110
|
-
|
111
|
-
|
109
|
+
cursor[:day] = i
|
110
|
+
cursor.exec
|
112
111
|
# check OraDate#day
|
113
|
-
assert_equal(i,
|
112
|
+
assert_equal(i, cursor[:date].day)
|
114
113
|
end
|
115
114
|
end
|
116
115
|
|
117
116
|
def test_set_hour
|
118
|
-
@
|
119
|
-
|
120
|
-
|
117
|
+
cursor = @conn.parse("BEGIN :hour := TO_NUMBER(TO_CHAR(:date, 'HH24'), '99'); END;")
|
118
|
+
cursor.bind_param(:date, OraDate)
|
119
|
+
cursor.bind_param(:hour, Fixnum)
|
121
120
|
date = OraDate.new()
|
122
121
|
HOUR_CHECK_TARGET.each do |i|
|
123
122
|
# set hour
|
124
123
|
date.hour = i
|
125
124
|
# check result via oracle.
|
126
|
-
|
127
|
-
|
128
|
-
assert_equal(i,
|
125
|
+
cursor[:date] = date
|
126
|
+
cursor.exec
|
127
|
+
assert_equal(i, cursor[:hour])
|
129
128
|
end
|
130
129
|
end
|
131
130
|
|
132
131
|
def test_get_hour
|
133
|
-
@
|
134
|
-
|
135
|
-
|
132
|
+
cursor = @conn.parse("BEGIN :date := TO_DATE(TO_CHAR(:hour, '99'), 'HH24'); END;")
|
133
|
+
cursor.bind_param(:hour, Fixnum)
|
134
|
+
cursor.bind_param(:date, OraDate)
|
136
135
|
HOUR_CHECK_TARGET.each do |i|
|
137
136
|
# set date via oracle.
|
138
|
-
|
139
|
-
|
137
|
+
cursor[:hour] = i
|
138
|
+
cursor.exec
|
140
139
|
# check OraDate#hour
|
141
|
-
assert_equal(i,
|
140
|
+
assert_equal(i, cursor[:date].hour)
|
142
141
|
end
|
143
142
|
end
|
144
143
|
|
145
144
|
def test_set_minute
|
146
|
-
@
|
147
|
-
|
148
|
-
|
145
|
+
cursor = @conn.parse("BEGIN :minute := TO_NUMBER(TO_CHAR(:date, 'MI'), '99'); END;")
|
146
|
+
cursor.bind_param(:date, OraDate)
|
147
|
+
cursor.bind_param(:minute, Fixnum)
|
149
148
|
date = OraDate.new()
|
150
149
|
MINUTE_CHECK_TARGET.each do |i|
|
151
150
|
# set minute
|
152
151
|
date.minute = i
|
153
152
|
# check result via oracle.
|
154
|
-
|
155
|
-
|
156
|
-
assert_equal(i,
|
153
|
+
cursor[:date] = date
|
154
|
+
cursor.exec
|
155
|
+
assert_equal(i, cursor[:minute])
|
157
156
|
end
|
158
157
|
end
|
159
158
|
|
160
159
|
def test_get_minute
|
161
|
-
@
|
162
|
-
|
163
|
-
|
160
|
+
cursor = @conn.parse("BEGIN :date := TO_DATE(TO_CHAR(:minute, '99'), 'MI'); END;")
|
161
|
+
cursor.bind_param(:minute, Fixnum)
|
162
|
+
cursor.bind_param(:date, OraDate)
|
164
163
|
MINUTE_CHECK_TARGET.each do |i|
|
165
164
|
# set date via oracle.
|
166
|
-
|
167
|
-
|
165
|
+
cursor[:minute] = i
|
166
|
+
cursor.exec
|
168
167
|
# check OraDate#minute
|
169
|
-
assert_equal(i,
|
168
|
+
assert_equal(i, cursor[:date].minute)
|
170
169
|
end
|
171
170
|
end
|
172
171
|
|
173
172
|
def test_set_second
|
174
|
-
@
|
175
|
-
|
176
|
-
|
173
|
+
cursor = @conn.parse("BEGIN :second := TO_NUMBER(TO_CHAR(:date, 'SS'), '99'); END;")
|
174
|
+
cursor.bind_param(:date, OraDate)
|
175
|
+
cursor.bind_param(:second, Fixnum)
|
177
176
|
date = OraDate.new()
|
178
177
|
SECOND_CHECK_TARGET.each do |i|
|
179
178
|
# set second
|
180
179
|
date.second = i
|
181
180
|
# check result via oracle.
|
182
|
-
|
183
|
-
|
184
|
-
assert_equal(i,
|
181
|
+
cursor[:date] = date
|
182
|
+
cursor.exec
|
183
|
+
assert_equal(i, cursor[:second])
|
185
184
|
end
|
186
185
|
end
|
187
186
|
|
188
187
|
def test_get_second
|
189
|
-
@
|
190
|
-
|
191
|
-
|
188
|
+
cursor = @conn.parse("BEGIN :date := TO_DATE(TO_CHAR(:second, '99'), 'SS'); END;")
|
189
|
+
cursor.bind_param(:second, Fixnum)
|
190
|
+
cursor.bind_param(:date, OraDate)
|
192
191
|
SECOND_CHECK_TARGET.each do |i|
|
193
192
|
# set date via oracle.
|
194
|
-
|
195
|
-
|
193
|
+
cursor[:second] = i
|
194
|
+
cursor.exec
|
196
195
|
# check OraDate#second
|
197
|
-
assert_equal(i,
|
196
|
+
assert_equal(i, cursor[:date].second)
|
198
197
|
end
|
199
198
|
end
|
200
199
|
|
@@ -252,12 +251,6 @@ class TestOraDate < RUNIT::TestCase
|
|
252
251
|
end
|
253
252
|
|
254
253
|
def teardown
|
255
|
-
@
|
256
|
-
@svc.logoff()
|
257
|
-
@env.free()
|
254
|
+
@conn.logoff
|
258
255
|
end
|
259
256
|
end
|
260
|
-
|
261
|
-
if $0 == __FILE__
|
262
|
-
RUNIT::CUI::TestRunner.run(TestOraDate.suite())
|
263
|
-
end
|