src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/CompressedOopTest.java
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 52910 583fd71c47d6
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
     1 /*
     1 /*
     2  * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   311         HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("stringBuilderTest", Object.class, Object.class);
   311         HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("stringBuilderTest", Object.class, Object.class);
   312         StringBuilder buffer = new StringBuilder("TestTestTestTestTestTestTest");
   312         StringBuilder buffer = new StringBuilder("TestTestTestTestTestTestTest");
   313         Assert.assertTrue(buffer.length() == 28);
   313         Assert.assertTrue(buffer.length() == 28);
   314         String a = new String("TestTestTestTestTestTestTest");
   314         String a = new String("TestTestTestTestTestTestTest");
   315         installedBenchmarkCode.executeVarargs(buffer, a.toCharArray());
   315         installedBenchmarkCode.executeVarargs(buffer, a.toCharArray());
   316         Assert.assertTrue(buffer.length() == 56);
   316         Assert.assertEquals(56, buffer.length());
   317         Assert.assertTrue(buffer.toString().equals("TestTestTestTestTestTestTestTestTestTestTestTestTestTest"));
   317         Assert.assertEquals("TestTestTestTestTestTestTestTestTestTestTestTestTestTest", buffer.toString());
   318     }
   318     }
   319 
   319 
   320     public static void stringBuilderTest(Object c1, Object c2) {
   320     public static void stringBuilderTest(Object c1, Object c2) {
   321         StringBuilder source = (StringBuilder) c1;
   321         StringBuilder source = (StringBuilder) c1;
   322         char[] add = (char[]) c2;
   322         char[] add = (char[]) c2;
   337         String a = new String("TestTestTestTestTestTestTest");
   337         String a = new String("TestTestTestTestTestTestTest");
   338         char[] add = a.toCharArray();
   338         char[] add = a.toCharArray();
   339         for (int i = 0; i < add.length; i++) {
   339         for (int i = 0; i < add.length; i++) {
   340             buffer.append(add[i]);
   340             buffer.append(add[i]);
   341         }
   341         }
   342         Assert.assertTrue(buffer.length() == 56);
   342         Assert.assertEquals(56, buffer.length());
   343         Assert.assertTrue(buffer.toString().equals("TestTestTestTestTestTestTestTestTestTestTestTestTestTest"));
   343         Assert.assertEquals("TestTestTestTestTestTestTestTestTestTestTestTestTestTest", buffer.toString());
   344     }
   344     }
   345 
   345 
   346     @Test
   346     @Test
   347     public void test16() throws Exception {
   347     public void test16() throws Exception {
   348         HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("stringBuilderArrayCopy");
   348         HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("stringBuilderArrayCopy");
   354         Assert.assertTrue(buffer.length() == 28);
   354         Assert.assertTrue(buffer.length() == 28);
   355         String a = new String("TestTestTestTestTestTestTest");
   355         String a = new String("TestTestTestTestTestTestTest");
   356         char[] dst = new char[buffer.length() * 2];
   356         char[] dst = new char[buffer.length() * 2];
   357         System.arraycopy(buffer.toString().toCharArray(), 0, dst, 0, buffer.length());
   357         System.arraycopy(buffer.toString().toCharArray(), 0, dst, 0, buffer.length());
   358         System.arraycopy(a.toCharArray(), 0, dst, buffer.length(), buffer.length());
   358         System.arraycopy(a.toCharArray(), 0, dst, buffer.length(), buffer.length());
   359         Assert.assertTrue(dst.length == 56);
   359         Assert.assertEquals(56, dst.length);
   360         Assert.assertTrue(new String(dst).equals("TestTestTestTestTestTestTestTestTestTestTestTestTestTest"));
   360         Assert.assertEquals("TestTestTestTestTestTestTestTestTestTestTestTestTestTest", new String(dst));
   361     }
   361     }
   362 
   362 
   363     @Test
   363     @Test
   364     public void test17() throws Exception {
   364     public void test17() throws Exception {
   365         HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("stringFormat");
   365         HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("stringFormat");