diff options
author | David Hatch <david.hatch@mongodb.com> | 2015-07-15 11:32:37 -0400 |
---|---|---|
committer | Raymond Jacobson <raymond.jacobson@10gen.com> | 2015-08-13 11:35:00 -0400 |
commit | 83f5d68e98d012db0846425ec66a72e328c79a52 (patch) | |
tree | c720ffc101c9fd3c28440b72691637d0939b8c4a /jstests/decimal/decimal_constructors.js | |
parent | 8fc4cbc675b90f96759b844ddfc4c52868a144f2 (diff) | |
download | mongo-83f5d68e98d012db0846425ec66a72e328c79a52.tar.gz |
SERVER-19629 Add Decimal128 roundtrip and CRUD jstests
Diffstat (limited to 'jstests/decimal/decimal_constructors.js')
-rw-r--r-- | jstests/decimal/decimal_constructors.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/jstests/decimal/decimal_constructors.js b/jstests/decimal/decimal_constructors.js new file mode 100644 index 00000000000..b07fc38ca81 --- /dev/null +++ b/jstests/decimal/decimal_constructors.js @@ -0,0 +1,25 @@ +// Tests constructing NumberDecimal with various types + +(function() { + "use strict"; + var col = db.decimal_constructors; + col.drop(); + + // Insert some sample data. + + assert.writeOK(col.insert([ + { "decimal" : NumberDecimal("1") }, + { "decimal" : NumberDecimal(1) }, + { "decimal" : NumberDecimal(NumberLong("1")) }, + { "decimal" : NumberDecimal(NumberInt("1")) }, + ]), "Initial insertion of decimals failed"); + + // Find values with various types and NumberDecimal constructed types + assert.eq(col.find({ "decimal" : NumberDecimal("1") }).count(), "4"); + assert.eq(col.find({ "decimal" : NumberDecimal(1) }).count(), "4"); + assert.eq(col.find({ "decimal" : NumberDecimal(NumberLong(1)) }).count(), "4"); + assert.eq(col.find({ "decimal" : NumberDecimal(NumberInt(1)) }).count(), "4"); + assert.eq(col.find({ "decimal" : 1 }).count(), "4"); + assert.eq(col.find({ "decimal" : NumberLong(1) }).count(), "4"); + assert.eq(col.find({ "decimal" : NumberInt(1) }).count(), "4"); +}()); |