Skip to content

Commit 8583496

Browse files
committed
Add tests of DB_TYPE_BINARY_FLOAT/DOUBLE
1 parent 955cdcf commit 8583496

File tree

5 files changed

+327
-16
lines changed

5 files changed

+327
-16
lines changed

test/dbType01.js

Lines changed: 94 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,23 @@
1919
* 226. dbType01.js
2020
*
2121
* DESCRIPTION
22-
* Test binding data of types DB_TYPE_CHAR, DB_TYPE_NCHAR,
23-
* DB_TYPE_NVARCHAR, DB_TYPE_DATE and DB_TYPE_TIMESTAMP_LTZ.
22+
* Test binding data of types DB_TYPE_*.
2423
*
2524
*****************************************************************************/
2625
'use strict';
2726

2827
const oracledb = require('oracledb');
2928
const should = require('should');
3029
const dbconfig = require('./dbconfig.js');
30+
const testsUtil = require('./testsUtil.js');
3131

3232
describe('226. dbType01.js', function() {
3333

3434
let conn;
35+
const default_stmtCacheSize = oracledb.stmtCacheSize;
3536

3637
before(async () => {
38+
oracledb.stmtCacheSize = 0;
3739
try {
3840
conn = await oracledb.getConnection(dbconfig);
3941
} catch (err) {
@@ -47,17 +49,24 @@ describe('226. dbType01.js', function() {
4749
} catch (err) {
4850
should.not.exist(err);
4951
}
52+
oracledb.stmtCacheSize = default_stmtCacheSize;
53+
});
54+
55+
afterEach(async () => {
56+
await testsUtil.sleep(100);
5057
});
5158

5259
const strInVal = "Node-oracledb";
5360
const dateInVal = new Date();
54-
const SQL = `SELECT DUMP(:1) FROM dual`;
61+
const numInVal = 12;
62+
const SQL = `SELECT :1, DUMP(:1) FROM dual`;
5563

5664
it('226.1 DB_TYPE_VARCHAR', async () => {
5765
try {
5866
const result = await conn.execute(SQL,
5967
[{ val: strInVal, type: oracledb.DB_TYPE_VARCHAR }]);
60-
(result.rows[0][0]).should.startWith('Typ=1 Len=13');
68+
should.strictEqual(strInVal, result.rows[0][0]);
69+
(result.rows[0][1]).should.startWith('Typ=1 Len=13');
6170
} catch (err) {
6271
should.not.exist(err);
6372
}
@@ -67,7 +76,8 @@ describe('226. dbType01.js', function() {
6776
try {
6877
const result = await conn.execute(SQL,
6978
[{ val: strInVal, type: oracledb.DB_TYPE_CHAR }]);
70-
(result.rows[0][0]).should.startWith('Typ=96 Len=13');
79+
should.strictEqual(strInVal, result.rows[0][0]);
80+
(result.rows[0][1]).should.startWith('Typ=96 Len=13');
7181
} catch (err) {
7282
should.not.exist(err);
7383
}
@@ -77,7 +87,8 @@ describe('226. dbType01.js', function() {
7787
try {
7888
const result = await conn.execute(SQL,
7989
[{ val: strInVal, type: oracledb.DB_TYPE_NVARCHAR }]);
80-
(result.rows[0][0]).should.startWith('Typ=1 Len=26');
90+
should.strictEqual(strInVal, result.rows[0][0]);
91+
(result.rows[0][1]).should.startWith('Typ=1 Len=26');
8192
} catch (err) {
8293
should.not.exist(err);
8394
}
@@ -87,7 +98,8 @@ describe('226. dbType01.js', function() {
8798
try {
8899
const result = await conn.execute(SQL,
89100
[{ val: strInVal, type: oracledb.DB_TYPE_NCHAR }]);
90-
(result.rows[0][0]).should.startWith('Typ=96 Len=26');
101+
should.strictEqual(strInVal, result.rows[0][0]);
102+
(result.rows[0][1]).should.startWith('Typ=96 Len=26');
91103
} catch (err) {
92104
should.not.exist(err);
93105
}
@@ -97,7 +109,7 @@ describe('226. dbType01.js', function() {
97109
try {
98110
const result = await conn.execute(SQL,
99111
[{ val: dateInVal, type: oracledb.DB_TYPE_DATE }]);
100-
(result.rows[0][0]).should.startWith('Typ=12 Len=7');
112+
(result.rows[0][1]).should.startWith('Typ=12 Len=7');
101113
} catch (err) {
102114
should.not.exist(err);
103115
}
@@ -107,10 +119,82 @@ describe('226. dbType01.js', function() {
107119
try {
108120
const result = await conn.execute(SQL,
109121
[{ val: dateInVal, type: oracledb.DB_TYPE_TIMESTAMP_LTZ }]);
110-
(result.rows[0][0]).should.startWith('Typ=231 Len=11');
122+
(result.rows[0][1]).should.startWith('Typ=231 Len=11');
111123
} catch (err) {
112124
should.not.exist(err);
113125
}
114126
}); // 226.6
115127

116-
});
128+
it('226.7 DB_TYPE_TIMESTAMP', async () => {
129+
try {
130+
const result = await conn.execute(SQL,
131+
[{ val: dateInVal, type: oracledb.DB_TYPE_TIMESTAMP }]);
132+
(result.rows[0][1]).should.startWith('Typ=180 Len=11');
133+
} catch (err) {
134+
should.not.exist(err);
135+
}
136+
});
137+
138+
it('226.8 DB_TYPE_TIMESTAMP_TZ', async () => {
139+
try {
140+
const result = await conn.execute(SQL,
141+
[{ val: dateInVal, type: oracledb.DB_TYPE_TIMESTAMP_TZ }]);
142+
(result.rows[0][1]).should.startWith('Typ=181 Len=13');
143+
} catch (err) {
144+
should.not.exist(err);
145+
}
146+
});
147+
148+
it('226.9 DB_TYPE_NUMBER', async () => {
149+
try {
150+
const sql = `SELECT DUMP(:1) FROM dual`;
151+
const result = await conn.execute(sql,
152+
[{ val: numInVal, type: oracledb.DB_TYPE_NUMBER }]);
153+
(result.rows[0][0]).should.startWith('Typ=2 Len=2');
154+
} catch (err) {
155+
should.not.exist(err);
156+
}
157+
});
158+
159+
it('226.10 DB_TYPE_BINARY_FLOAT', async () => {
160+
try {
161+
const result = await conn.execute(SQL,
162+
[{ val: numInVal, type: oracledb.DB_TYPE_BINARY_FLOAT }]);
163+
(result.rows[0][1]).should.startWith('Typ=100 Len=4');
164+
} catch (err) {
165+
should.not.exist(err);
166+
}
167+
});
168+
169+
it('226.11 DB_TYPE_BINARY_DOUBLE', async () => {
170+
try {
171+
const result = await conn.execute(SQL,
172+
[{ val: numInVal, type: oracledb.DB_TYPE_BINARY_DOUBLE }]);
173+
(result.rows[0][1]).should.startWith('Typ=101 Len=8');
174+
} catch (err) {
175+
should.not.exist(err);
176+
}
177+
});
178+
179+
it('226.12 Infinity, DB_TYPE_BINARY_FLOAT', async () => {
180+
try {
181+
const num = 1 / 0;
182+
const result = await conn.execute(SQL,
183+
[{ val: num, type: oracledb.DB_TYPE_BINARY_FLOAT }]);
184+
(result.rows[0][1]).should.startWith('Typ=100 Len=4');
185+
} catch (err) {
186+
should.not.exist(err);
187+
}
188+
});
189+
190+
it('226.13 Infinity, DB_TYPE_BINARY_DOUBLE', async () => {
191+
try {
192+
const num = 1 / 0;
193+
const result = await conn.execute(SQL,
194+
[{ val: num, type: oracledb.DB_TYPE_BINARY_DOUBLE }]);
195+
(result.rows[0][1]).should.startWith('Typ=101 Len=8');
196+
} catch (err) {
197+
should.not.exist(err);
198+
}
199+
});
200+
});

test/dbType02.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@
1616
* limitations under the License.
1717
*
1818
* NAME
19-
* 227. dbType01.js
19+
* 227. dbType02.js
2020
*
2121
* DESCRIPTION
22-
* Roundtrip tests of binding data of typesDB_TYPE_CHAR, DB_TYPE_NCHAR,
23-
* DB_TYPE_NVARCHAR, DB_TYPE_DATE and DB_TYPE_TIMESTAMP_LTZ.
22+
* Roundtrip tests of binding data of types DB_TYPE_*.
2423
*
2524
*****************************************************************************/
2625
'use strict';
@@ -178,4 +177,4 @@ describe('227. dbType02.js', () => {
178177
await VerifyDate(tableName, type, dbType);
179178

180179
}); // 227.6
181-
});
180+
});

0 commit comments

Comments
 (0)