Skip to content

Commit 65ae33c

Browse files
committed
added read/write double byte methods
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/io/trunk@140436 13f79535-47bb-0310-9956-ffa450edef68
1 parent 374fead commit 65ae33c

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

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

Lines changed: 25 additions & 4 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.5 2003/11/27 06:27:52 bayard Exp $
3-
* $Revision: 1.5 $
4-
* $Date: 2003/11/27 06:27:52 $
2+
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//io/src/test/org/apache/commons/io/EndianUtilsTest.java,v 1.6 2003/11/27 06:30:26 bayard Exp $
3+
* $Revision: 1.6 $
4+
* $Date: 2003/11/27 06:30:26 $
55
*
66
* ====================================================================
77
*
@@ -70,7 +70,7 @@
7070

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

7676
public class EndianUtilsTest extends TestCase {
@@ -195,6 +195,27 @@ public void testWriteSwappedFloat() {
195195
assertEquals( 0x01, bytes[3] );
196196
}
197197

198+
public void testReadSwappedDouble() {
199+
byte[] bytes = new byte[] { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 };
200+
double d1 = Double.longBitsToDouble( 0x0102030405060708L );
201+
double d2 = EndianUtils.readSwappedDouble( bytes, 0 );
202+
assertEquals( d1, d2, 0.0 );
203+
}
204+
205+
public void testWriteSwappedDouble() {
206+
byte[] bytes = new byte[8];
207+
double d1 = Double.longBitsToDouble( 0x0102030405060708L );
208+
EndianUtils.writeSwappedDouble( bytes, 0, d1 );
209+
assertEquals( 0x08, bytes[0] );
210+
assertEquals( 0x07, bytes[1] );
211+
assertEquals( 0x06, bytes[2] );
212+
assertEquals( 0x05, bytes[3] );
213+
assertEquals( 0x04, bytes[4] );
214+
assertEquals( 0x03, bytes[5] );
215+
assertEquals( 0x02, bytes[6] );
216+
assertEquals( 0x01, bytes[7] );
217+
}
218+
198219
/*
199220
// TODO:
200221

0 commit comments

Comments
 (0)