Skip to content

Commit

Permalink
8316696: Remove the testing base classes: IntlTest and CollatorTest
Browse files Browse the repository at this point in the history
Reviewed-by: mdoerr
Backport-of: b859da9
  • Loading branch information
GoeLin committed Jan 18, 2025
1 parent 9db8d28 commit 2d29e1b
Show file tree
Hide file tree
Showing 79 changed files with 3,377 additions and 3,539 deletions.
194 changes: 110 additions & 84 deletions test/jdk/java/text/BreakIterator/BreakIteratorTest.java

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions test/jdk/java/text/BreakIterator/Bug4533872.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -24,18 +24,18 @@
/**
* @test
* @bug 4533872 4640853
* @library /java/text/testlib
* @summary Unit tests for supplementary character support (JSR-204) and Unicode 4.0 support
* @run junit Bug4533872
*/

import java.text.BreakIterator;
import java.util.Locale;

public class Bug4533872 extends IntlTest {
import org.junit.jupiter.api.Test;

public static void main(String[] args) throws Exception {
new Bug4533872().run(args);
}
import static org.junit.jupiter.api.Assertions.fail;

public class Bug4533872 {

static final String[] given = {
/* Lu Nd Lu Ll */
Expand Down Expand Up @@ -73,7 +73,7 @@ void TestNext() {
end = iter.next();

if (!expected[i][j].equals(given[i].substring(start, end))) {
errln("Word break failure: printEachForward() expected:<" +
fail("Word break failure: printEachForward() expected:<" +
expected[i][j] + ">, got:<" +
given[i].substring(start, end) +
"> start=" + start + " end=" + end);
Expand All @@ -95,7 +95,7 @@ void TestIsBoundary() {

while (end < given[i].length()) {
if (!iter.isBoundary(end)) {
errln("Word break failure: isBoundary() This should be a boundary. Index=" +
fail("Word break failure: isBoundary() This should be a boundary. Index=" +
end + " for " + given[i]);
}
end = iter.next();
Expand All @@ -122,7 +122,7 @@ void TestPrintEachForward() {
// Check current()'s return value - should be same as first()'s.
current = iter.current();
if (start != current) {
errln("Word break failure: printEachForward() Unexpected current value: current()=" +
fail("Word break failure: printEachForward() Unexpected current value: current()=" +
current + ", expected(=first())=" + start);
}

Expand All @@ -134,12 +134,12 @@ void TestPrintEachForward() {
// Check current()'s return value - should be same as next()'s.
current = iter.current();
if (end != current) {
errln("Word break failure: printEachForward() Unexpected current value: current()=" +
fail("Word break failure: printEachForward() Unexpected current value: current()=" +
current + ", expected(=next())=" + end);
}

if (!expected[i][j].equals(given[i].substring(start, end))) {
errln("Word break failure: printEachForward() expected:<" +
fail("Word break failure: printEachForward() expected:<" +
expected[i][j] + ">, got:<" +
given[i].substring(start, end) +
"> start=" + start + " end=" + end);
Expand All @@ -161,7 +161,7 @@ void TestPrintEachBackward() {
// Check current()'s return value - should be same as last()'s.
current = iter.current();
if (end != current) {
errln("Word break failure: printEachBackward() Unexpected current value: current()=" +
fail("Word break failure: printEachBackward() Unexpected current value: current()=" +
current + ", expected(=last())=" + end);
}

Expand All @@ -173,12 +173,12 @@ void TestPrintEachBackward() {
// Check current()'s return value - should be same as previous()'s.
current = iter.current();
if (start != current) {
errln("Word break failure: printEachBackward() Unexpected current value: current()=" +
fail("Word break failure: printEachBackward() Unexpected current value: current()=" +
current + ", expected(=previous())=" + start);
}

if (!expected[i][j].equals(given[i].substring(start, end))) {
errln("Word break failure: printEachBackward() expected:<" +
fail("Word break failure: printEachBackward() expected:<" +
expected[i][j] + ">, got:<" +
given[i].substring(start, end) +
"> start=" + start + " end=" + end);
Expand Down Expand Up @@ -207,7 +207,7 @@ void TestPrintAt_1() {
start = iter.previous();

if (!expected[i][j].equals(given[i].substring(start, end))) {
errln("Word break failure: printAt_1() expected:<" +
fail("Word break failure: printAt_1() expected:<" +
expected[i][j] + ">, got:<" +
given[i].substring(start, end) +
"> start=" + start + " end=" + end);
Expand All @@ -234,7 +234,7 @@ void TestPrintAt_2() {

// Check preceding(0)'s return value - should equals BreakIterator.DONE.
if (iter.preceding(0) != BreakIterator.DONE) {
errln("Word break failure: printAt_2() expected:-1(BreakIterator.DONE), got:" +
fail("Word break failure: printAt_2() expected:-1(BreakIterator.DONE), got:" +
iter.preceding(0));
}

Expand All @@ -243,7 +243,7 @@ void TestPrintAt_2() {
end = iter.next();

if (!expected[i][j].equals(given[i].substring(start, end))) {
errln("Word break failure: printAt_2() expected:<" +
fail("Word break failure: printAt_2() expected:<" +
expected[i][j] + ">, got:<" +
given[i].substring(start, end) +
"> start=" + start + " end=" + end);
Expand All @@ -254,7 +254,7 @@ void TestPrintAt_2() {
end = iter.last();
start = iter.next();
if (start != BreakIterator.DONE) {
errln("Word break failure: printAt_2() expected:-1(BreakIterator.DONE), got:" + start);
fail("Word break failure: printAt_2() expected:-1(BreakIterator.DONE), got:" + start);
}
}
}
Expand Down
86 changes: 45 additions & 41 deletions test/jdk/java/text/CharacterIterator/CharacterIteratorTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -23,8 +23,8 @@

/*
* @test
* @library /java/text/testlib
* @summary test for Character Iterator
* @run junit CharacterIteratorTest
*/

/*
Expand Down Expand Up @@ -65,14 +65,15 @@

import java.text.*;

public class CharacterIteratorTest extends IntlTest {
public static void main(String[] args) throws Exception {
new CharacterIteratorTest().run(args);
}
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.fail;

public class CharacterIteratorTest {
public CharacterIteratorTest() {
}

@Test
public void TestConstructionAndEquality() {
String testText = "Now is the time for all good men to come to the aid of their country.";
String testText2 = "Don't bother using this string.";
Expand All @@ -84,49 +85,50 @@ public void TestConstructionAndEquality() {
CharacterIterator test5 = (CharacterIterator)test1.clone();

if (test1.equals(test2) || test1.equals(test3) || test1.equals(test4))
errln("Construation or equals() failed: Two unequal iterators tested equal");
fail("Construation or equals() failed: Two unequal iterators tested equal");

if (!test1.equals(test5))
errln("clone() or equals() failed: Two clones tested unequal");
fail("clone() or equals() failed: Two clones tested unequal");

if (test1.hashCode() == test2.hashCode() || test1.hashCode() == test3.hashCode()
|| test1.hashCode() == test4.hashCode())
errln("hash() failed: different objects have same hash code");
fail("hash() failed: different objects have same hash code");

if (test1.hashCode() != test5.hashCode())
errln("hash() failed: identical objects have different hash codes");
fail("hash() failed: identical objects have different hash codes");

test1.setIndex(5);
if (!test1.equals(test2) || test1.equals(test5))
errln("setIndex() failed");
fail("setIndex() failed");
}

@Test
public void TestIteration() {
String text = "Now is the time for all good men to come to the aid of their country.";

CharacterIterator iter = new StringCharacterIterator(text, 5);

if (iter.current() != text.charAt(5))
errln("Iterator didn't start out in the right place.");
fail("Iterator didn't start out in the right place.");

char c = iter.first();
int i = 0;

if (iter.getBeginIndex() != 0 || iter.getEndIndex() != text.length())
errln("getBeginIndex() or getEndIndex() failed");
fail("getBeginIndex() or getEndIndex() failed");

logln("Testing forward iteration...");
System.out.println("Testing forward iteration...");
do {
if (c == CharacterIterator.DONE && i != text.length())
errln("Iterator reached end prematurely");
fail("Iterator reached end prematurely");
else if (c != text.charAt(i))
errln("Character mismatch at position " + i + ", iterator has " + c +
fail("Character mismatch at position " + i + ", iterator has " + c +
", string has " + text.charAt(c));

if (iter.current() != c)
errln("current() isn't working right");
fail("current() isn't working right");
if (iter.getIndex() != i)
errln("getIndex() isn't working right");
fail("getIndex() isn't working right");

if (c != CharacterIterator.DONE) {
c = iter.next();
Expand All @@ -137,18 +139,18 @@ else if (c != text.charAt(i))
c = iter.last();
i = text.length() - 1;

logln("Testing backward iteration...");
System.out.println("Testing backward iteration...");
do {
if (c == CharacterIterator.DONE && i >= 0)
errln("Iterator reached end prematurely");
fail("Iterator reached end prematurely");
else if (c != text.charAt(i))
errln("Character mismatch at position " + i + ", iterator has " + c +
fail("Character mismatch at position " + i + ", iterator has " + c +
", string has " + text.charAt(c));

if (iter.current() != c)
errln("current() isn't working right");
fail("current() isn't working right");
if (iter.getIndex() != i)
errln("getIndex() isn't working right");
fail("getIndex() isn't working right");

if (c != CharacterIterator.DONE) {
c = iter.previous();
Expand All @@ -158,26 +160,26 @@ else if (c != text.charAt(i))

iter = new StringCharacterIterator(text, 5, 15, 10);
if (iter.getBeginIndex() != 5 || iter.getEndIndex() != 15)
errln("creation of a restricted-range iterator failed");
fail("creation of a restricted-range iterator failed");

if (iter.getIndex() != 10 || iter.current() != text.charAt(10))
errln("starting the iterator in the middle didn't work");
fail("starting the iterator in the middle didn't work");

c = iter.first();
i = 5;

logln("Testing forward iteration over a range...");
System.out.println("Testing forward iteration over a range...");
do {
if (c == CharacterIterator.DONE && i != 15)
errln("Iterator reached end prematurely");
fail("Iterator reached end prematurely");
else if (c != text.charAt(i))
errln("Character mismatch at position " + i + ", iterator has " + c +
fail("Character mismatch at position " + i + ", iterator has " + c +
", string has " + text.charAt(c));

if (iter.current() != c)
errln("current() isn't working right");
fail("current() isn't working right");
if (iter.getIndex() != i)
errln("getIndex() isn't working right");
fail("getIndex() isn't working right");

if (c != CharacterIterator.DONE) {
c = iter.next();
Expand All @@ -188,18 +190,18 @@ else if (c != text.charAt(i))
c = iter.last();
i = 14;

logln("Testing backward iteration over a range...");
System.out.println("Testing backward iteration over a range...");
do {
if (c == CharacterIterator.DONE && i >= 5)
errln("Iterator reached end prematurely");
fail("Iterator reached end prematurely");
else if (c != text.charAt(i))
errln("Character mismatch at position " + i + ", iterator has " + c +
fail("Character mismatch at position " + i + ", iterator has " + c +
", string has " + text.charAt(c));

if (iter.current() != c)
errln("current() isn't working right");
fail("current() isn't working right");
if (iter.getIndex() != i)
errln("getIndex() isn't working right");
fail("getIndex() isn't working right");

if (c != CharacterIterator.DONE) {
c = iter.previous();
Expand All @@ -211,6 +213,7 @@ else if (c != text.charAt(i))
/**
* @bug 4082050 4078261 4078255
*/
@Test
public void TestPathologicalCases() {
String text = "This is only a test.";

Expand All @@ -227,7 +230,7 @@ public void TestPathologicalCases() {
|| iter.previous() != CharacterIterator.DONE
|| iter.current() != CharacterIterator.DONE
|| iter.getIndex() != 5)
errln("Got something other than DONE when performing operations on an empty StringCharacterIterator");
fail("Got something other than DONE when performing operations on an empty StringCharacterIterator");
*/
CharacterIterator iter = null;

Expand All @@ -242,7 +245,7 @@ public void TestPathologicalCases() {
gotException = true;
}
if (!gotException)
errln("StringCharacterIterator didn't throw an exception when given an invalid substring range.");
fail("StringCharacterIterator didn't throw an exception when given an invalid substring range.");

// test for bug #4078255 (getting wrong value from next() when we're at the end
// of the string)
Expand All @@ -253,24 +256,25 @@ public void TestPathologicalCases() {
iter.last();
actualIndex = iter.getIndex();
if (actualIndex != expectedIndex - 1)
errln("last() failed: expected " + (expectedIndex - 1) + ", got " + actualIndex);
fail("last() failed: expected " + (expectedIndex - 1) + ", got " + actualIndex);

iter.next();
actualIndex = iter.getIndex();
if (actualIndex != expectedIndex)
errln("next() after last() failed: expected " + expectedIndex + ", got " + actualIndex);
fail("next() after last() failed: expected " + expectedIndex + ", got " + actualIndex);

iter.next();
actualIndex = iter.getIndex();
if (actualIndex != expectedIndex)
errln("second next() after last() failed: expected " + expectedIndex + ", got " + actualIndex);
fail("second next() after last() failed: expected " + expectedIndex + ", got " + actualIndex);
}

/*
* @bug 4123771 4051073
* #4123771 is actually a duplicate of bug #4051073, which was fixed some time ago, but
* no one ever added a regression test for it.
*/
@Test
public void TestBug4123771() {
String text = "Some string for testing";
StringCharacterIterator iter = new StringCharacterIterator(text);
Expand All @@ -283,7 +287,7 @@ public void TestBug4123771() {
System.out.println(" position: " + index);
System.out.println(" getEndIndex(): " + iter.getEndIndex());
System.out.println(" text.length(): " + text.length());
errln(""); // re-throw the exception through our test framework
fail(""); // re-throw the exception through our test framework
}
}
}
Loading

0 comments on commit 2d29e1b

Please sign in to comment.