Skip to content

Commit b92ddbc

Browse files
committed
Add failing double precision roundtrip test
Add a failing test for roundtripping large double precision values. This test will fail with the default extra_float_digits. Reproduces brianc#730
1 parent b3f0687 commit b92ddbc

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
var async = require('async');
2+
var helper = require(__dirname + '/../test-helper');
3+
var exec = require('child_process').exec;
4+
5+
var floatTestVals = [
6+
'0',
7+
'1',
8+
'100',
9+
'123.456',
10+
'123456.123456',
11+
'2099999997689999',
12+
'2099999997690000',
13+
'2099999997690001'
14+
]
15+
16+
helper.pg.connect(helper.config, function(err, client, done) {
17+
assert.isNull(err);
18+
19+
function testFloatRoundTrip(val, cb) {
20+
test('float round trip val=' + val, function() {
21+
var sql = 'SELECT $1::float8 AS val'
22+
client.query(sql, [val], function(err, result){
23+
assert.isNull(err);
24+
assert.equal(result.rows[0].val, val);
25+
cb(null);
26+
});
27+
});
28+
};
29+
30+
async.eachSeries(floatTestVals, testFloatRoundTrip, function(err, results){
31+
assert.isNull(err || null);
32+
done();
33+
helper.pg.end();
34+
});
35+
});

0 commit comments

Comments
 (0)