bayard 2003/11/26 22:30:26
Modified: io/src/test/org/apache/commons/io EndianUtilsTest.java
Log:
added read/write double byte methods
Revision Changes Path
1.6 +25 -4
jakarta-commons-sandbox/io/src/test/org/apache/commons/io/EndianUtilsTest.java
Index: EndianUtilsTest.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/io/src/test/org/apache/commons/io/EndianUtilsTest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- EndianUtilsTest.java 27 Nov 2003 06:27:52 -0000 1.5
+++ EndianUtilsTest.java 27 Nov 2003 06:30:26 -0000 1.6
@@ -195,6 +195,27 @@
assertEquals( 0x01, bytes[3] );
}
+ public void testReadSwappedDouble() {
+ byte[] bytes = new byte[] { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01
};
+ double d1 = Double.longBitsToDouble( 0x0102030405060708L );
+ double d2 = EndianUtils.readSwappedDouble( bytes, 0 );
+ assertEquals( d1, d2, 0.0 );
+ }
+
+ public void testWriteSwappedDouble() {
+ byte[] bytes = new byte[8];
+ double d1 = Double.longBitsToDouble( 0x0102030405060708L );
+ EndianUtils.writeSwappedDouble( bytes, 0, d1 );
+ assertEquals( 0x08, bytes[0] );
+ assertEquals( 0x07, bytes[1] );
+ assertEquals( 0x06, bytes[2] );
+ assertEquals( 0x05, bytes[3] );
+ assertEquals( 0x04, bytes[4] );
+ assertEquals( 0x03, bytes[5] );
+ assertEquals( 0x02, bytes[6] );
+ assertEquals( 0x01, bytes[7] );
+ }
+
/*
// TODO:
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]