4555N/A/*
4555N/A * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
4555N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4555N/A *
4555N/A * This code is free software; you can redistribute it and/or modify it
4555N/A * under the terms of the GNU General Public License version 2 only, as
4555N/A * published by the Free Software Foundation.
4555N/A *
4555N/A * This code is distributed in the hope that it will be useful, but WITHOUT
4555N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4555N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4555N/A * version 2 for more details (a copy is included in the LICENSE file that
4555N/A * accompanied this code).
4555N/A *
4555N/A * You should have received a copy of the GNU General Public License version
4555N/A * 2 along with this work; if not, write to the Free Software Foundation,
4555N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4555N/A *
4555N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4555N/A * or visit www.oracle.com if you need additional information or have any
4555N/A * questions.
4555N/A */
4555N/A
4555N/A/*
4555N/A * @test
4555N/A * @bug 4031762
4555N/A * @summary Test the primitive wrappers static toString()
4555N/A */
4555N/A
4555N/Aimport java.util.Random;
4555N/A
4555N/Apublic class ToString {
4555N/A
4555N/A private static Random generator = new Random();
4555N/A
4555N/A public static void main(String args[]) throws Exception {
4555N/A // boolean wrapper
4555N/A boolean b = false;
4555N/A Boolean B = new Boolean(b);
4555N/A if (!B.toString().equals(Boolean.toString(b)))
4555N/A throw new RuntimeException("Boolean wrapper toString() failure.");
4555N/A b = true;
4555N/A B = new Boolean(b);
4555N/A if (!B.toString().equals(Boolean.toString(b)))
4555N/A throw new RuntimeException("Boolean wrapper toString() failure.");
4555N/A
4555N/A // char wrapper
4555N/A for(int x=0; x<100; x++) {
4555N/A char c = (char)generator.nextInt();
4555N/A Character C = new Character(c);
4555N/A if (!C.toString().equals(Character.toString(c)))
4555N/A throw new RuntimeException("Character wrapper toString() failure.");
4555N/A }
4555N/A
4555N/A // byte wrapper
4555N/A for(int x=0; x<100; x++) {
4555N/A byte y = (byte)generator.nextInt();
4555N/A Byte Y = new Byte(y);
4555N/A if (!Y.toString().equals(Byte.toString(y)))
4555N/A throw new RuntimeException("Byte wrapper toString() failure.");
4555N/A }
4555N/A
4555N/A // short wrapper
4555N/A for(int x=0; x<100; x++) {
4555N/A short s = (short)generator.nextInt();
4555N/A Short S = new Short(s);
4555N/A if (!S.toString().equals(Short.toString(s)))
4555N/A throw new RuntimeException("Short wrapper toString() failure.");
4555N/A }
4555N/A
4555N/A // int wrapper
4555N/A for(int x=0; x<100; x++) {
4555N/A int i = generator.nextInt();
4555N/A Integer I = new Integer(i);
4555N/A if (!I.toString().equals(Integer.toString(i)))
4555N/A throw new RuntimeException("Integer wrapper toString() failure.");
4555N/A }
4555N/A
4555N/A // long wrapper
4555N/A for(int x=0; x<100; x++) {
4555N/A long l = generator.nextLong();
4555N/A Long L = new Long(l);
4555N/A if (!L.toString().equals(Long.toString(l)))
4555N/A throw new RuntimeException("Long wrapper toString() failure.");
4555N/A }
4555N/A
4555N/A // float wrapper
4555N/A for(int x=0; x<100; x++) {
4555N/A float f = generator.nextFloat();
4555N/A Float F = new Float(f);
4555N/A if (!F.toString().equals(Float.toString(f)))
4555N/A throw new RuntimeException("Float wrapper toString() failure.");
4555N/A }
4555N/A
4555N/A // double wrapper
4555N/A for(int x=0; x<100; x++) {
4555N/A double d = generator.nextDouble();
4555N/A Double D = new Double(d);
4555N/A if (!D.toString().equals(Double.toString(d)))
4555N/A throw new RuntimeException("Double wrapper toString() failure.");
4555N/A }
4555N/A
4555N/A }
4555N/A}
4555N/A