@@ -270,16 +270,26 @@ public void shuffleTest() {
270270 }
271271
272272 @ Test
273- public void sortTest () {
274- byte [] sorted = new byte []{0 , 1 , 2 , 3 , 4 , 5 , 6 };
273+ public void sortSignedTest () {
274+ byte [] sorted = new byte []{- 2 , - 1 , 0 , 1 , 2 , 3 , 4 , 5 , 6 };
275275 assertArrayEquals (sorted , Bytes .from (sorted ).transform (shuffle ()).transform (sort ()).array ());
276- assertArrayEquals (sorted , Bytes .from (new byte []{6 , 0 , 3 , 4 , 1 , 5 , 2 }).transform (sort ()).array ());
277- assertArrayEquals (Bytes .from (sorted ).reverse ().array (), Bytes .from (new byte []{6 , 0 , 3 , 4 , 1 , 5 , 2 }).transform (sort (new Comparator <Byte >() {
276+ assertArrayEquals (sorted , Bytes .from (new byte []{6 , 0 , 3 , - 2 , - 1 , 4 , 1 , 5 , 2 }).transform (sort ()).array ());
277+ assertArrayEquals (Bytes .from (sorted ).reverse ().array (), Bytes .from (new byte []{6 , - 2 , - 1 , 0 , 3 , 4 , 1 , 5 , 2 }).transform (sort (new Comparator <Byte >() {
278278 @ Override
279279 public int compare (Byte o1 , Byte o2 ) {
280280 return o2 .compareTo (o1 );
281281 }
282282 })).array ());
283+
284+ byte [] checkSignedSorted = new byte []{(byte ) 0x80 , (byte ) 0xFE , (byte ) 0xFF , 0x00 , 0x01 };
285+ assertArrayEquals (checkSignedSorted , Bytes .from (checkSignedSorted ).transform (shuffle ()).transform (sort ()).array ());
286+ }
287+
288+ @ Test
289+ public void sortUnsignedTest () {
290+ byte [] sorted = new byte []{0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , (byte ) 0x80 , (byte ) 0xAE , (byte ) 0xFF };
291+ assertArrayEquals (sorted , Bytes .from (sorted ).transform (shuffle ()).transform (sortUnsigned ()).array ());
292+ assertArrayEquals (sorted , Bytes .from (new byte []{(byte ) 0x80 , (byte ) 0xAE , (byte ) 0xFF , 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 }).transform (sortUnsigned ()).array ());
283293 }
284294
285295 @ Test
0 commit comments