- Timestamp:
- 2024-04-23T16:13:30+02:00 (9 months ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/tools/JosmDecimalFormatSymbolsProviderTest.java
r19053 r19054 5 5 import static org.junit.jupiter.api.Assertions.assertNotNull; 6 6 import static org.junit.jupiter.api.Assertions.assertTrue; 7 import static org.junit.jupiter.api.Assertions.fail; 7 8 8 9 import java.io.IOException; … … 15 16 import org.junit.jupiter.api.BeforeAll; 16 17 import org.junit.jupiter.api.Test; 18 import org.junit.jupiter.params.ParameterizedTest; 19 import org.junit.jupiter.params.provider.MethodSource; 17 20 18 21 /** … … 32 35 } 33 36 34 @Test 35 void testGroupingSeparator() { 37 static Stream<Locale> testGroupingSeparator() { 36 38 System.out.println(Locale.getDefault()); 37 39 38 40 assertTrue(I18n.getAvailableTranslations().count() > 10); 39 I18n.getAvailableTranslations().forEach(this::checkGroupingSymbol); 40 Stream.of("", "AU", "IE", "US", "UK").map(country -> new Locale("en", country, "")).forEach(this::checkGroupingSymbol); 41 Stream.of("", "AT", "CH", "DE").map(country -> new Locale("de", country, "")).forEach(this::checkGroupingSymbol); 41 return Stream.concat( 42 I18n.getAvailableTranslations(), 43 Stream.concat(Stream.of("", "AU", "IE", "US", "UK").map(country -> new Locale("en", country, "")), 44 Stream.of("", "AT", "CH", "DE").map(country -> new Locale("de", country, "")) 45 )); 42 46 } 43 47 44 private void checkGroupingSymbol(Locale locale) { 45 assertEquals("123\u202F456", DecimalFormat.getInstance(locale).format(123_456), locale.toString()); 48 @ParameterizedTest 49 @MethodSource 50 void testGroupingSeparator(Locale locale) { 51 final String formattedNumber = DecimalFormat.getInstance(locale).format(123_456); 52 // Note: If you have to add another numeral system, please indicate the name and the locale(s) it is for. 53 if (formattedNumber.startsWith("1")) { 54 // Western Arabic (for most locales) 55 assertEquals("123\u202F456", formattedNumber, locale.toString() + ": " + locale.getDisplayName()); 56 } else if (formattedNumber.startsWith("١")) { 57 // Eastern Arabic (for Arabic locale) 58 assertEquals("١٢٣\u202F٤٥٦", formattedNumber, locale.toString() + ": " + locale.getDisplayName()); 59 } else if (formattedNumber.startsWith("۱")) { 60 // Urdu (for Persian locale) 61 assertEquals("۱۲۳\u202F۴۵۶", formattedNumber, locale.toString() + ": " + locale.getDisplayName()); 62 } else if (formattedNumber.startsWith("१")) { 63 // Devanagari (for Marathi locale) 64 assertEquals("१२३\u202F४५६", formattedNumber, locale.toString() + ": " + locale.getDisplayName()); 65 } else { 66 fail(locale.toString() + " (" + locale.getDisplayName() + "): " + formattedNumber); 67 } 46 68 } 47 69 -
trunk/test/unit/org/openstreetmap/josm/tools/date/DateUtilsTest.java
r18870 r19054 160 160 161 161 setTimeZone(TimeZone.getTimeZone("Europe/Berlin")); 162 assertEquals("1:00:00 AM CET", DateUtils.formatTime(new Date(0), DateFormat.LONG));162 assertEquals("1:00:00 AM GMT+01:00", DateUtils.formatTime(new Date(0), DateFormat.LONG), "This is mostly dependent upon java.locale.providers. CET is also OK."); 163 163 } 164 164 … … 308 308 } 309 309 } 310 311 /** 312 * Some Java version use narrow no-break space ("NNBSP") instead of a space. 313 * @param time The time string with NNBSP instead of a space 314 * @return The time with spaces instead of NNBSP 315 */ 316 private static String replaceWhitespace(String time) { 317 return time.replace((char) 8239 /* "NNBSP" */, ' '); 318 } 310 319 }
Note:
See TracChangeset
for help on using the changeset viewer.