commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject cvs commit: jakarta-commons-sandbox/io/src/test/org/apache/commons/io EndianUtilsTest.java
Date Thu, 27 Nov 2003 06:27:52 GMT
bayard      2003/11/26 22:27:52

  Modified:    io/src/test/org/apache/commons/io EndianUtilsTest.java
  Log:
  removed unused line and added the read/write float byte methods
  
  Revision  Changes    Path
  1.5       +23 -5     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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- EndianUtilsTest.java	27 Nov 2003 04:08:14 -0000	1.4
  +++ EndianUtilsTest.java	27 Nov 2003 06:27:52 -0000	1.5
  @@ -158,9 +158,10 @@
           assertEquals( 0x01, bytes[3] );
       }
   
  +    // TODO: public void testWriteUnsignedInteger
  +
       public void testReadSwappedLong() {
           byte[] bytes = new byte[] { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 };
  -        long ln = EndianUtils.readSwappedLong( bytes, 0 );
           assertEquals( 0x0102030405060708L, EndianUtils.readSwappedLong( bytes, 0 ) );
       }
   
  @@ -175,6 +176,23 @@
           assertEquals( 0x03, bytes[5] );
           assertEquals( 0x02, bytes[6] );
           assertEquals( 0x01, bytes[7] );
  +    }
  +
  +    public void testReadSwappedFloat() {
  +        byte[] bytes = new byte[] { 0x04, 0x03, 0x02, 0x01 };
  +        float f1 = Float.intBitsToFloat( 0x01020304 );
  +        float f2 = EndianUtils.readSwappedFloat( bytes, 0 );
  +        assertEquals( f1, f2, 0.0 );
  +    }
  +
  +    public void testWriteSwappedFloat() {
  +        byte[] bytes = new byte[4];
  +        float f1 = Float.intBitsToFloat( 0x01020304 );
  +        EndianUtils.writeSwappedFloat( bytes, 0, f1 );
  +        assertEquals( 0x04, bytes[0] );
  +        assertEquals( 0x03, bytes[1] );
  +        assertEquals( 0x02, bytes[2] );
  +        assertEquals( 0x01, bytes[3] );
       }
   
       /*
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message