@@ -46,7 +46,7 @@ public class BytesConstructorTests extends ABytesTest {
4646 public TemporaryFolder testFolder = new TemporaryFolder ();
4747
4848 @ Test
49- public void wrapTest () throws Exception {
49+ public void wrapTest () {
5050 Bytes b = Bytes .wrap (example_bytes_seven );
5151 assertSame (example_bytes_seven , b .array ());
5252 byte [] copy = Arrays .copyOf (example_bytes_seven , example_bytes_seven .length );
@@ -66,17 +66,17 @@ public void wrapTest() throws Exception {
6666 }
6767
6868 @ Test (expected = NullPointerException .class )
69- public void wrapTestNullExpected () throws Exception {
69+ public void wrapTestNullExpected () {
7070 Bytes .wrap ((byte []) null );
7171 }
7272
7373 @ Test
74- public void wrapTestNullSafe () throws Exception {
74+ public void wrapTestNullSafe () {
7575 Bytes .wrapNullSafe (null );
7676 }
7777
7878 @ Test
79- public void allocate () throws Exception {
79+ public void allocate () {
8080 assertEquals (0 , Bytes .allocate (0 ).length ());
8181 assertEquals (2 , Bytes .allocate (2 ).length ());
8282 assertEquals (16 , Bytes .allocate (16 ).length ());
@@ -98,7 +98,7 @@ private void checkAllocate(int length, byte content) {
9898 }
9999
100100 @ Test
101- public void fromBitSet () throws Exception {
101+ public void fromBitSet () {
102102 checkBitSet (example_bytes_empty );
103103 checkBitSet (example_bytes_one );
104104 checkBitSet (example_bytes_two );
@@ -114,7 +114,7 @@ private void checkBitSet(byte[] array) {
114114 }
115115
116116 @ Test
117- public void fromBigInteger () throws Exception {
117+ public void fromBigInteger () {
118118 checkBigInteger (example_bytes_one );
119119 checkBigInteger (example_bytes_two );
120120 checkBigInteger (example_bytes_seven );
@@ -129,21 +129,21 @@ private void checkBigInteger(byte[] array) {
129129 }
130130
131131 @ Test
132- public void fromBoolean () throws Exception {
132+ public void fromBoolean () {
133133 assertArrayEquals (new byte []{(byte ) 1 }, Bytes .from (true ).array ());
134134 assertArrayEquals (new byte []{(byte ) 0 }, Bytes .from (false ).array ());
135135 }
136136
137137 @ Test
138- public void fromByte () throws Exception {
138+ public void fromByte () {
139139 byte test = 0x4E ;
140140 assertArrayEquals (new byte []{test }, Bytes .from (test ).array ());
141141 assertArrayEquals (new byte [1 ], Bytes .from ((byte ) 0 ).array ());
142142 assertEquals (test , Bytes .from (test ).toByte ());
143143 }
144144
145145 @ Test
146- public void fromChar () throws Exception {
146+ public void fromChar () {
147147 char test = 5821 ;
148148 byte [] primitiveArray = ByteBuffer .allocate (2 ).putChar (test ).array ();
149149 assertArrayEquals (primitiveArray , Bytes .from (test ).array ());
@@ -152,7 +152,7 @@ public void fromChar() throws Exception {
152152 }
153153
154154 @ Test
155- public void fromShort () throws Exception {
155+ public void fromShort () {
156156 short test = 12721 ;
157157 byte [] primitiveArray = ByteBuffer .allocate (2 ).putShort (test ).array ();
158158 assertArrayEquals (primitiveArray , Bytes .from (test ).array ());
@@ -161,7 +161,7 @@ public void fromShort() throws Exception {
161161 }
162162
163163 @ Test
164- public void fromInt () throws Exception {
164+ public void fromInt () {
165165 int test = 722837193 ;
166166 byte [] primitiveArray = ByteBuffer .allocate (4 ).putInt (test ).array ();
167167 assertArrayEquals (primitiveArray , Bytes .from (test ).array ());
@@ -170,15 +170,15 @@ public void fromInt() throws Exception {
170170 }
171171
172172 @ Test
173- public void fromIntArray () throws Exception {
173+ public void fromIntArray () {
174174 assertArrayEquals (new byte []{0 , 0 , 0 , 1 , 0 , 0 , 0 , 2 }, Bytes .from (1 , 2 ).array ());
175175 assertArrayEquals (Bytes .from (Bytes .from (871193 ), Bytes .from (6761 ), Bytes .from (-917656 )).array (), Bytes .from (871193 , 6761 , -917656 ).array ());
176176 assertArrayEquals (Bytes .from (Bytes .from (1678 ), Bytes .from (-223 ), Bytes .from (11114 )).array (), Bytes .from (1678 , -223 , 11114 ).array ());
177177 assertArrayEquals (new byte []{0 , 11 , 30 , 55 , 0 , 0 , 35 , 53 , 0 , 0 , 0 , 0 , 0 , 0 , 56 , -70 }, Bytes .from (728631 , 9013 , 0 , 14522 ).array ());
178178 }
179179
180180 @ Test
181- public void fromLong () throws Exception {
181+ public void fromLong () {
182182 long test = 172283719283L ;
183183 byte [] primitiveArray = ByteBuffer .allocate (8 ).putLong (test ).array ();
184184 assertArrayEquals (primitiveArray , Bytes .from (test ).array ());
@@ -187,15 +187,33 @@ public void fromLong() throws Exception {
187187 }
188188
189189 @ Test
190- public void fromLongArray () throws Exception {
190+ public void fromLongArray () {
191191 assertArrayEquals (new byte []{0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 2 }, Bytes .from (new long []{1 , 2 }).array ());
192192 assertArrayEquals (Bytes .from (Bytes .from (871193L ), Bytes .from (6761L ), Bytes .from (-917656L )).array (), Bytes .from (new long []{871193 , 6761 , -917656 }).array ());
193193 assertArrayEquals (Bytes .from (Bytes .from (1678L ), Bytes .from (-223L ), Bytes .from (11114L )).array (), Bytes .from (1678L , -223L , 11114L ).array ());
194194 assertArrayEquals (Bytes .from (Bytes .from (1273612831678L ), Bytes .from (-72639123786223L )).array (), Bytes .from (1273612831678L , -72639123786223L ).array ());
195195 }
196196
197197 @ Test
198- public void fromByteBuffer () throws Exception {
198+ public void fromFloat () {
199+ float test = 63278.123f ;
200+ byte [] primitiveArray = ByteBuffer .allocate (4 ).putFloat (test ).array ();
201+ assertArrayEquals (primitiveArray , Bytes .from (test ).array ());
202+ assertArrayEquals (new byte [4 ], Bytes .from (0f ).array ());
203+ assertEquals (test , Bytes .from (test ).toFloat (), 0.01 );
204+ }
205+
206+ @ Test
207+ public void fromDouble () {
208+ double test = 3423423.8923423974123 ;
209+ byte [] primitiveArray = ByteBuffer .allocate (8 ).putDouble (test ).array ();
210+ assertArrayEquals (primitiveArray , Bytes .from (test ).array ());
211+ assertArrayEquals (new byte [8 ], Bytes .from (0.0 ).array ());
212+ assertEquals (test , Bytes .from (test ).toDouble (), 0.01 );
213+ }
214+
215+ @ Test
216+ public void fromByteBuffer () {
199217 checkByteBuffer (example_bytes_empty );
200218 checkByteBuffer (example_bytes_one );
201219 checkByteBuffer (example_bytes_two );
@@ -210,7 +228,7 @@ private void checkByteBuffer(byte[] array) {
210228 }
211229
212230 @ Test
213- public void fromString () throws Exception {
231+ public void fromString () {
214232 checkString ("" , StandardCharsets .UTF_8 );
215233 checkString (" " , StandardCharsets .UTF_8 );
216234 checkString ("\t " , StandardCharsets .UTF_8 );
@@ -224,7 +242,7 @@ public void fromString() throws Exception {
224242 }
225243
226244 @ Test
227- public void fromMultipleBytes () throws Exception {
245+ public void fromMultipleBytes () {
228246 assertArrayEquals (new byte []{0x01 , 0x02 , 0x03 }, Bytes .from (Bytes .from ((byte ) 0x01 ), Bytes .from ((byte ) 0x02 ), Bytes .from ((byte ) 0x03 )).array ());
229247 }
230248
@@ -244,7 +262,7 @@ private void checkString(String string, Charset charset) {
244262 }
245263
246264 @ Test
247- public void fromInputStream () throws Exception {
265+ public void fromInputStream () {
248266 checkInputStream (example_bytes_one );
249267 checkInputStream (example_bytes_two );
250268 checkInputStream (example_bytes_four );
@@ -259,7 +277,7 @@ private void checkInputStream(byte[] array) {
259277 }
260278
261279 @ Test
262- public void fromDataInput () throws Exception {
280+ public void fromDataInput () {
263281 checkDataInput (example_bytes_one );
264282 checkDataInput (example_bytes_two );
265283 checkDataInput (example_bytes_four );
@@ -274,12 +292,12 @@ private void checkDataInput(byte[] array) {
274292 }
275293
276294 @ Test (expected = IllegalStateException .class )
277- public void fromDataInputShouldThrowException () throws Exception {
295+ public void fromDataInputShouldThrowException () {
278296 Bytes .from (new DataInputStream (new ByteArrayInputStream (example_bytes_one )), 2 );
279297 }
280298
281299 @ Test
282- public void fromList () throws Exception {
300+ public void fromList () {
283301 checkList (example_bytes_one );
284302 checkList (example_bytes_two );
285303 checkList (example_bytes_four );
@@ -296,7 +314,7 @@ private void checkList(byte[] array) {
296314 }
297315
298316 @ Test
299- public void fromVariousBytes () throws Exception {
317+ public void fromVariousBytes () {
300318 assertArrayEquals (example_bytes_one , Bytes .from (example_bytes_one ).array ());
301319 assertArrayEquals (example_bytes_two , Bytes .from (example_bytes_two ).array ());
302320 assertArrayEquals (example_bytes_seven , Bytes .from (example_bytes_seven ).array ());
@@ -318,7 +336,7 @@ public void fromVariousBytes() throws Exception {
318336 }
319337
320338 @ Test
321- public void fromPartByte () throws Exception {
339+ public void fromPartByte () {
322340 assertArrayEquals (new byte []{example_bytes_four [1 ]}, Bytes .from (example_bytes_four , 1 , 1 ).array ());
323341 assertArrayEquals (new byte []{example_bytes_eight [4 ], example_bytes_eight [5 ], example_bytes_eight [6 ]}, Bytes .from (example_bytes_eight , 4 , 3 ).array ());
324342 }
@@ -336,7 +354,7 @@ public void fromFile() throws Exception {
336354 }
337355
338356 @ Test (expected = IllegalArgumentException .class )
339- public void fromFileNotExisting () throws Exception {
357+ public void fromFileNotExisting () {
340358 Bytes .from (new File ("doesnotexist" ));
341359 }
342360
@@ -358,7 +376,7 @@ public void fromFileCannotRead() throws Exception {
358376 }
359377
360378 @ Test
361- public void fromObjectArray () throws Exception {
379+ public void fromObjectArray () {
362380 Byte [] objectArray = new Byte []{0x01 , 0x02 , 0x03 , 0x04 };
363381 Bytes b = Bytes .from (objectArray );
364382 assertArrayEquals (new byte []{0x01 , 0x02 , 0x03 , 0x04 }, b .array ());
0 commit comments