test/tools/javac/util/StringUtilsTest.java

changeset 2415
7ceaee0e497b
parent 2413
fe033d997ddf
child 2525
2eb010b6cb22
equal deleted inserted replaced
2414:17ce329d7bd0 2415:7ceaee0e497b
1 /* 1 /*
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2013, 2014, 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.
21 * questions. 21 * questions.
22 */ 22 */
23 23
24 /** 24 /**
25 * @test 25 * @test
26 * @bug 8029800 26 * @bug 8029800 8043186
27 * @summary Unit test StringUtils 27 * @summary Unit test StringUtils
28 * @run main StringUtilsTest 28 * @run main StringUtilsTest
29 */ 29 */
30 30
31 import java.util.Locale; 31 import java.util.Locale;
42 42
43 //verify the properties of the default locale: 43 //verify the properties of the default locale:
44 assertEquals("\u0131", "I".toLowerCase()); 44 assertEquals("\u0131", "I".toLowerCase());
45 assertEquals("\u0130", "i".toUpperCase()); 45 assertEquals("\u0130", "i".toUpperCase());
46 46
47 //verify the StringUtils does what it should 47 //verify the StringUtils.toLowerCase/toUpperCase do what they should:
48 assertEquals("i", StringUtils.toLowerCase("I")); 48 assertEquals("i", StringUtils.toLowerCase("I"));
49 assertEquals("I", StringUtils.toUpperCase("i")); 49 assertEquals("I", StringUtils.toUpperCase("i"));
50 50
51 //verify we can use index from indexOf of toLowerCase String in the original: 51 //verify StringUtils.caseInsensitiveIndexOf works:
52 assertEquals(2, StringUtils.toLowerCase("\u0130\u0130lookFor").indexOf("lookfor")); 52 assertEquals(2, StringUtils.indexOfIgnoreCase(" lookFor", "lookfor"));
53 assertEquals(11, StringUtils.indexOfIgnoreCase(" lookFor LOOKfor", "lookfor", 11));
54 assertEquals(2, StringUtils.indexOfIgnoreCase("\u0130\u0130lookFor", "lookfor"));
53 } 55 }
54 56
55 void assertEquals(String expected, String actual) { 57 void assertEquals(String expected, String actual) {
56 if (!Objects.equals(expected, actual)) { 58 if (!Objects.equals(expected, actual)) {
57 throw new IllegalStateException("expected=" + expected + "; actual=" + actual); 59 throw new IllegalStateException("expected=" + expected + "; actual=" + actual);

mercurial