1 /*
2 * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
321 throw new RuntimeException(
322 "Japanese calendar names mismatch. result: " +
323 result +
324 ", expected: " +
325 expected);
326 }
327 } else {
328 System.out.println("Test ignored. Either :-\n" +
329 "OS is not macOS, or\n" +
330 "provider is not HOST: " + type + ", or\n" +
331 "Language is not Japanese: " + lang + ", or\n" +
332 "native calendar is not JapaneseCalendar: " + calType);
333 }
334 }
335
336 static void bug8232860Test() {
337 var inputList = List.of(123, 123.4);
338 var nfExpectedList = List.of("123", "123.4");
339 var ifExpectedList = List.of("123", "123");
340
341 var type = LocaleProviderAdapter.getAdapter(CalendarNameProvider.class, Locale.US)
342 .getAdapterType();
343 if (type == LocaleProviderAdapter.Type.HOST && (IS_WINDOWS || IS_MAC)) {
344 final var numf = NumberFormat.getNumberInstance(Locale.US);
345 final var intf = NumberFormat.getIntegerInstance(Locale.US);
346
347 IntStream.range(0, inputList.size())
348 .forEach(i -> {
349 var input = inputList.get(i);
350 var nfExpected = nfExpectedList.get(i);
351 var result = numf.format(input);
352 if (!result.equals(nfExpected)) {
353 throw new RuntimeException("Incorrect number format. " +
354 "input: " + input + ", expected: " +
355 nfExpected + ", result: " + result);
356 }
357
358 var ifExpected = ifExpectedList.get(i);
359 result = intf.format(input);
360 if (!result.equals(ifExpected)) {
361 throw new RuntimeException("Incorrect integer format. " +
362 "input: " + input + ", expected: " +
363 ifExpected + ", result: " + result);
364 }
365 });
366 System.out.println("bug8232860Test succeeded.");
367 } else {
368 System.out.println("Test ignored. Either :-\n" +
369 "OS is neither macOS/Windows, or\n" +
370 "provider is not HOST: " + type);
371 }
372 }
373 }
|
1 /*
2 * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
321 throw new RuntimeException(
322 "Japanese calendar names mismatch. result: " +
323 result +
324 ", expected: " +
325 expected);
326 }
327 } else {
328 System.out.println("Test ignored. Either :-\n" +
329 "OS is not macOS, or\n" +
330 "provider is not HOST: " + type + ", or\n" +
331 "Language is not Japanese: " + lang + ", or\n" +
332 "native calendar is not JapaneseCalendar: " + calType);
333 }
334 }
335
336 static void bug8232860Test() {
337 var inputList = List.of(123, 123.4);
338 var nfExpectedList = List.of("123", "123.4");
339 var ifExpectedList = List.of("123", "123");
340
341 var defLoc = Locale.getDefault(Locale.Category.FORMAT);
342 var type = LocaleProviderAdapter.getAdapter(CalendarNameProvider.class, Locale.US)
343 .getAdapterType();
344 if (defLoc.equals(Locale.US) &&
345 type == LocaleProviderAdapter.Type.HOST &&
346 (IS_WINDOWS || IS_MAC)) {
347 final var numf = NumberFormat.getNumberInstance(Locale.US);
348 final var intf = NumberFormat.getIntegerInstance(Locale.US);
349
350 IntStream.range(0, inputList.size())
351 .forEach(i -> {
352 var input = inputList.get(i);
353 var nfExpected = nfExpectedList.get(i);
354 var result = numf.format(input);
355 if (!result.equals(nfExpected)) {
356 throw new RuntimeException("Incorrect number format. " +
357 "input: " + input + ", expected: " +
358 nfExpected + ", result: " + result);
359 }
360
361 var ifExpected = ifExpectedList.get(i);
362 result = intf.format(input);
363 if (!result.equals(ifExpected)) {
364 throw new RuntimeException("Incorrect integer format. " +
365 "input: " + input + ", expected: " +
366 ifExpected + ", result: " + result);
367 }
368 });
369 System.out.println("bug8232860Test succeeded.");
370 } else {
371 System.out.println("Test ignored. Either :-\n" +
372 "Default format locale is not Locale.US: " + defLoc + ", or\n" +
373 "OS is neither macOS/Windows, or\n" +
374 "provider is not HOST: " + type);
375 }
376 }
377 }
|