Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/util/Formatter/Basic.java
38821 views
/*1* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/* @test24* @summary Unit test for formatter25* @bug 4906370 4962433 4973103 4989961 5005818 5031150 4970931 4989491 500293726* 5005104 5007745 5061412 5055180 5066788 5088703 6317248 6318369 632012227* 6344623 6369500 6534606 6282094 6286592 6476425 5063507 6469160 647616828*29* @run shell/timeout=240 Basic.sh30*/3132import static java.lang.System.out;3334public class Basic {3536private static int fail = 0;37private static int pass = 0;3839private static Throwable first;4041static void pass() {42pass++;43}4445static void fail(String fs, Class ex) {46String s = "'" + fs + "': " + ex.getName() + " not thrown";47if (first == null)48setFirst(s);49System.err.println("FAILED: " + s);50fail++;51}5253static void fail(String fs, String exp, String got) {54String s = "'" + fs + "': Expected '" + exp + "', got '" + got + "'";55if (first == null)56setFirst(s);57System.err.println("FAILED: " + s);58fail++;59}6061private static void setFirst(String s) {62try {63throw new RuntimeException(s);64} catch (RuntimeException x) {65first = x;66}67}6869static void ck(String fs, String exp, String got) {70if (!exp.equals(got))71fail(fs, exp, got);72else73pass();74}7576public static void main(String[] args) {77BasicBoolean.test();78BasicBooleanObject.test();79BasicByte.test();80BasicByteObject.test();81BasicChar.test();82BasicCharObject.test();83BasicShort.test();84BasicShortObject.test();85BasicInt.test();86BasicIntObject.test();87BasicLong.test();88BasicLongObject.test();89BasicBigInteger.test();90BasicFloat.test();91BasicFloatObject.test();92BasicDouble.test();93BasicDoubleObject.test();94BasicBigDecimal.test();9596BasicDateTime.test();9798if (fail != 0)99throw new RuntimeException((fail + pass) + " tests: "100+ fail + " failure(s), first", first);101else102out.println("all " + (fail + pass) + " tests passed");103}104}105106107