diff options
author | Jennifer Peshansky <jennifer.peshansky@mongodb.com> | 2021-10-27 14:53:03 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-10-27 16:21:59 +0000 |
commit | b7a055f55a202ba870730fb865579acf5d9fb90f (patch) | |
tree | 22ed657f71bca593edfbe66e661759f99cc98566 | |
parent | 1d73f4df563f15e07158fcf4323a1e1f68cc53ad (diff) | |
download | mongo-b7a055f55a202ba870730fb865579acf5d9fb90f.tar.gz |
SERVER-60584 Add test cases for $multiply
-rw-r--r-- | jstests/aggregation/expressions/multiply.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/jstests/aggregation/expressions/multiply.js b/jstests/aggregation/expressions/multiply.js index 9fa789c3cac..0743085565d 100644 --- a/jstests/aggregation/expressions/multiply.js +++ b/jstests/aggregation/expressions/multiply.js @@ -124,6 +124,47 @@ const nAryTestCases = [ {values: [null, 2, 3, 4, 5, 6, 7, 8, 9, 10], expected: null}, {values: [1, 2, 3, 4, 5, null, 7, 8, 9, 10], expected: null}, {values: [1, 2, 3, 4, 5, 6, 7, 8, 9, null], expected: null}, + + // Test different combinations of types. + { + values: [NumberInt(12345), NumberLong(67890), NumberDecimal(2.71828)], + expected: NumberDecimal("2278196040.47400000000000") + }, + {values: [NumberInt(12345), 67890, NumberLong(23456)], expected: 19658521684800}, + { + values: [NumberInt(12345), 67890, NumberDecimal(2.71828)], + expected: NumberDecimal("2278196040.47400000000000000000") + }, + { + values: [NumberLong(67890), 12345, NumberDecimal(2.71828)], + expected: NumberDecimal("2278196040.47400000000000000000") + }, + + // Test edge cases. + { + values: [1, NumberLong("314159265358979393"), NumberLong("-314159265358979323")], + expected: -9.86960440108936e+34 + }, + { + values: [NumberInt(1), NumberDecimal(1.1), 1.0e+35], + expected: NumberDecimal("1.1000000000000000000000000000E+35") + }, + { + values: [NumberInt(2147483647), 9223372036854, NumberLong(-9223372036854)], + expected: -1.8268770458126154e+35 + }, + { + values: [NumberInt(2147483647), 9223372036854, NumberDecimal(3.14)], + expected: NumberDecimal("62194107544730740000000.000000") + }, + {values: [NumberInt(1), NumberDecimal(1.1), NaN], expected: NumberDecimal("NaN")}, + { + values: [-NaN, NumberLong("314159265358979393"), NumberLong("-314159265358979323")], + expected: NaN + }, + {values: [undefined, 9223372036854, NumberDecimal(3.14)], expected: undefined}, + {values: [NumberInt(2147483647), Infinity, NumberLong(-9223372036854)], expected: -Infinity}, + {values: [-Infinity, NumberDecimal(-1.1), 1.0e+35], expected: NumberDecimal("Infinity")}, ]; nAryTestCases.forEach(function(testCase) { |