2323
2424/**
2525 * @author Henri Yandell (bayard at apache dot org)
26- * @version $Revision: 1.12 $ $Date: 2004/02/29 21:46:17 $
26+ * @version $Revision: 1.13 $ $Date: 2004/02/29 21:47:07 $
2727 */
2828public class EndianUtilsTest extends TestCase {
2929
@@ -86,6 +86,7 @@ public void testSymmetry() {
8686 public void testReadSwappedShort () throws IOException {
8787 byte [] bytes = new byte [] { 0x02 , 0x01 };
8888 assertEquals ( 0x0102 , EndianUtils .readSwappedShort ( bytes , 0 ) );
89+
8990 ByteArrayInputStream input = new ByteArrayInputStream (bytes );
9091 assertEquals ( 0x0102 , EndianUtils .readSwappedShort ( input ) );
9192 }
@@ -106,13 +107,15 @@ public void testWriteSwappedShort() throws IOException {
106107 public void testReadSwappedUnsignedShort () throws IOException {
107108 byte [] bytes = new byte [] { 0x02 , 0x01 };
108109 assertEquals ( 0x00000102 , EndianUtils .readSwappedUnsignedShort ( bytes , 0 ) );
110+
109111 ByteArrayInputStream input = new ByteArrayInputStream (bytes );
110112 assertEquals ( 0x00000102 , EndianUtils .readSwappedUnsignedShort ( input ) );
111113 }
112114
113115 public void testReadSwappedInteger () throws IOException {
114116 byte [] bytes = new byte [] { 0x04 , 0x03 , 0x02 , 0x01 };
115117 assertEquals ( 0x01020304 , EndianUtils .readSwappedInteger ( bytes , 0 ) );
118+
116119 ByteArrayInputStream input = new ByteArrayInputStream (bytes );
117120 assertEquals ( 0x01020304 , EndianUtils .readSwappedInteger ( input ) );
118121 }
@@ -137,13 +140,15 @@ public void testWriteSwappedInteger() throws IOException {
137140 public void testReadSwappedUnsignedInteger () throws IOException {
138141 byte [] bytes = new byte [] { 0x04 , 0x03 , 0x02 , 0x01 };
139142 assertEquals ( 0x0000000001020304L , EndianUtils .readSwappedUnsignedInteger ( bytes , 0 ) );
143+
140144 ByteArrayInputStream input = new ByteArrayInputStream (bytes );
141145 assertEquals ( 0x0000000001020304L , EndianUtils .readSwappedUnsignedInteger ( input ) );
142146 }
143147
144148 public void testReadSwappedLong () throws IOException {
145149 byte [] bytes = new byte [] { 0x08 , 0x07 , 0x06 , 0x05 , 0x04 , 0x03 , 0x02 , 0x01 };
146150 assertEquals ( 0x0102030405060708L , EndianUtils .readSwappedLong ( bytes , 0 ) );
151+
147152 ByteArrayInputStream input = new ByteArrayInputStream (bytes );
148153 assertEquals ( 0x0102030405060708L , EndianUtils .readSwappedLong ( input ) );
149154 }
@@ -178,6 +183,7 @@ public void testReadSwappedFloat() throws IOException {
178183 float f1 = Float .intBitsToFloat ( 0x01020304 );
179184 float f2 = EndianUtils .readSwappedFloat ( bytes , 0 );
180185 assertEquals ( f1 , f2 , 0.0 );
186+
181187 ByteArrayInputStream input = new ByteArrayInputStream (bytes );
182188 assertEquals ( f1 , EndianUtils .readSwappedFloat ( input ), 0.0 );
183189 }
@@ -205,6 +211,7 @@ public void testReadSwappedDouble() throws IOException {
205211 double d1 = Double .longBitsToDouble ( 0x0102030405060708L );
206212 double d2 = EndianUtils .readSwappedDouble ( bytes , 0 );
207213 assertEquals ( d1 , d2 , 0.0 );
214+
208215 ByteArrayInputStream input = new ByteArrayInputStream (bytes );
209216 assertEquals ( d1 , EndianUtils .readSwappedDouble ( input ), 0.0 );
210217 }
0 commit comments