@@ -289,7 +289,7 @@ class DecodeSpec extends Specification {
289289 val moreThanMaxLong =
290290 new BsonDecimal128 (new Decimal128 ((BigDecimal (Long .MaxValue ) + BigDecimal (1L )).bigDecimal))
291291 val lessThanMinLong =
292- new BsonDecimal128 (new Decimal128 ((BigDecimal (Long .MinValue ) + BigDecimal (- 1L )).bigDecimal))
292+ new BsonDecimal128 (new Decimal128 ((BigDecimal (Long .MinValue ) - BigDecimal (1L )).bigDecimal))
293293 val moreThanMaxDouble =
294294 new BsonDecimal128 (new Decimal128 (
295295 (BigDecimal (Double .MaxValue ) * 1.1 ).bigDecimal
@@ -298,40 +298,55 @@ class DecodeSpec extends Specification {
298298 new BsonDecimal128 (new Decimal128 (
299299 (BigDecimal (Double .MinValue ) * 1.1 ).bigDecimal
300300 ))
301-
302301 val tinierThanTiny =
303302 new BsonDecimal128 (new Decimal128 (
304303 (BigDecimal (Double .MinPositiveValue ) / 2 ).bigDecimal
305304 ))
305+ val rational =
306+ new BsonDecimal128 (new Decimal128 (
307+ (BigDecimal (1L ) / BigDecimal (3L )).bigDecimal
308+ ))
309+ val doubleRational =
310+ new BsonDecimal128 (new Decimal128 (
311+ BigDecimal (1.0 / 3.0 ).bigDecimal
312+ ))
306313
307- qdataDecoder.tpe(nan) === QNull
308- qdataDecoder.tpe(negativeNaN) === QNull
309- qdataDecoder.tpe(inf) === QNull
310- qdataDecoder.tpe(negativeInf) === QNull
311- qdataDecoder.tpe(zero) === QLong
312- qdataDecoder.tpe(negativeZero) === QLong
313- qdataDecoder.tpe(maxLong) === QLong
314- qdataDecoder.tpe(minLong) === QLong
315- qdataDecoder.tpe(maxDouble) === QDouble
316- qdataDecoder.tpe(minDouble) === QDouble
317- qdataDecoder.tpe(tinyDouble) === QDouble
318- qdataDecoder.tpe(moreThanMaxLong) === QDouble
319- qdataDecoder.tpe(lessThanMinLong) === QDouble
320- qdataDecoder.tpe(moreThanMaxDouble) === QReal
321- qdataDecoder.tpe(lessThanMinDouble) === QReal
322- qdataDecoder.tpe(tinierThanTiny) === QReal
314+ " tpe" >> {
315+ " nan" >> (qdataDecoder.tpe(nan) === QNull )
316+ " -nan" >> (qdataDecoder.tpe(negativeNaN) === QNull )
317+ " inf" >> (qdataDecoder.tpe(inf) === QNull )
318+ " -inf" >> (qdataDecoder.tpe(negativeInf) === QNull )
319+ " 0" >> (qdataDecoder.tpe(zero) === QLong )
320+ " ---0" >> (qdataDecoder.tpe(negativeZero) === QLong )
321+ " maxlong" >> (qdataDecoder.tpe(maxLong) === QLong )
322+ " minlong" >> (qdataDecoder.tpe(minLong) === QLong )
323+ " maxdouble" >> (qdataDecoder.tpe(maxDouble) === QDouble )
324+ " mindouble" >> (qdataDecoder.tpe(minDouble) === QDouble )
325+ " tinydouble" >> (qdataDecoder.tpe(tinyDouble) === QDouble )
326+ " >maxlong" >> (qdataDecoder.tpe(moreThanMaxLong) === QReal )
327+ " <minLong" >> (qdataDecoder.tpe(lessThanMinLong) === QReal )
328+ " >maxdouble" >> (qdataDecoder.tpe(moreThanMaxDouble) === QReal )
329+ " <mindouble" >> (qdataDecoder.tpe(lessThanMinDouble) === QReal )
330+ " abs < tinydouble" >> (qdataDecoder.tpe(tinierThanTiny) === QReal )
331+ " rational" >> (qdataDecoder.tpe(rational) === QReal )
332+ " doublerational" >> (qdataDecoder.tpe(doubleRational) === QDouble )
333+ }
323334
324- qdataDecoder.getLong(zero) === 0L
325- qdataDecoder.getLong(negativeZero) === 0L
326- qdataDecoder.getLong(maxLong) === Long .MaxValue
327- qdataDecoder.getLong(minLong) === Long .MinValue
328- qdataDecoder.getDouble(maxDouble) === Double .MaxValue
329- qdataDecoder.getDouble(minDouble) === Double .MinValue
330- qdataDecoder.getDouble(tinyDouble) === Double .MinPositiveValue
331- qdataDecoder.getDouble(moreThanMaxLong) === Long .MaxValue + 1.0
332- qdataDecoder.getDouble(lessThanMinLong) === Long .MinValue - 1.0
333- qdataDecoder.getReal(moreThanMaxDouble) === Real (BigDecimal (Double .MaxValue ) * 1.1 )
334- qdataDecoder.getReal(lessThanMinDouble) === Real (BigDecimal (Double .MinValue ) * 1.1 )
335- qdataDecoder.getReal(tinierThanTiny) === Real (BigDecimal (Double .MinPositiveValue ) / 2 )
335+ " getValue" >> {
336+ " 0" >> (qdataDecoder.getLong(zero) === 0L )
337+ " ---0" >> (qdataDecoder.getLong(negativeZero) === 0L )
338+ " maxlong" >> (qdataDecoder.getLong(maxLong) === Long .MaxValue )
339+ " minlong" >> (qdataDecoder.getLong(minLong) === Long .MinValue )
340+ " maxdouble" >> (qdataDecoder.getDouble(maxDouble) === Double .MaxValue )
341+ " mindouble" >> (qdataDecoder.getDouble(minDouble) === Double .MinValue )
342+ " tinydouble" >> (qdataDecoder.getDouble(tinyDouble) === Double .MinPositiveValue )
343+ " >maxlong" >> (qdataDecoder.getReal(moreThanMaxLong) === Real (Long .MaxValue ) + 1.0 )
344+ " <minlong" >> (qdataDecoder.getReal(lessThanMinLong) === Real (Long .MinValue ) - 1.0 )
345+ " >maxdouble" >> (qdataDecoder.getReal(moreThanMaxDouble) === Real (BigDecimal (Double .MaxValue ) * 1.1 ))
346+ " <mindouble" >> (qdataDecoder.getReal(lessThanMinDouble) === Real (BigDecimal (Double .MinValue ) * 1.1 ))
347+ " abs < tinydouble" >> (qdataDecoder.getReal(tinierThanTiny) === Real (BigDecimal (Double .MinPositiveValue ) / 2 ))
348+ " rational" >> (qdataDecoder.getReal(rational) === Real (BigDecimal (1L ) / BigDecimal (3L )))
349+ " doublerational" >> (qdataDecoder.getDouble(doubleRational) === 1.0 / 3.0 )
350+ }
336351 }
337352}
0 commit comments