2
2
3
3
import java .io .*;
4
4
import java .math .BigDecimal ;
5
+ import java .math .BigInteger ;
5
6
import java .util .*;
6
7
7
8
import org .junit .Assert ;
@@ -398,7 +399,7 @@ public void testCopyCurrentEventWithTag() throws Exception {
398
399
targetBytes .toByteArray ());
399
400
}
400
401
401
- public void testCopyCurrentSturctureWithTag () throws Exception {
402
+ public void testCopyCurrentStructureWithTaggedArray () throws Exception {
402
403
final ByteArrayOutputStream sourceBytes = new ByteArrayOutputStream ();
403
404
final CBORGenerator sourceGen = cborGenerator (sourceBytes );
404
405
sourceGen .writeNumber (BigDecimal .ONE );
@@ -422,4 +423,24 @@ public void testCopyCurrentSturctureWithTag() throws Exception {
422
423
},
423
424
targetBytes .toByteArray ());
424
425
}
426
+
427
+
428
+ public void testCopyCurrentStructureWithTaggedBinary () throws Exception {
429
+ final ByteArrayOutputStream sourceBytes = new ByteArrayOutputStream ();
430
+ final CBORGenerator sourceGen = cborGenerator (sourceBytes );
431
+ sourceGen .writeNumber (BigInteger .ZERO );
432
+ sourceGen .close ();
433
+
434
+ final ByteArrayOutputStream targetBytes = new ByteArrayOutputStream ();
435
+ final CBORGenerator gen = cborGenerator (targetBytes );
436
+ final CBORParser cborParser = cborParser (sourceBytes );
437
+ cborParser .nextToken ();
438
+ gen .copyCurrentStructure (cborParser );
439
+ gen .close ();
440
+ cborParser .close ();
441
+
442
+ Assert .assertArrayEquals (
443
+ sourceBytes .toByteArray (),
444
+ targetBytes .toByteArray ());
445
+ }
425
446
}
0 commit comments