2727import java .nio .ByteBuffer ;
2828import java .nio .charset .Charset ;
2929import java .nio .charset .StandardCharsets ;
30+ import java .text .Normalizer ;
3031import java .util .Arrays ;
3132import java .util .BitSet ;
3233import java .util .LinkedList ;
@@ -148,14 +149,22 @@ private void checkByteBuffer(byte[] array) {
148149 @ Test
149150 public void fromString () throws Exception {
150151 checkString ("" , StandardCharsets .UTF_8 );
152+ checkString (" " , StandardCharsets .UTF_8 );
153+ checkString ("\t " , StandardCharsets .UTF_8 );
151154 checkString ("a" , StandardCharsets .UTF_8 );
155+ checkString ("12345678abcdefjkl" , StandardCharsets .UTF_8 );
152156 checkString ("asdghasdu72Ahdans" , StandardCharsets .UTF_8 );
153157 checkString ("asdghasdu72Ahdans" , StandardCharsets .ISO_8859_1 );
154158 checkString ("7asdh#ö01^^`´dµ@€" , StandardCharsets .UTF_8 );
155159 checkString ("7asdh#ö01^^`´dµ@€" , StandardCharsets .US_ASCII );
156160 checkString ("7asdh#ö01^^`´dµ@€" , StandardCharsets .ISO_8859_1 );
157161 }
158162
163+ @ Test
164+ public void fromMultipleBytes () throws Exception {
165+ assertArrayEquals (new byte []{0x01 , 0x02 , 0x03 }, Bytes .from (Bytes .from ((byte ) 0x01 ), Bytes .from ((byte ) 0x02 ), Bytes .from ((byte ) 0x03 )).array ());
166+ }
167+
159168 private void checkString (String string , Charset charset ) {
160169 Bytes b = Bytes .from (string , charset );
161170 assertArrayEquals (string .getBytes (charset ), b .array ());
@@ -165,6 +174,9 @@ private void checkString(String string, Charset charset) {
165174 Bytes bUtf8 = Bytes .from (string );
166175 assertArrayEquals (string .getBytes (StandardCharsets .UTF_8 ), bUtf8 .array ());
167176 assertEquals (new String (string .getBytes (StandardCharsets .UTF_8 ), StandardCharsets .UTF_8 ), bUtf8 .encodeUtf8 ());
177+ } else {
178+ Bytes bNormalized = Bytes .from (string , Normalizer .Form .NFKD );
179+ assertArrayEquals (Normalizer .normalize (string , Normalizer .Form .NFKD ).getBytes (charset ), bNormalized .array ());
168180 }
169181 }
170182
0 commit comments