commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1383170 - /commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java
Date Mon, 10 Sep 2012 23:58:29 GMT
Author: sebb
Date: Mon Sep 10 23:58:29 2012
New Revision: 1383170

URL: http://svn.apache.org/viewvc?rev=1383170&view=rev
Log:
Use valid input for testing byte conversion, as behaviour for invalid input is undefined.
Fixes test failure with IBM Java 1.6

Modified:
    commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java

Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java?rev=1383170&r1=1383169&r2=1383170&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java
(original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java
Mon Sep 10 23:58:29 2012
@@ -33,6 +33,12 @@ public class StringUtilsTest {
 
     private static final byte[] BYTES_FIXTURE = {'a','b','c'};
 
+    // This is valid input for UTF-16BE
+    private static final byte[] BYTES_FIXTURE_16BE = {0, 'a', 0, 'b', 0, 'c'};
+
+    // This is valid for UTF-16LE
+    private static final byte[] BYTES_FIXTURE_16LE = {'a', 0, 'b', 0, 'c', 0};
+
     private static final String STRING_FIXTURE = "ABC";
 
     /**
@@ -171,8 +177,8 @@ public class StringUtilsTest {
     public void testNewStringUtf16Be() throws UnsupportedEncodingException {
         String charsetName = "UTF-16BE";
         testNewString(charsetName);
-        String expected = new String(BYTES_FIXTURE, charsetName);
-        String actual = StringUtils.newStringUtf16Be(BYTES_FIXTURE);
+        String expected = new String(BYTES_FIXTURE_16BE, charsetName);
+        String actual = StringUtils.newStringUtf16Be(BYTES_FIXTURE_16BE);
         Assert.assertEquals(expected, actual);
     }
 
@@ -180,8 +186,8 @@ public class StringUtilsTest {
     public void testNewStringUtf16Le() throws UnsupportedEncodingException {
         String charsetName = "UTF-16LE";
         testNewString(charsetName);
-        String expected = new String(BYTES_FIXTURE, charsetName);
-        String actual = StringUtils.newStringUtf16Le(BYTES_FIXTURE);
+        String expected = new String(BYTES_FIXTURE_16LE, charsetName);
+        String actual = StringUtils.newStringUtf16Le(BYTES_FIXTURE_16LE);
         Assert.assertEquals(expected, actual);
     }
 



Mime
View raw message