directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r440615 - /directory/trunks/mina/core/src/test/java/org/apache/mina/common/ByteBufferTest.java
Date Wed, 06 Sep 2006 05:04:45 GMT
Author: trustin
Date: Tue Sep  5 22:04:44 2006
New Revision: 440615

URL: http://svn.apache.org/viewvc?view=rev&rev=440615
Log:
Added more test case for ByteBuffer.getString()

Modified:
    directory/trunks/mina/core/src/test/java/org/apache/mina/common/ByteBufferTest.java

Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/common/ByteBufferTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/test/java/org/apache/mina/common/ByteBufferTest.java?view=diff&rev=440615&r1=440614&r2=440615
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/common/ByteBufferTest.java (original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/common/ByteBufferTest.java Tue
Sep  5 22:04:44 2006
@@ -227,6 +227,19 @@
         Assert.assertEquals( "A", buf.getString( 1, decoder ) );
         Assert.assertEquals( 1, buf.position() );
 
+        // Test a trailing garbage
+        buf.clear();
+        buf.put( (byte) 'A' );
+        buf.put( (byte) 'B' );
+        buf.put( (byte) 0 );
+        buf.put( (byte) 'C' );
+        buf.position( 0 );
+        Assert.assertEquals( "AB", buf.getString( 4, decoder ) );
+        Assert.assertEquals( 4, buf.position() );
+        buf.position( 0 );
+        Assert.assertEquals( "AB\u0000C", buf.getString( 4, decoder, false ) );
+        Assert.assertEquals( 4, buf.position() );
+
         buf.clear();
         buf.fillAndReset( buf.limit() );
         decoder = Charset.forName( "UTF-16" ).newDecoder();
@@ -271,7 +284,7 @@
         {
             // ignore
         }
-
+        
         // Test getting strings from an empty buffer.
         buf.clear();
         buf.limit( 0 );



Mime
View raw message