22
33import java .io .*;
44import java .math .BigDecimal ;
5+ import java .math .BigInteger ;
56import java .util .*;
67
78import org .junit .Assert ;
@@ -398,7 +399,7 @@ public void testCopyCurrentEventWithTag() throws Exception {
398399 targetBytes .toByteArray ());
399400 }
400401
401- public void testCopyCurrentSturctureWithTag () throws Exception {
402+ public void testCopyCurrentStructureWithTaggedArray () throws Exception {
402403 final ByteArrayOutputStream sourceBytes = new ByteArrayOutputStream ();
403404 final CBORGenerator sourceGen = cborGenerator (sourceBytes );
404405 sourceGen .writeNumber (BigDecimal .ONE );
@@ -422,4 +423,24 @@ public void testCopyCurrentSturctureWithTag() throws Exception {
422423 },
423424 targetBytes .toByteArray ());
424425 }
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+ }
425446}
0 commit comments