diff options
author | Narayan Kamath <narayan@google.com> | 2015-02-17 13:46:16 +0000 |
---|---|---|
committer | Narayan Kamath <narayan@google.com> | 2015-02-18 14:25:18 +0000 |
commit | de75c0aa34c7db47ddec1704e94fa05c54687705 (patch) | |
tree | a63f3e6b6c1ac4a558351370c6037e645a56c094 /harmony-tests/src/test | |
parent | 6ebd116201512baf0cee39584fbf4ad19f7972b7 (diff) | |
download | libcore-de75c0aa34c7db47ddec1704e94fa05c54687705.zip libcore-de75c0aa34c7db47ddec1704e94fa05c54687705.tar.gz libcore-de75c0aa34c7db47ddec1704e94fa05c54687705.tar.bz2 |
Fix handling of consecutive quotes in ChoiceFormat et al.
Two consecutive single quotes ('') must be interpreted as an
escaped single quite sequence. We were implementing it by simply
keeping track of whether the last character was a single quote.
This is insufficient for sequences of three or more quotes since
we shouldn't emit ('') for an escape sequence of ('''). We'll have
to keep track of the number of consecutive quotes we've seen in the
input instead.
This is a partial fix for the bug below. There appears to be another
bug in MessageFormat itself in its handling of subpatterns.
bug: 19011159
Change-Id: Ia71e5d8c1962356cabc265cf80ebc0a04ff84f17
Diffstat (limited to 'harmony-tests/src/test')
-rw-r--r-- | harmony-tests/src/test/java/org/apache/harmony/tests/java/text/ChoiceFormatTest.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/ChoiceFormatTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/ChoiceFormatTest.java index 63232ae..d52e586 100644 --- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/ChoiceFormatTest.java +++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/ChoiceFormatTest.java @@ -21,6 +21,7 @@ import java.text.ChoiceFormat; import java.text.FieldPosition; import java.text.MessageFormat; import java.text.ParsePosition; +import java.util.Locale; import junit.framework.TestCase; @@ -474,4 +475,15 @@ public class ChoiceFormatTest extends TestCase { assertEquals("-\u221E<are negative|0.0<are fractions|1.0#is one|1.0<is 1+|\u221E<are many.", fmt.toPattern()); } + + // http://b/19011159 + public void testEscapedPatternWithConsecutiveQuotes() { + ChoiceFormat format = new ChoiceFormat("0#1'2''3'''4''''."); + String formatted = format.format(0); + assertEquals("12'3'4''.", formatted); + + format = new ChoiceFormat("0#1'2''3'''''4''''."); + formatted = format.format(0); + assertEquals("12'3''4''.", formatted); + } } |