src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements.test/src/org/graalvm/compiler/replacements/test/StringCompareToAVX512Test.java
changeset 58299 6df94ce3ab2f
equal deleted inserted replaced
58298:0152ad7b38b8 58299:6df94ce3ab2f
       
     1 /*
       
     2  * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     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
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  */
       
    23 
       
    24 
       
    25 package org.graalvm.compiler.replacements.test;
       
    26 
       
    27 import org.graalvm.compiler.core.test.GraalCompilerTest;
       
    28 import org.junit.Test;
       
    29 
       
    30 // JDK-8228903
       
    31 public final class StringCompareToAVX512Test extends GraalCompilerTest {
       
    32 
       
    33     public static int compareTo(String str1, String str2) {
       
    34         return str1.compareTo(str2);
       
    35     }
       
    36 
       
    37     @Test
       
    38     public void testLatin1VsUtf16BadStride() {
       
    39         String latin1 = "000000001111111122222222333333334444444455555555666666667777777\u0099888888889";
       
    40         String utf16 = "000000001111111122222222333333334444444455555555666666667777777\u0699888888889";
       
    41         test("compareTo", latin1, utf16);
       
    42         test("compareTo", utf16, latin1);
       
    43     }
       
    44 
       
    45     @Test
       
    46     public void testLatin1VsUtf16BadStride2() {
       
    47         String latin1 = "00000000111111112222222233333333444444445555555566666666777777778888888\u008799999999AAAAAAAAB";
       
    48         String utf16 = "00000000111111112222222233333333444444445555555566666666777777778888888\u058799999999AAAAAAAAB";
       
    49         test("compareTo", latin1, utf16);
       
    50         test("compareTo", utf16, latin1);
       
    51     }
       
    52 
       
    53     @Test
       
    54     public void testLatin1VsUtf16FalseEquality() {
       
    55         // java.lang.AssertionError: expected:<-1536> but was:<0>
       
    56         String latin1 = "00000000111111112222222233333333\u0099444444455555555";
       
    57         String utf16 = "00000000111111112222222233333333\u0699xxxxxxxxxxxxxxx";
       
    58         test("compareTo", latin1, utf16);
       
    59         test("compareTo", utf16, latin1);
       
    60     }
       
    61 
       
    62     @Test
       
    63     public void testLatin1BeyondRange() {
       
    64         StringBuilder latin1Builder = new StringBuilder();
       
    65         for (int j = 0; j <= 255; ++j) {
       
    66             latin1Builder.append((char) j);
       
    67         }
       
    68         String latin1 = latin1Builder.toString();
       
    69         test("compareTo", latin1, String.valueOf(latin1.toCharArray()));
       
    70     }
       
    71 }