Path: blob/master/test/jdk/java/lang/String/CompactString/ValueOf.java
41152 views
/*1* Copyright (c) 2015, 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*/2223import org.testng.annotations.DataProvider;24import org.testng.annotations.Test;2526import static org.testng.Assert.assertEquals;2728/*29* @test30* @bug 807755931* @summary Tests Compact String. This one is for String.valueOf.32* valueOf(char[] data) is not tested here.33* @run testng/othervm -XX:+CompactStrings ValueOf34* @run testng/othervm -XX:-CompactStrings ValueOf35*/3637public class ValueOf {3839/*40* Data provider for testValueOf41*42* @return input parameter for testValueOf43*/44@DataProvider45public Object[][] valueOfs() {46return new Object[][] { { String.valueOf(true), "true" },47{ String.valueOf(false), "false" },48{ String.valueOf(1.0f), "1.0" },49{ String.valueOf(0.0f), "0.0" },50{ String.valueOf(Float.MAX_VALUE), "3.4028235E38" },51{ String.valueOf(Float.MIN_VALUE), "1.4E-45" },52{ String.valueOf(1.0d), "1.0" },53{ String.valueOf(0.0d), "0.0" },54{ String.valueOf(Double.MAX_VALUE), "1.7976931348623157E308" },55{ String.valueOf(Double.MIN_VALUE), "4.9E-324" },56{ String.valueOf(1), "1" }, { String.valueOf(0), "0" },57{ String.valueOf(Integer.MAX_VALUE), "2147483647" },58{ String.valueOf(Integer.MIN_VALUE), "-2147483648" },59{ String.valueOf(1L), "1" }, { String.valueOf(0L), "0" },60{ String.valueOf(Long.MAX_VALUE), "9223372036854775807" },61{ String.valueOf(Long.MIN_VALUE), "-9223372036854775808" } };62}6364/*65* test String.valueOf(xxx).66*67* @param res68* real result69* @param expected70* expected result71*/72@Test(dataProvider = "valueOfs")73public void testValueOf(String res, String expected) {74assertEquals(res, expected);75}7677}787980