diff options
author | 2017-02-17 10:18:57 +0000 | |
---|---|---|
committer | 2017-02-17 10:27:34 +0000 | |
commit | 85bef97df9019dd4aa27e00437198952b41d2a62 (patch) | |
tree | 12563d16e25981191cb0c9f4db794031aa21e212 | |
parent | 1fed1dc7b1ea75b0465c0b2b3457718aab5a0f34 (diff) |
Tests for String.setCharAt() breaking string compression.
With string compression, all compressible strings must be
compressed. The internal API String.setCharAt() can break
that invariant when overwriting a non-ASCII character with
an ASCII character, turning an uncompressible string into
a compressible one. It can also truncate a non-ASCII
character written to a compressed string. These regression
tests check the public API that exposes the problem.
Submitting these tests (without a fix) shall prevent us
from enabling string compression before it's ready.
Test: testrunner.py --host -t 021-string2
Test: Manually check that new asserts fail with string compression.
Bug: 31040547
Change-Id: I66f27a73f273f7648acbdf1b601345711f37c85e
-rw-r--r-- | test/021-string2/src/Main.java | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/021-string2/src/Main.java b/test/021-string2/src/Main.java index 5a43a4f23f..0dd82abf6f 100644 --- a/test/021-string2/src/Main.java +++ b/test/021-string2/src/Main.java @@ -16,6 +16,7 @@ import junit.framework.Assert; import java.lang.reflect.Method; +import java.util.Locale; /** * more string tests @@ -120,6 +121,12 @@ public class Main { testEqualsConstString(); testConstStringEquals(); + + // Regression tests for String.setCharAt() breaking string compression invariants. + Locale en_US = new Locale("en", "US"); + Assert.assertEquals("I", /* Small latin dotless i */ "\u0131".toUpperCase()); + Assert.assertEquals("abc", "a\u0131c".replace('\u0131', 'b')); + Assert.assertEquals("a\u0131c", "abc".replace('b', '\u0131')); } public static void testCompareToAndEquals() { |