Path: blob/master/test/jdk/java/lang/String/CompactString/Numbers.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*/222324import org.testng.annotations.DataProvider;25import org.testng.annotations.Test;2627import static org.testng.Assert.assertEquals;2829/*30* @test31* @bug 807755932* @summary Tests Compact String. This one is testing33* Integer/Long's methods related to String.34* @run testng/othervm -XX:+CompactStrings Numbers35* @run testng/othervm -XX:-CompactStrings Numbers36*/3738public class Numbers {3940/*41* Data provider for testIntegerLong42*43* @return input parameter for testIntegerLong44*/45@DataProvider46public Object[][] numbers() {47return new Object[][] {48{ Integer.toBinaryString(Integer.MAX_VALUE),49"1111111111111111111111111111111" },50{ Integer.toBinaryString(Integer.MIN_VALUE),51"10000000000000000000000000000000" },52{ Integer.toBinaryString(7), "111" },53{ Integer.toBinaryString(0), "0" },54{ Integer.toOctalString(Integer.MAX_VALUE), "17777777777" },55{ Integer.toOctalString(Integer.MIN_VALUE), "20000000000" },56{ Integer.toOctalString(9), "11" },57{ Integer.toOctalString(0), "0" },58{ Integer.toHexString(Integer.MAX_VALUE), "7fffffff" },59{ Integer.toHexString(Integer.MIN_VALUE), "80000000" },60{ Integer.toHexString(17), "11" },61{ Integer.toHexString(0), "0" },62{ Integer.toString(Integer.MAX_VALUE, 2),63"1111111111111111111111111111111" },64{ Integer.toString(Integer.MIN_VALUE, 2),65"-10000000000000000000000000000000" },66{ Integer.toString(7, 2), "111" },67{ Integer.toString(0, 2), "0" },68{ Integer.toString(Integer.MAX_VALUE, 8), "17777777777" },69{ Integer.toString(Integer.MIN_VALUE, 8), "-20000000000" },70{ Integer.toString(9, 8), "11" },71{ Integer.toString(Integer.MAX_VALUE, 16), "7fffffff" },72{ Integer.toString(Integer.MIN_VALUE, 16), "-80000000" },73{ Integer.toString(17, 16), "11" },74{ Long.toBinaryString(Long.MAX_VALUE),75"111111111111111111111111111111111111111111111111111111111111111" },76{ Long.toBinaryString(Long.MIN_VALUE),77"1000000000000000000000000000000000000000000000000000000000000000" },78{ Long.toOctalString(Long.MAX_VALUE), "777777777777777777777" },79{ Long.toOctalString(Long.MIN_VALUE), "1000000000000000000000" },80{ Long.toHexString(Long.MAX_VALUE), "7fffffffffffffff" },81{ Long.toHexString(Long.MIN_VALUE), "8000000000000000" },82{ Long.toString(Long.MAX_VALUE, 2),83"111111111111111111111111111111111111111111111111111111111111111" },84{ Long.toString(Long.MIN_VALUE, 2),85"-1000000000000000000000000000000000000000000000000000000000000000" },86{ Long.toString(Long.MAX_VALUE, 8), "777777777777777777777" },87{ Long.toString(Long.MIN_VALUE, 8), "-1000000000000000000000" },88{ Long.toString(Long.MAX_VALUE, 16), "7fffffffffffffff" },89{ Long.toString(Long.MIN_VALUE, 16), "-8000000000000000" } };90}9192/*93* test Integer/Long's methods related to String.94*95* @param res96* real result97* @param expected98* expected result99*/100@Test(dataProvider = "numbers")101public void testIntegerLong(String res, String expected) {102assertEquals(res, expected);103}104105}106107108