@@ -328,7 +328,7 @@ public void testFloatNumberType() throws IOException {
328
328
}
329
329
330
330
public void testBigDecimalType () throws IOException {
331
- final BigDecimal NR = new BigDecimal ("273.15 " );
331
+ final BigDecimal NR = new BigDecimal ("172.125 " );
332
332
ByteArrayOutputStream out = new ByteArrayOutputStream ();
333
333
CBORGenerator generator = cborGenerator (out );
334
334
generator .writeNumber (NR );
@@ -343,7 +343,20 @@ public void testBigDecimalType() throws IOException {
343
343
assertEquals (NR .intValue (), parser .getIntValue ());
344
344
assertNull (parser .nextToken ());
345
345
}
346
- // Almost good. But [dataformats#139] to consider too...
347
- // ... but that'll need to wait for 2.10
346
+
347
+ // Almost good. But [dataformats#139] to consider too, see
348
+ // [https://tools.ietf.org/html/rfc7049#section-2.4.2]
349
+ final byte [] spec = new byte [] {
350
+ (byte ) 0xC4 , // tag 4
351
+ (byte ) 0x82 , // Array of length 2
352
+ 0x21 , // int -- -2
353
+ 0x19 , 0x6a , (byte ) 0xb3 // int 27315
354
+ };
355
+ try (CBORParser parser = cborParser (spec )) {
356
+ assertEquals (JsonToken .VALUE_NUMBER_FLOAT , parser .nextToken ());
357
+ assertEquals (NumberType .BIG_DECIMAL , parser .getNumberType ());
358
+ assertEquals (new BigDecimal ("273.15" ), parser .getDecimalValue ());
359
+ assertNull (parser .nextToken ());
360
+ }
348
361
}
349
362
}
0 commit comments