bayard      2003/11/25 23:56:38

  Modified:    io/src/test/org/apache/commons/io EndianUtilsTest.java
  Log:
  Filled things in a bit more test wise.
  
  Revision  Changes    Path
  1.2       +21 -6     
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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- EndianUtilsTest.java      26 Nov 2003 07:50:05 -0000      1.1
  +++ EndianUtilsTest.java      26 Nov 2003 07:56:38 -0000      1.2
  @@ -80,8 +80,10 @@
       }
   
       public void testSwapShort() {
  -        // need to study to make up these
  -        assertEquals( 1, EndianUtils.swapShort( (short) 256 ) );
  +        assertEquals( (short) 0, EndianUtils.swapShort( (short) 0 ) );
  +        assertEquals( (short) 0x0201, EndianUtils.swapShort( (short) 0x0102 ) );
  +        assertEquals( (short) 0xffff, EndianUtils.swapShort( (short) 0xffff ) );
  +        assertEquals( (short) 0x0102, EndianUtils.swapShort( (short) 0x0201 ) );
       }
   
       public void testSwapInteger() {
  @@ -99,13 +101,26 @@
           assertEquals( 0x0807060504030201L, EndianUtils.swapLong( 
0x0102030405060708L ) );
       }
   
  -    // TODO:
       /*
       public void testSwapFloat() {
       }
   
       public void testSwapDouble() {
       }
  +    */
  +
  +    /**
  +     * Tests all swapXxxx methods for symmetry when going from one endian 
  +     * to another and back again. 
  +     */
  +    public void testSymmetry() {
  +        assertEquals( (short) 0x0102, EndianUtils.swapShort( EndianUtils.swapShort( 
(short) 0x0102 ) ) );
  +        assertEquals( 0x01020304, EndianUtils.swapInteger( EndianUtils.swapInteger( 
0x01020304 ) ) );
  +        assertEquals( 0x0102030405060708L, EndianUtils.swapLong( 
EndianUtils.swapLong( 0x0102030405060708L ) ) );
  +    }
  +
  +    /*
  +    // TODO:
   
       // All readSwappedXxxx(byte[], int)
       // All writeSwappedXxxx(byte[], int, xxxx)
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to