Skip to content

Commit 374fead

Browse files
committed
removed unused line and added the read/write float byte methods
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/io/trunk@140435 13f79535-47bb-0310-9956-ffa450edef68
1 parent 7df318b commit 374fead

1 file changed

Lines changed: 23 additions & 5 deletions

File tree

src/test/org/apache/commons/io/EndianUtilsTest.java

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
2-
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//io/src/test/org/apache/commons/io/EndianUtilsTest.java,v 1.4 2003/11/27 04:08:14 bayard Exp $
3-
* $Revision: 1.4 $
4-
* $Date: 2003/11/27 04:08:14 $
2+
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//io/src/test/org/apache/commons/io/EndianUtilsTest.java,v 1.5 2003/11/27 06:27:52 bayard Exp $
3+
* $Revision: 1.5 $
4+
* $Date: 2003/11/27 06:27:52 $
55
*
66
* ====================================================================
77
*
@@ -70,7 +70,7 @@
7070

7171
/**
7272
* @author Henri Yandell (bayard at apache dot org)
73-
* @version $Revision: 1.4 $ $Date: 2003/11/27 04:08:14 $
73+
* @version $Revision: 1.5 $ $Date: 2003/11/27 06:27:52 $
7474
*/
7575

7676
public class EndianUtilsTest extends TestCase {
@@ -158,9 +158,10 @@ public void testWriteSwappedInteger() {
158158
assertEquals( 0x01, bytes[3] );
159159
}
160160

161+
// TODO: public void testWriteUnsignedInteger
162+
161163
public void testReadSwappedLong() {
162164
byte[] bytes = new byte[] { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 };
163-
long ln = EndianUtils.readSwappedLong( bytes, 0 );
164165
assertEquals( 0x0102030405060708L, EndianUtils.readSwappedLong( bytes, 0 ) );
165166
}
166167

@@ -177,6 +178,23 @@ public void testWriteSwappedLong() {
177178
assertEquals( 0x01, bytes[7] );
178179
}
179180

181+
public void testReadSwappedFloat() {
182+
byte[] bytes = new byte[] { 0x04, 0x03, 0x02, 0x01 };
183+
float f1 = Float.intBitsToFloat( 0x01020304 );
184+
float f2 = EndianUtils.readSwappedFloat( bytes, 0 );
185+
assertEquals( f1, f2, 0.0 );
186+
}
187+
188+
public void testWriteSwappedFloat() {
189+
byte[] bytes = new byte[4];
190+
float f1 = Float.intBitsToFloat( 0x01020304 );
191+
EndianUtils.writeSwappedFloat( bytes, 0, f1 );
192+
assertEquals( 0x04, bytes[0] );
193+
assertEquals( 0x03, bytes[1] );
194+
assertEquals( 0x02, bytes[2] );
195+
assertEquals( 0x01, bytes[3] );
196+
}
197+
180198
/*
181199
// TODO:
182200

0 commit comments

Comments
 (0)