You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2026/04/05 13:55:20 UTC
(commons-text) branch master updated: Use static imports only for JUnit
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git
The following commit(s) were added to refs/heads/master by this push:
new 32fe1c29 Use static imports only for JUnit
32fe1c29 is described below
commit 32fe1c29e2366b37e648b9014b579df2d1cb583a
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Apr 5 09:55:16 2026 -0400
Use static imports only for JUnit
---
...ubstitutorWithInterpolatorStringLookupTest.java | 61 ++++++------
.../commons/text/numbers/DoubleFormatTest.java | 28 +++---
.../commons/text/numbers/ParsedDecimalTest.java | 104 +++++++++++----------
.../text/similarity/IntersectionResultTest.java | 43 +++++----
4 files changed, 124 insertions(+), 112 deletions(-)
diff --git a/src/test/java/org/apache/commons/text/StringSubstitutorWithInterpolatorStringLookupTest.java b/src/test/java/org/apache/commons/text/StringSubstitutorWithInterpolatorStringLookupTest.java
index 8272c01c..56a7b485 100644
--- a/src/test/java/org/apache/commons/text/StringSubstitutorWithInterpolatorStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/StringSubstitutorWithInterpolatorStringLookupTest.java
@@ -18,6 +18,8 @@
package org.apache.commons.text;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.net.InetAddress;
import java.net.UnknownHostException;
@@ -27,7 +29,6 @@ import java.util.Map;
import org.apache.commons.text.lookup.DefaultStringLookup;
import org.apache.commons.text.lookup.StringLookup;
import org.apache.commons.text.lookup.StringLookupFactory;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
class StringSubstitutorWithInterpolatorStringLookupTest {
@@ -58,9 +59,9 @@ class StringSubstitutorWithInterpolatorStringLookupTest {
StringLookupFactory.INSTANCE.interpolatorStringLookup(stringLookupMap, null, addDefaultLookups));
if (addDefaultLookups) {
final String spKey = "user.name";
- Assertions.assertEquals(System.getProperty(spKey), strSubst.replace("${sys:" + spKey + "}"));
+ assertEquals(System.getProperty(spKey), strSubst.replace("${sys:" + spKey + "}"));
}
- Assertions.assertEquals("value", strSubst.replace("${customLookup:key}"));
+ assertEquals("value", strSubst.replace("${customLookup:key}"));
}
@Test
@@ -85,10 +86,10 @@ class StringSubstitutorWithInterpolatorStringLookupTest {
StringLookupFactory.INSTANCE.interpolatorStringLookup(stringLookupMap, null, addDefaultLookups));
if (addDefaultLookups) {
final String spKey = "user.name";
- Assertions.assertEquals(System.getProperty(spKey), strSubst.replace("${sys:" + spKey + "}"));
+ assertEquals(System.getProperty(spKey), strSubst.replace("${sys:" + spKey + "}"));
}
- Assertions.assertEquals("value", strSubst.replace("${customLookup:key}"));
- Assertions.assertEquals("${UnknownLookup:key}", strSubst.replace("${UnknownLookup:key}"));
+ assertEquals("value", strSubst.replace("${customLookup:key}"));
+ assertEquals("${UnknownLookup:key}", strSubst.replace("${UnknownLookup:key}"));
}
@Test
@@ -117,13 +118,13 @@ class StringSubstitutorWithInterpolatorStringLookupTest {
+ "XML XPath: ${xml:src/test/resources/org/apache/commons/text/document.xml:/root/path/to/node}\n"
);
// @formatter:on
- Assertions.assertNotNull(text);
+ assertNotNull(text);
// TEXT-171:
- Assertions.assertFalse(text.contains("${base64Decoder:SGVsbG9Xb3JsZCE=}"));
- Assertions.assertFalse(text.contains("${base64Encoder:HelloWorld!}"));
- Assertions.assertFalse(text.contains("${urlDecoder:Hello%20World%21}"));
- Assertions.assertFalse(text.contains("${urlEncoder:Hello World!}"));
- Assertions.assertFalse(text.contains("${resourceBundle:org.apache.commons.text.example.testResourceBundleLookup:mykey}"));
+ assertFalse(text.contains("${base64Decoder:SGVsbG9Xb3JsZCE=}"));
+ assertFalse(text.contains("${base64Encoder:HelloWorld!}"));
+ assertFalse(text.contains("${urlDecoder:Hello%20World%21}"));
+ assertFalse(text.contains("${urlEncoder:Hello World!}"));
+ assertFalse(text.contains("${resourceBundle:org.apache.commons.text.example.testResourceBundleLookup:mykey}"));
}
@Test
@@ -142,7 +143,7 @@ class StringSubstitutorWithInterpolatorStringLookupTest {
final StringSubstitutor strSubst =
new StringSubstitutor(createInterpolatorWithLookups(DefaultStringLookup.DNS));
final String hostName = InetAddress.getLocalHost().getHostName();
- Assertions.assertEquals(InetAddress.getByName(hostName).getHostAddress(),
+ assertEquals(InetAddress.getByName(hostName).getHostAddress(),
strSubst.replace("${dns:" + hostName + "}"));
}
@@ -151,14 +152,14 @@ class StringSubstitutorWithInterpolatorStringLookupTest {
final StringSubstitutor strSubst = StringSubstitutor.createInterpolator();
final String hostName = InetAddress.getLocalHost().getHostName();
final String input = "${dns:" + hostName + "}";
- Assertions.assertEquals(input, strSubst.replace(input));
+ assertEquals(input, strSubst.replace(input));
}
@Test
void testDnsLookupAddress() throws UnknownHostException {
final StringSubstitutor strSubst =
new StringSubstitutor(createInterpolatorWithLookups(DefaultStringLookup.DNS));
- Assertions.assertEquals(InetAddress.getByName("apache.org").getHostAddress(),
+ assertEquals(InetAddress.getByName("apache.org").getHostAddress(),
strSubst.replace("${dns:address|apache.org}"));
}
@@ -168,7 +169,7 @@ class StringSubstitutorWithInterpolatorStringLookupTest {
new StringSubstitutor(createInterpolatorWithLookups(DefaultStringLookup.DNS));
final String address = InetAddress.getLocalHost().getHostAddress();
final InetAddress inetAddress = InetAddress.getByName(address);
- Assertions.assertEquals(inetAddress.getCanonicalHostName(),
+ assertEquals(inetAddress.getCanonicalHostName(),
strSubst.replace("${dns:canonical-name|" + address + "}"));
}
@@ -178,7 +179,7 @@ class StringSubstitutorWithInterpolatorStringLookupTest {
new StringSubstitutor(createInterpolatorWithLookups(DefaultStringLookup.DNS));
final String address = InetAddress.getLocalHost().getHostAddress();
final InetAddress inetAddress = InetAddress.getByName(address);
- Assertions.assertEquals(inetAddress.getHostName(), strSubst.replace("${dns:name|" + address + "}"));
+ assertEquals(inetAddress.getHostName(), strSubst.replace("${dns:name|" + address + "}"));
}
@Test
@@ -187,7 +188,7 @@ class StringSubstitutorWithInterpolatorStringLookupTest {
new StringSubstitutor(createInterpolatorWithLookups(DefaultStringLookup.DNS));
final String address = InetAddress.getLocalHost().getHostAddress();
final InetAddress inetAddress = InetAddress.getByName(address);
- Assertions.assertEquals(inetAddress.getHostName(), strSubst.replace("${dns:name| " + address + " }"));
+ assertEquals(inetAddress.getHostName(), strSubst.replace("${dns:name| " + address + " }"));
}
@Test
@@ -195,7 +196,7 @@ class StringSubstitutorWithInterpolatorStringLookupTest {
final StringSubstitutor strSubst =
new StringSubstitutor(createInterpolatorWithLookups(DefaultStringLookup.DNS));
final String unknown = "${dns: u n k n o w n}";
- Assertions.assertEquals(unknown, strSubst.replace(unknown));
+ assertEquals(unknown, strSubst.replace(unknown));
}
@Test
@@ -203,34 +204,34 @@ class StringSubstitutorWithInterpolatorStringLookupTest {
final StringSubstitutor strSubst =
new StringSubstitutor(createInterpolatorWithLookups(DefaultStringLookup.SCRIPT));
- Assertions.assertEquals("Hello World!", strSubst.replace("${script:javascript:\"Hello World!\"}"));
- Assertions.assertEquals("7", strSubst.replace("${script:javascript:3 + 4}"));
+ assertEquals("Hello World!", strSubst.replace("${script:javascript:\"Hello World!\"}"));
+ assertEquals("7", strSubst.replace("${script:javascript:3 + 4}"));
}
@Test
void testJavaScript_disabledByDefault() {
final StringSubstitutor strSubst = StringSubstitutor.createInterpolator();
- Assertions.assertEquals("${script:javascript:3 + 4}", strSubst.replace("${script:javascript:3 + 4}"));
+ assertEquals("${script:javascript:3 + 4}", strSubst.replace("${script:javascript:3 + 4}"));
}
@Test
void testLocalHostLookup_Address() throws UnknownHostException {
final StringSubstitutor strSubst = StringSubstitutor.createInterpolator();
- Assertions.assertEquals(InetAddress.getLocalHost().getHostAddress(), strSubst.replace("${localhost:address}"));
+ assertEquals(InetAddress.getLocalHost().getHostAddress(), strSubst.replace("${localhost:address}"));
}
@Test
void testLocalHostLookup_CanonicalName() throws UnknownHostException {
final StringSubstitutor strSubst = StringSubstitutor.createInterpolator();
- Assertions.assertEquals(InetAddress.getLocalHost().getCanonicalHostName(),
+ assertEquals(InetAddress.getLocalHost().getCanonicalHostName(),
strSubst.replace("${localhost:canonical-name}"));
}
@Test
void testLocalHostLookup_Name() throws UnknownHostException {
final StringSubstitutor strSubst = StringSubstitutor.createInterpolator();
- Assertions.assertEquals(InetAddress.getLocalHost().getHostName(), strSubst.replace("${localhost:name}"));
+ assertEquals(InetAddress.getLocalHost().getHostName(), strSubst.replace("${localhost:name}"));
}
@Test
@@ -242,15 +243,15 @@ class StringSubstitutorWithInterpolatorStringLookupTest {
final StringSubstitutor strSubst = new StringSubstitutor(
StringLookupFactory.INSTANCE.interpolatorStringLookup(map));
final String spKey = "user.name";
- Assertions.assertEquals(System.getProperty(spKey), strSubst.replace("${sys:" + spKey + "}"));
- Assertions.assertEquals(value, strSubst.replace("${" + key + "}"));
+ assertEquals(System.getProperty(spKey), strSubst.replace("${sys:" + spKey + "}"));
+ assertEquals(value, strSubst.replace("${" + key + "}"));
}
@Test
void testSystemProperty() {
final StringSubstitutor strSubst = StringSubstitutor.createInterpolator();
final String spKey = "user.name";
- Assertions.assertEquals(System.getProperty(spKey), strSubst.replace("${sys:" + spKey + "}"));
+ assertEquals(System.getProperty(spKey), strSubst.replace("${sys:" + spKey + "}"));
}
@Test
@@ -258,7 +259,7 @@ class StringSubstitutorWithInterpolatorStringLookupTest {
final StringSubstitutor strSubst = new StringSubstitutor(
StringLookupFactory.INSTANCE.interpolatorStringLookup(StringLookupFactory.INSTANCE.systemPropertyStringLookup()));
final String spKey = "user.name";
- Assertions.assertEquals(System.getProperty(spKey), strSubst.replace("${" + spKey + "}"));
- Assertions.assertEquals(System.getProperty(spKey), strSubst.replace("${sys:" + spKey + "}"));
+ assertEquals(System.getProperty(spKey), strSubst.replace("${" + spKey + "}"));
+ assertEquals(System.getProperty(spKey), strSubst.replace("${sys:" + spKey + "}"));
}
}
diff --git a/src/test/java/org/apache/commons/text/numbers/DoubleFormatTest.java b/src/test/java/org/apache/commons/text/numbers/DoubleFormatTest.java
index e0fb1b96..8217f872 100644
--- a/src/test/java/org/apache/commons/text/numbers/DoubleFormatTest.java
+++ b/src/test/java/org/apache/commons/text/numbers/DoubleFormatTest.java
@@ -16,6 +16,9 @@
*/
package org.apache.commons.text.numbers;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Locale;
@@ -24,7 +27,6 @@ import java.util.function.DoubleFunction;
import java.util.function.Function;
import java.util.stream.Stream;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
@@ -42,7 +44,7 @@ class DoubleFormatTest {
final String fmtStr = trimFormatChars(fmt.apply(d));
try {
- Assertions.assertEquals(dfStr, fmtStr,
+ assertEquals(dfStr, fmtStr,
() -> "Unexpected output for locale [" + loc.toLanguageTag() + "] and double value " + d);
} catch (final AssertionError e) {
// Note:
@@ -74,7 +76,7 @@ class DoubleFormatTest {
}
private static void checkFormat(final DoubleFunction<String> fmt, final double d, final String str) {
- Assertions.assertEquals(str, fmt.apply(d));
+ assertEquals(str, fmt.apply(d));
}
/**
@@ -86,7 +88,7 @@ class DoubleFormatTest {
private static void checkFormatAccuracy(final DoubleFunction<String> fmt, final double d) {
final String str = fmt.apply(d);
final double parsed = Double.parseDouble(str);
- Assertions.assertEquals(d, parsed, () -> "Formatted double string [" + str + "] did not match input value");
+ assertEquals(d, parsed, () -> "Formatted double string [" + str + "] did not match input value");
}
/**
@@ -217,14 +219,14 @@ class DoubleFormatTest {
final DoubleFormat.Builder builder = DoubleFormat.PLAIN.builder();
// act/assert
- Assertions.assertThrows(NullPointerException.class, () -> builder.digits(null));
- Assertions.assertThrows(IllegalArgumentException.class, () -> builder.digits("a"));
- Assertions.assertThrows(IllegalArgumentException.class, () -> builder.digits("0123456789a"));
-
- Assertions.assertThrows(NullPointerException.class, () -> builder.exponentSeparator(null));
- Assertions.assertThrows(NullPointerException.class, () -> builder.infinity(null));
- Assertions.assertThrows(NullPointerException.class, () -> builder.nan(null));
- Assertions.assertThrows(NullPointerException.class, () -> builder.formatSymbols(null));
+ assertThrows(NullPointerException.class, () -> builder.digits(null));
+ assertThrows(IllegalArgumentException.class, () -> builder.digits("a"));
+ assertThrows(IllegalArgumentException.class, () -> builder.digits("0123456789a"));
+
+ assertThrows(NullPointerException.class, () -> builder.exponentSeparator(null));
+ assertThrows(NullPointerException.class, () -> builder.infinity(null));
+ assertThrows(NullPointerException.class, () -> builder.nan(null));
+ assertThrows(NullPointerException.class, () -> builder.formatSymbols(null));
}
@Test
@@ -363,7 +365,7 @@ class DoubleFormatTest {
void testMaximumPrecision(final DoubleFunction<String> fmt, final double value) {
final String s = fmt.apply(value);
final double d = Double.parseDouble(s);
- Assertions.assertEquals(value, d, () -> value + " formatted as " + s);
+ assertEquals(value, d, () -> value + " formatted as " + s);
}
@Test
diff --git a/src/test/java/org/apache/commons/text/numbers/ParsedDecimalTest.java b/src/test/java/org/apache/commons/text/numbers/ParsedDecimalTest.java
index 187d32fc..7a073f6b 100644
--- a/src/test/java/org/apache/commons/text/numbers/ParsedDecimalTest.java
+++ b/src/test/java/org/apache/commons/text/numbers/ParsedDecimalTest.java
@@ -16,6 +16,11 @@
*/
package org.apache.commons.text.numbers;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
@@ -23,7 +28,6 @@ import java.util.function.BiFunction;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;
@@ -149,17 +153,17 @@ class ParsedDecimalTest {
private static void assertSimpleDecimal(final ParsedDecimal parsed, final boolean negative, final String digits,
final int exponent) {
- Assertions.assertEquals(negative, parsed.negative);
- Assertions.assertEquals(digits, digitString(parsed));
- Assertions.assertEquals(exponent, parsed.getExponent());
- Assertions.assertEquals(digits.length(), parsed.digitCount);
- Assertions.assertEquals(exponent, parsed.getScientificExponent() - digits.length() + 1);
+ assertEquals(negative, parsed.negative);
+ assertEquals(digits, digitString(parsed));
+ assertEquals(exponent, parsed.getExponent());
+ assertEquals(digits.length(), parsed.digitCount);
+ assertEquals(exponent, parsed.getScientificExponent() - digits.length() + 1);
}
private static void assertThrowsWithMessage(final Executable fn, final Class<? extends Throwable> type,
final String msg) {
- final Throwable exc = Assertions.assertThrows(type, fn);
- Assertions.assertEquals(msg, exc.getMessage());
+ final Throwable exc = assertThrows(type, fn);
+ assertEquals(msg, exc.getMessage());
}
private static void checkFrom(final double d, final String digits, final int exponent) {
@@ -175,10 +179,10 @@ class ParsedDecimalTest {
// check the exponent value to make sure it is a multiple of 3
final String pos = ParsedDecimal.from(d).toEngineeringString(opts);
- Assertions.assertEquals(0, parseExponent(pos, opts) % 3);
+ assertEquals(0, parseExponent(pos, opts) % 3);
final String neg = ParsedDecimal.from(-d).toEngineeringString(opts);
- Assertions.assertEquals(0, parseExponent(neg, opts) % 3);
+ assertEquals(0, parseExponent(neg, opts) % 3);
}
private static void checkToPlainString(final double d, final String expected,
@@ -198,7 +202,7 @@ class ParsedDecimalTest {
final ParsedDecimal pos = ParsedDecimal.from(d);
final String actual = fn.apply(pos, opts);
- Assertions.assertEquals(expected, actual);
+ assertEquals(expected, actual);
}
private static double createRandomDouble(final UniformRandomProvider rng) {
@@ -302,17 +306,17 @@ class ParsedDecimalTest {
@Test
void testIsZero() {
// act/assert
- Assertions.assertTrue(ParsedDecimal.from(0.0).isZero());
- Assertions.assertTrue(ParsedDecimal.from(-0.0).isZero());
+ assertTrue(ParsedDecimal.from(0.0).isZero());
+ assertTrue(ParsedDecimal.from(-0.0).isZero());
- Assertions.assertFalse(ParsedDecimal.from(1.0).isZero());
- Assertions.assertFalse(ParsedDecimal.from(-1.0).isZero());
+ assertFalse(ParsedDecimal.from(1.0).isZero());
+ assertFalse(ParsedDecimal.from(-1.0).isZero());
- Assertions.assertFalse(ParsedDecimal.from(Double.MIN_NORMAL).isZero());
- Assertions.assertFalse(ParsedDecimal.from(-Double.MIN_NORMAL).isZero());
+ assertFalse(ParsedDecimal.from(Double.MIN_NORMAL).isZero());
+ assertFalse(ParsedDecimal.from(-Double.MIN_NORMAL).isZero());
- Assertions.assertFalse(ParsedDecimal.from(Double.MAX_VALUE).isZero());
- Assertions.assertFalse(ParsedDecimal.from(-Double.MIN_VALUE).isZero());
+ assertFalse(ParsedDecimal.from(Double.MAX_VALUE).isZero());
+ assertFalse(ParsedDecimal.from(-Double.MIN_VALUE).isZero());
}
@Test
@@ -387,7 +391,7 @@ class ParsedDecimalTest {
dec.maxPrecision(precision);
// assert
- Assertions.assertEquals(new BigDecimal(Double.toString(d), ctx).doubleValue(),
+ assertEquals(new BigDecimal(Double.toString(d), ctx).doubleValue(),
Double.parseDouble(dec.toScientificString(opts)));
}
}
@@ -492,14 +496,14 @@ class ParsedDecimalTest {
d = createRandomDouble(rand);
// act/assert
- Assertions.assertEquals(d, Double.parseDouble(ParsedDecimal.from(d).toScientificString(stdOpts)));
- Assertions.assertEquals(d, Double.parseDouble(ParsedDecimal.from(d).toScientificString(altOpts)));
+ assertEquals(d, Double.parseDouble(ParsedDecimal.from(d).toScientificString(stdOpts)));
+ assertEquals(d, Double.parseDouble(ParsedDecimal.from(d).toScientificString(altOpts)));
- Assertions.assertEquals(d, Double.parseDouble(ParsedDecimal.from(d).toEngineeringString(stdOpts)));
- Assertions.assertEquals(d, Double.parseDouble(ParsedDecimal.from(d).toEngineeringString(altOpts)));
+ assertEquals(d, Double.parseDouble(ParsedDecimal.from(d).toEngineeringString(stdOpts)));
+ assertEquals(d, Double.parseDouble(ParsedDecimal.from(d).toEngineeringString(altOpts)));
- Assertions.assertEquals(d, Double.parseDouble(ParsedDecimal.from(d).toPlainString(stdOpts)));
- Assertions.assertEquals(d, Double.parseDouble(ParsedDecimal.from(d).toPlainString(altOpts)));
+ assertEquals(d, Double.parseDouble(ParsedDecimal.from(d).toPlainString(stdOpts)));
+ assertEquals(d, Double.parseDouble(ParsedDecimal.from(d).toPlainString(altOpts)));
}
}
@@ -515,18 +519,18 @@ class ParsedDecimalTest {
altOpts.setExponentSeparator("e");
altOpts.setIncludeFractionPlaceholder(false);
- Assertions.assertEquals(10.0, Double.parseDouble(ParsedDecimal.from(10.0).toScientificString(stdOpts)));
+ assertEquals(10.0, Double.parseDouble(ParsedDecimal.from(10.0).toScientificString(stdOpts)));
for (double d = min; d <= max; d += delta) {
// act/assert
- Assertions.assertEquals(d, Double.parseDouble(ParsedDecimal.from(d).toScientificString(stdOpts)));
- Assertions.assertEquals(d, Double.parseDouble(ParsedDecimal.from(d).toScientificString(altOpts)));
+ assertEquals(d, Double.parseDouble(ParsedDecimal.from(d).toScientificString(stdOpts)));
+ assertEquals(d, Double.parseDouble(ParsedDecimal.from(d).toScientificString(altOpts)));
- Assertions.assertEquals(d, Double.parseDouble(ParsedDecimal.from(d).toEngineeringString(stdOpts)));
- Assertions.assertEquals(d, Double.parseDouble(ParsedDecimal.from(d).toEngineeringString(altOpts)));
+ assertEquals(d, Double.parseDouble(ParsedDecimal.from(d).toEngineeringString(stdOpts)));
+ assertEquals(d, Double.parseDouble(ParsedDecimal.from(d).toEngineeringString(altOpts)));
- Assertions.assertEquals(d, Double.parseDouble(ParsedDecimal.from(d).toPlainString(stdOpts)));
- Assertions.assertEquals(d, Double.parseDouble(ParsedDecimal.from(d).toPlainString(altOpts)));
+ assertEquals(d, Double.parseDouble(ParsedDecimal.from(d).toPlainString(stdOpts)));
+ assertEquals(d, Double.parseDouble(ParsedDecimal.from(d).toPlainString(altOpts)));
}
}
@@ -537,23 +541,23 @@ class ParsedDecimalTest {
opts.setDigitsFromString("abcdefghij");
// act/assert
- Assertions.assertEquals("b.a", ParsedDecimal.from(1.0).toPlainString(opts));
- Assertions.assertEquals("-a.abcd", ParsedDecimal.from(-0.0123).toPlainString(opts));
- Assertions.assertEquals("bc.de", ParsedDecimal.from(12.34).toPlainString(opts));
- Assertions.assertEquals("baaaa.a", ParsedDecimal.from(10000).toPlainString(opts));
- Assertions.assertEquals("jihgfedcba.a", ParsedDecimal.from(9876543210d).toPlainString(opts));
-
- Assertions.assertEquals("b.a", ParsedDecimal.from(1.0).toScientificString(opts));
- Assertions.assertEquals("-b.cdE-c", ParsedDecimal.from(-0.0123).toScientificString(opts));
- Assertions.assertEquals("b.cdeEb", ParsedDecimal.from(12.34).toScientificString(opts));
- Assertions.assertEquals("b.aEe", ParsedDecimal.from(10000).toScientificString(opts));
- Assertions.assertEquals("j.ihgfedcbEj", ParsedDecimal.from(9876543210d).toScientificString(opts));
-
- Assertions.assertEquals("b.a", ParsedDecimal.from(1.0).toEngineeringString(opts));
- Assertions.assertEquals("-bc.dE-d", ParsedDecimal.from(-0.0123).toEngineeringString(opts));
- Assertions.assertEquals("bc.de", ParsedDecimal.from(12.34).toEngineeringString(opts));
- Assertions.assertEquals("ba.aEd", ParsedDecimal.from(10000).toEngineeringString(opts));
- Assertions.assertEquals("j.ihgfedcbEj", ParsedDecimal.from(9876543210d).toEngineeringString(opts));
+ assertEquals("b.a", ParsedDecimal.from(1.0).toPlainString(opts));
+ assertEquals("-a.abcd", ParsedDecimal.from(-0.0123).toPlainString(opts));
+ assertEquals("bc.de", ParsedDecimal.from(12.34).toPlainString(opts));
+ assertEquals("baaaa.a", ParsedDecimal.from(10000).toPlainString(opts));
+ assertEquals("jihgfedcba.a", ParsedDecimal.from(9876543210d).toPlainString(opts));
+
+ assertEquals("b.a", ParsedDecimal.from(1.0).toScientificString(opts));
+ assertEquals("-b.cdE-c", ParsedDecimal.from(-0.0123).toScientificString(opts));
+ assertEquals("b.cdeEb", ParsedDecimal.from(12.34).toScientificString(opts));
+ assertEquals("b.aEe", ParsedDecimal.from(10000).toScientificString(opts));
+ assertEquals("j.ihgfedcbEj", ParsedDecimal.from(9876543210d).toScientificString(opts));
+
+ assertEquals("b.a", ParsedDecimal.from(1.0).toEngineeringString(opts));
+ assertEquals("-bc.dE-d", ParsedDecimal.from(-0.0123).toEngineeringString(opts));
+ assertEquals("bc.de", ParsedDecimal.from(12.34).toEngineeringString(opts));
+ assertEquals("ba.aEd", ParsedDecimal.from(10000).toEngineeringString(opts));
+ assertEquals("j.ihgfedcbEj", ParsedDecimal.from(9876543210d).toEngineeringString(opts));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/similarity/IntersectionResultTest.java b/src/test/java/org/apache/commons/text/similarity/IntersectionResultTest.java
index 70230b86..7e069be8 100644
--- a/src/test/java/org/apache/commons/text/similarity/IntersectionResultTest.java
+++ b/src/test/java/org/apache/commons/text/similarity/IntersectionResultTest.java
@@ -16,10 +16,15 @@
*/
package org.apache.commons.text.similarity;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.util.HashMap;
import java.util.concurrent.ThreadLocalRandom;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
@@ -36,18 +41,18 @@ class IntersectionResultTest {
};
// Test a different instance with same values
- Assertions.assertEquals(new IntersectionResult(0, 0, 0), results[0]);
+ assertEquals(new IntersectionResult(0, 0, 0), results[0]);
final Object something = new Object();
for (int i = 0; i < results.length; i++) {
- Assertions.assertNotEquals(results[i], something);
- Assertions.assertNotEquals(null, results[i]);
+ assertNotEquals(results[i], something);
+ assertNotEquals(null, results[i]);
for (int j = 0; j < results.length; j++) {
- Assertions.assertEquals(results[i].equals(results[j]), i == j);
+ assertEquals(results[i].equals(results[j]), i == j);
}
- Assertions.assertFalse(results[i].equals(null), "Should not be Equal to null");
- Assertions.assertNotEquals("Test", results[i], "Should not be Equal to a different type of object");
+ assertFalse(results[i].equals(null), "Should not be Equal to null");
+ assertNotEquals("Test", results[i], "Should not be Equal to a different type of object");
}
}
@@ -64,7 +69,7 @@ class IntersectionResultTest {
map.put(results[i], i + offset);
}
for (int i = 0; i < results.length; i++) {
- Assertions.assertEquals(i + offset, map.get(results[i]));
+ assertEquals(i + offset, map.get(results[i]));
}
}
@@ -73,8 +78,8 @@ class IntersectionResultTest {
final int sizeA = 1;
final int sizeB = 2;
final int intersection = Math.max(sizeA, sizeB) + 1;
- Assertions.assertThrows(IllegalArgumentException.class, () -> new IntersectionResult(sizeA, sizeB, intersection));
- Assertions.assertThrows(IllegalArgumentException.class, () -> new IntersectionResult(sizeB, sizeA, intersection));
+ assertThrows(IllegalArgumentException.class, () -> new IntersectionResult(sizeA, sizeB, intersection));
+ assertThrows(IllegalArgumentException.class, () -> new IntersectionResult(sizeB, sizeA, intersection));
}
@Test
@@ -82,7 +87,7 @@ class IntersectionResultTest {
final int sizeA = 0;
final int sizeB = 0;
final int intersection = -1;
- Assertions.assertThrows(IllegalArgumentException.class, () -> new IntersectionResult(sizeA, sizeB, intersection));
+ assertThrows(IllegalArgumentException.class, () -> new IntersectionResult(sizeA, sizeB, intersection));
}
@Test
@@ -90,7 +95,7 @@ class IntersectionResultTest {
final int sizeA = -1;
final int sizeB = 0;
final int intersection = 0;
- Assertions.assertThrows(IllegalArgumentException.class, () -> new IntersectionResult(sizeA, sizeB, intersection));
+ assertThrows(IllegalArgumentException.class, () -> new IntersectionResult(sizeA, sizeB, intersection));
}
@Test
@@ -98,7 +103,7 @@ class IntersectionResultTest {
final int sizeA = 0;
final int sizeB = -1;
final int intersection = 0;
- Assertions.assertThrows(IllegalArgumentException.class, () -> new IntersectionResult(sizeA, sizeB, intersection));
+ assertThrows(IllegalArgumentException.class, () -> new IntersectionResult(sizeA, sizeB, intersection));
}
@Test
@@ -119,9 +124,9 @@ class IntersectionResultTest {
final int sizeB = rand.nextInt(max) + 1;
final int intersection = rand.nextInt(Math.min(sizeA, sizeB));
final IntersectionResult result = new IntersectionResult(sizeA, sizeB, intersection);
- Assertions.assertEquals(sizeA, result.getSizeA());
- Assertions.assertEquals(sizeB, result.getSizeB());
- Assertions.assertEquals(intersection, result.getIntersection());
+ assertEquals(sizeA, result.getSizeA());
+ assertEquals(sizeB, result.getSizeB());
+ assertEquals(intersection, result.getIntersection());
}
}
@@ -138,9 +143,9 @@ class IntersectionResultTest {
final String string = result.toString();
// Not perfect as this will match substrings too. The chance of error
// is limited by restricting the numbers to a max of 10.
- Assertions.assertTrue(string.contains(String.valueOf(sizeA)));
- Assertions.assertTrue(string.contains(String.valueOf(sizeB)));
- Assertions.assertTrue(string.contains(String.valueOf(intersection)));
+ assertTrue(string.contains(String.valueOf(sizeA)));
+ assertTrue(string.contains(String.valueOf(sizeB)));
+ assertTrue(string.contains(String.valueOf(intersection)));
}
}
}