RFR: 8318613: ChoiceFormat patterns are not well tested

Naoto Sato naoto at openjdk.org
Mon Oct 23 22:27:31 UTC 2023


On Mon, 23 Oct 2023 21:15:44 GMT, Justin Lu <jlu at openjdk.org> wrote:

> Please review this PR which adds a test for ChoiceFormat intended to test a wide range of ChoiceFormat patterns.
> 
> The existing test _Bug4387255_ only tests a singular basic pattern and does not test for incorrect patterns either.
> 
> The new test checks 
> 
> - both correct and incorrect patterns
> - the behavior of incorrect patterns that either throw an IllegalArgumentException or discard the incorrect portion
> - the case of formatting with an empty pattern (that leads to empty limits and formats)

test/jdk/java/text/Format/ChoiceFormat/PatternsTest.java line 48:

> 46: public class PatternsTest {
> 47: 
> 48:     private static final String err1 =

Nit: static constants should be uppercased.

test/jdk/java/text/Format/ChoiceFormat/PatternsTest.java line 59:

> 57:         assertDoesNotThrow( ()-> new ChoiceFormat(pattern),
> 58:                 "Valid pattern should not have thrown an exception");
> 59:     }

For those valid cases, it may be helpful to actually format some edge cases, and check the results, especially for those odd ones. Or compare the parsed arrays.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/16324#discussion_r1369320017
PR Review Comment: https://git.openjdk.org/jdk/pull/16324#discussion_r1369319425


More information about the core-libs-dev mailing list