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.1 2003/11/26 07:50:05 bayard Exp $
3- * $Revision: 1.1 $
4- * $Date: 2003/11/26 07:50:05 $
2+ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//io/src/test/org/apache/commons/io/EndianUtilsTest.java,v 1.2 2003/11/26 07:56:38 bayard Exp $
3+ * $Revision: 1.2 $
4+ * $Date: 2003/11/26 07:56:38 $
55 *
66 * ====================================================================
77 *
7070
7171/**
7272 * @author Henri Yandell (bayard at apache dot org)
73- * @version $Revision: 1.1 $ $Date: 2003/11/26 07:50:05 $
73+ * @version $Revision: 1.2 $ $Date: 2003/11/26 07:56:38 $
7474 */
7575
7676public class EndianUtilsTest extends TestCase {
@@ -80,8 +80,10 @@ public EndianUtilsTest(String name) {
8080 }
8181
8282 public void testSwapShort () {
83- // need to study to make up these
84- assertEquals ( 1 , EndianUtils .swapShort ( (short ) 256 ) );
83+ assertEquals ( (short ) 0 , EndianUtils .swapShort ( (short ) 0 ) );
84+ assertEquals ( (short ) 0x0201 , EndianUtils .swapShort ( (short ) 0x0102 ) );
85+ assertEquals ( (short ) 0xffff , EndianUtils .swapShort ( (short ) 0xffff ) );
86+ assertEquals ( (short ) 0x0102 , EndianUtils .swapShort ( (short ) 0x0201 ) );
8587 }
8688
8789 public void testSwapInteger () {
@@ -99,13 +101,26 @@ public void testSwapLong() {
99101 assertEquals ( 0x0807060504030201L , EndianUtils .swapLong ( 0x0102030405060708L ) );
100102 }
101103
102- // TODO:
103104 /*
104105 public void testSwapFloat() {
105106 }
106107
107108 public void testSwapDouble() {
108109 }
110+ */
111+
112+ /**
113+ * Tests all swapXxxx methods for symmetry when going from one endian
114+ * to another and back again.
115+ */
116+ public void testSymmetry () {
117+ assertEquals ( (short ) 0x0102 , EndianUtils .swapShort ( EndianUtils .swapShort ( (short ) 0x0102 ) ) );
118+ assertEquals ( 0x01020304 , EndianUtils .swapInteger ( EndianUtils .swapInteger ( 0x01020304 ) ) );
119+ assertEquals ( 0x0102030405060708L , EndianUtils .swapLong ( EndianUtils .swapLong ( 0x0102030405060708L ) ) );
120+ }
121+
122+ /*
123+ // TODO:
109124
110125 // All readSwappedXxxx(byte[], int)
111126 // All writeSwappedXxxx(byte[], int, xxxx)
0 commit comments