File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed
src/test/java/at/favre/lib/bytes Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -123,5 +123,11 @@ public void toLong() throws Exception {
123123 assertNotEquals (b .byteOrder (ByteOrder .BIG_ENDIAN ).toLong (), b .byteOrder (ByteOrder .LITTLE_ENDIAN ).toLong ());
124124 }
125125
126+ @ Test
127+ public void bigInteger () throws Exception {
128+ Bytes b = Bytes .from (example_bytes_four );
129+ assertNotEquals (b .byteOrder (ByteOrder .BIG_ENDIAN ).bigInteger (), b .byteOrder (ByteOrder .LITTLE_ENDIAN ).bigInteger ());
130+ assertEquals (b .byteOrder (ByteOrder .BIG_ENDIAN ).bigInteger (), b .byteOrder (ByteOrder .LITTLE_ENDIAN ).reverse ().bigInteger ());
131+ }
126132
127133}
Original file line number Diff line number Diff line change 2424import org .junit .Test ;
2525
2626import java .nio .ByteOrder ;
27+ import java .nio .ReadOnlyBufferException ;
2728
2829import static org .junit .Assert .*;
2930
@@ -178,5 +179,12 @@ public void readOnly() throws Exception {
178179 assertFalse (Bytes .from (example_bytes_twentyfour ).isReadOnly ());
179180 assertTrue (Bytes .from (example_bytes_twentyfour ).readOnly ().isReadOnly ());
180181 assertTrue (Bytes .from (example_bytes_twentyfour ).readOnly ().copy ().isReadOnly ());
182+
183+ assertArrayEquals (example_bytes_twentyfour , Bytes .from (example_bytes_twentyfour ).readOnly ().internalArray ());
184+ try {
185+ Bytes .from (example_bytes_twentyfour ).readOnly ().array ();
186+ fail ();
187+ } catch (ReadOnlyBufferException e ) {
188+ }
181189 }
182190}
Original file line number Diff line number Diff line change @@ -100,4 +100,10 @@ public void secureWipeShouldThrowException() throws Exception {
100100 Bytes .wrap (new byte [0 ]).mutable ().secureWipe (null );
101101 }
102102
103+ @ Test
104+ public void testIfGetSameInstance () throws Exception {
105+ MutableBytes b = fromAndTest (example_bytes_seven ).mutable ();
106+ assertSame (b , b .mutable ());
107+ }
108+
103109}
You can’t perform that action at this time.
0 commit comments