Tests for an already-fixed CharsetEncoder bug.

Bug: 11571917

(cherry picked from commit 7d0998187acb4f0e0ddc030943936c36429efaf1)

Change-Id: I82edae0dd2324a9a5d9f418f72b1a861469044a5
diff --git a/luni/src/test/java/libcore/java/lang/StringTest.java b/luni/src/test/java/libcore/java/lang/StringTest.java
index 605fd63..e16496b 100644
--- a/luni/src/test/java/libcore/java/lang/StringTest.java
+++ b/luni/src/test/java/libcore/java/lang/StringTest.java
@@ -348,4 +348,13 @@
         assertEquals("-w-o-r-l-d-", "hello world".substring(6).replace("", "-"));
         assertEquals("-*-w-*-o-*-r-*-l-*-d-*-", "hello world".substring(6).replace("", "-*-"));
     }
+
+    // http://b/11571917
+    public void test_String_getBytes() throws Exception {
+        assertEquals("[-126, -96]", Arrays.toString("あ".getBytes("Shift_JIS")));
+        assertEquals("[-126, -87]", Arrays.toString("か".getBytes("Shift_JIS")));
+        assertEquals("[-105, 67]", Arrays.toString("佑".getBytes("Shift_JIS")));
+        assertEquals("[36]", Arrays.toString("$".getBytes("Shift_JIS")));
+        assertEquals("[-29, -127, -117]", Arrays.toString("か".getBytes("UTF-8")));
+    }
 }
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/net/URLEncoderTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/net/URLEncoderTest.java
index 1c86303..aa2d9ca 100644
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/net/URLEncoderTest.java
+++ b/luni/src/test/java/org/apache/harmony/luni/tests/java/net/URLEncoderTest.java
@@ -65,4 +65,19 @@
         } catch (UnsupportedCharsetException expected) {
         }
     }
+
+    // http://b/11571917
+    public void test11571917() throws Exception {
+        assertEquals("%82%A0", URLEncoder.encode("あ", "Shift_JIS"));
+        assertEquals("%82%A9", URLEncoder.encode("か", "Shift_JIS"));
+        assertEquals("%97%43", URLEncoder.encode("佑", "Shift_JIS"));
+        assertEquals("%24", URLEncoder.encode("$", "Shift_JIS"));
+        assertEquals("%E3%81%8B", URLEncoder.encode("か", "UTF-8"));
+
+        assertEquals("%82%A0%82%A9%97%43%24%E3%81%8B", URLEncoder.encode("あ", "Shift_JIS") +
+            URLEncoder.encode("か", "Shift_JIS") +
+            URLEncoder.encode("佑", "Shift_JIS") +
+            URLEncoder.encode("$", "Shift_JIS") +
+            URLEncoder.encode("か", "UTF-8"));
+    }
 }