summaryrefslogtreecommitdiff
path: root/src/test/java/sevenUnitsGUI/PrefixSearchTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/sevenUnitsGUI/PrefixSearchTest.java')
-rw-r--r--src/test/java/sevenUnitsGUI/PrefixSearchTest.java36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/test/java/sevenUnitsGUI/PrefixSearchTest.java b/src/test/java/sevenUnitsGUI/PrefixSearchTest.java
index 305d0d7..00dd960 100644
--- a/src/test/java/sevenUnitsGUI/PrefixSearchTest.java
+++ b/src/test/java/sevenUnitsGUI/PrefixSearchTest.java
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2022 Adrien Hopkins
+ * Copyright (C) 2022, 2024, 2025 Adrien Hopkins
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -18,6 +18,7 @@ package sevenUnitsGUI;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static sevenUnitsGUI.PrefixSearchRule.COMMON_PREFIXES;
import static sevenUnitsGUI.PrefixSearchRule.NO_PREFIXES;
import static sevenUnitsGUI.PrefixSearchRule.getCoherentOnlyRule;
@@ -35,13 +36,11 @@ import sevenUnits.unit.Metric;
/**
* Tests for {@link PrefixSearchRule}
*
- * @since v0.4.0
* @since 2022-07-17
+ * @since v0.4.0
*/
class PrefixSearchTest {
- /**
- * A method that creates duplicate copies of the common prefix rule.
- */
+ /** A method that creates duplicate copies of the common prefix rule. */
private static final PrefixSearchRule getCommonRuleCopy() {
return getCoherentOnlyRule(Set.of(Metric.KILO, Metric.MILLI));
}
@@ -51,8 +50,8 @@ class PrefixSearchTest {
* {@link sevenUnitsGUI.PrefixSearchRule#apply(java.util.Map.Entry)}, for a
* coherent unit and {@link PrefixSearchRule#COMMON_PREFIXES}.
*
- * @since v0.4.0
* @since 2022-07-17
+ * @since v0.4.0
*/
@Test
final void testCoherentPrefixSearch() {
@@ -69,8 +68,8 @@ class PrefixSearchTest {
* Test method for
* {@link sevenUnitsGUI.PrefixSearchRule#equals(java.lang.Object)}.
*
- * @since v0.4.0
* @since 2022-07-17
+ * @since v0.4.0
*/
@Test
final void testEquals() {
@@ -84,8 +83,8 @@ class PrefixSearchTest {
/**
* Test method for {@link sevenUnitsGUI.PrefixSearchRule#getPrefixes()}.
*
- * @since v0.4.0
* @since 2022-07-17
+ * @since v0.4.0
*/
@Test
final void testGetPrefixes() {
@@ -97,8 +96,8 @@ class PrefixSearchTest {
/**
* Test method for {@link sevenUnitsGUI.PrefixSearchRule#hashCode()}.
*
- * @since v0.4.0
* @since 2022-07-17
+ * @since v0.4.0
*/
@Test
final void testHashCode() {
@@ -109,9 +108,9 @@ class PrefixSearchTest {
/**
* Tests prefix searching for a non-coherent unit and
* {@link PrefixSearchRule#COMMON_PREFIXES}.
- *
- * @since v0.4.0
+ *
* @since 2022-07-17
+ * @since v0.4.0
*/
@Test
final void testNonCoherentPrefixSearch() {
@@ -124,9 +123,9 @@ class PrefixSearchTest {
/**
* Tests that {@link PrefixSearchRule#NO_PREFIXES} returns the original unit.
- *
- * @since v0.4.0
+ *
* @since 2022-07-17
+ * @since v0.4.0
*/
@Test
void testNoPrefixes() {
@@ -145,14 +144,17 @@ class PrefixSearchTest {
/**
* Test method for {@link sevenUnitsGUI.PrefixSearchRule#toString()}.
*
- * @since v0.4.0
* @since 2022-07-17
+ * @since v0.4.0
*/
@Test
final void testToString() {
- assertEquals(
- "Apply the following prefixes: [kilo (\u00D7 1000.0), milli (\u00D7 0.001)]",
- COMMON_PREFIXES.toString());
+ final var toString = COMMON_PREFIXES.toString();
+ final var valid1 = "Apply the following prefixes: [kilo (\u00D7 1000.0), milli (\u00D7 0.001)]";
+ final var valid2 = "Apply the following prefixes: [milli (\u00D7 0.001), kilo (\u00D7 1000.0)]";
+
+ assertTrue(valid1.equals(toString) || valid2.equals(toString),
+ "COMMON_PREFIXES.toString invalid (was \"" + toString + "\").");
}
}