This is an automated email from the ASF dual-hosted git repository.

garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-codec.git


The following commit(s) were added to refs/heads/master by this push:
     new 5cc69188 Sort members.
5cc69188 is described below

commit 5cc69188a20ac46d6f596b636e4ba22b3a7edef0
Author: Gary Gregory <[email protected]>
AuthorDate: Sun Aug 16 20:01:29 2026 -0400

    Sort members.
---
 .../language/bm/PhoneticEngineBuilderTest.java     | 230 ++++++++++-----------
 1 file changed, 115 insertions(+), 115 deletions(-)

diff --git 
a/src/test/java/org/apache/commons/codec/language/bm/PhoneticEngineBuilderTest.java
 
b/src/test/java/org/apache/commons/codec/language/bm/PhoneticEngineBuilderTest.java
index d4643b46..ee80d081 100644
--- 
a/src/test/java/org/apache/commons/codec/language/bm/PhoneticEngineBuilderTest.java
+++ 
b/src/test/java/org/apache/commons/codec/language/bm/PhoneticEngineBuilderTest.java
@@ -34,6 +34,18 @@ import org.junit.jupiter.api.Test;
  */
 class PhoneticEngineBuilderTest {
 
+    /**
+     * Returns a string of {@code 'a'} characters with the given length, 
compatible with Java 8.
+     *
+     * @param length the desired length.
+     * @return a string of the specified length filled with {@code 'a'}.
+     */
+    private static String repeat(final int length) {
+        final char[] chars = new char[length];
+        java.util.Arrays.fill(chars, 'a');
+        return new String(chars);
+    }
+
     /**
      * Tests that the builder produces a non-null {@link PhoneticEngine}.
      */
@@ -59,6 +71,28 @@ class PhoneticEngineBuilderTest {
         assertNotSame(PhoneticEngine.builder(), PhoneticEngine.builder());
     }
 
+    /**
+     * Tests that the default maximum input length (666) allows input of 
exactly that length to be encoded without throwing.
+     */
+    @Test
+    void testDefaultMaxInputLengthAllowsInputAtLimit() {
+        // Default max input length is 666 (Hubert Blaine 
Wolfeschlegelsteinhausenbergerdorff Sr.)
+        final PhoneticEngine engine = PhoneticEngine.builder().get();
+        final String input = repeat(666);
+        assertDoesNotThrow(() -> engine.encode(input));
+    }
+
+    /**
+     * Tests that the default maximum input length (666) causes an {@link 
IllegalArgumentException}
+     * when input exceeds that limit.
+     */
+    @Test
+    void testDefaultMaxInputLengthRejectsInputBeyondLimit() {
+        final PhoneticEngine engine = PhoneticEngine.builder().get();
+        final String input = repeat(667);
+        assertThrows(IllegalArgumentException.class, () -> 
engine.encode(input));
+    }
+
     /**
      * Tests the default values of the builder.
      */
@@ -188,187 +222,153 @@ class PhoneticEngineBuilderTest {
     }
 
     /**
-     * Tests {@link PhoneticEngine.Builder#setMaxPhonemes(int)}.
-     */
-    @Test
-    void testSetMaxPhonemes() {
-        final int maxPhonemes = 10;
-        final PhoneticEngine engine = 
PhoneticEngine.builder().setMaxPhonemes(maxPhonemes).get();
-        assertEquals(maxPhonemes, engine.getMaxPhonemes());
-    }
-
-    /**
-     * Tests {@link PhoneticEngine.Builder#setMaxPhonemes(int)} with {@link 
Integer#MAX_VALUE}.
-     */
-    @Test
-    void testSetMaxPhonemesMaxValue() {
-        final PhoneticEngine engine = 
PhoneticEngine.builder().setMaxPhonemes(Integer.MAX_VALUE).get();
-        assertEquals(Integer.MAX_VALUE, engine.getMaxPhonemes());
-    }
-
-    /**
-     * Tests {@link PhoneticEngine.Builder#setNameType(NameType)} with 
ASHKENAZI.
+     * Tests {@link PhoneticEngine.Builder#setMaxInputLength(int)} with a 
custom value:
+     * input exactly at the limit is accepted.
      */
     @Test
-    void testSetNameTypeAshkenazi() {
-        final PhoneticEngine engine = 
PhoneticEngine.builder().setNameType(NameType.ASHKENAZI).get();
-        assertEquals(NameType.ASHKENAZI, engine.getNameType());
+    void testSetMaxInputLengthAllowsInputAtCustomLimit() {
+        final int customLimit = 10;
+        final PhoneticEngine engine = 
PhoneticEngine.builder().setMaxInputLength(customLimit).get();
+        final String input = repeat(customLimit);
+        assertDoesNotThrow(() -> engine.encode(input));
     }
 
     /**
-     * Tests {@link PhoneticEngine.Builder#setNameType(NameType)}.
+     * Tests that {@link PhoneticEngine.Builder#setMaxInputLength(int)} with 
{@link Integer#MAX_VALUE}
+     * allows very long input.
      */
     @Test
-    void testSetNameTypeGeneric() {
-        final PhoneticEngine engine = 
PhoneticEngine.builder().setNameType(NameType.GENERIC).get();
-        assertEquals(NameType.GENERIC, engine.getNameType());
+    void testSetMaxInputLengthMaxValue() {
+        final PhoneticEngine engine = 
PhoneticEngine.builder().setMaxInputLength(Integer.MAX_VALUE).get();
+        // A very long string should not trigger the length check
+        final String input = repeat(10_000);
+        assertDoesNotThrow(() -> engine.encode(input));
     }
 
     /**
-     * Tests {@link PhoneticEngine.Builder#setNameType(NameType)} with 
SEPHARDIC.
+     * Tests {@link PhoneticEngine.Builder#setMaxInputLength(int)} with a 
custom value:
+     * input one character beyond the limit is rejected with {@link 
IllegalArgumentException}.
      */
     @Test
-    void testSetNameTypeSephardic() {
-        final PhoneticEngine engine = 
PhoneticEngine.builder().setNameType(NameType.SEPHARDIC).get();
-        assertEquals(NameType.SEPHARDIC, engine.getNameType());
+    void testSetMaxInputLengthRejectsInputBeyondCustomLimit() {
+        final int customLimit = 10;
+        final PhoneticEngine engine = 
PhoneticEngine.builder().setMaxInputLength(customLimit).get();
+        final String input = repeat(customLimit + 1);
+        assertThrows(IllegalArgumentException.class, () -> 
engine.encode(input));
     }
 
     /**
-     * Tests {@link PhoneticEngine.Builder#setRuleType(RuleType)} with APPROX.
+     * Tests {@link PhoneticEngine.Builder#setMaxInputLength(int)} that the 
setter returns
+     * the same builder instance to enable method chaining.
      */
     @Test
-    void testSetRuleTypeApprox() {
-        final PhoneticEngine engine = 
PhoneticEngine.builder().setRuleType(RuleType.APPROX).get();
-        assertEquals(RuleType.APPROX, engine.getRuleType());
+    void testSetMaxInputLengthReturnsBuilder() {
+        final PhoneticEngine.Builder builder = PhoneticEngine.builder();
+        assertNotNull(builder.setMaxInputLength(100));
     }
 
     /**
-     * Tests {@link PhoneticEngine.Builder#setRuleType(RuleType)} with EXACT.
+     * Tests that {@link PhoneticEngine.Builder#setMaxInputLength(int)} can be 
combined
+     * with other builder settings and still produces a valid engine.
      */
     @Test
-    void testSetRuleTypeExact() {
-        final PhoneticEngine engine = 
PhoneticEngine.builder().setRuleType(RuleType.EXACT).get();
-        assertEquals(RuleType.EXACT, engine.getRuleType());
-    }
-
-    /**
-     * Returns a string of {@code 'a'} characters with the given length, 
compatible with Java 8.
-     *
-     * @param length the desired length.
-     * @return a string of the specified length filled with {@code 'a'}.
-     */
-    private static String repeat(final int length) {
-        final char[] chars = new char[length];
-        java.util.Arrays.fill(chars, 'a');
-        return new String(chars);
+    void testSetMaxInputLengthWithOtherSettings() {
+        // @formatter:off
+        final PhoneticEngine engine = PhoneticEngine.builder()
+                .setNameType(NameType.ASHKENAZI)
+                .setRuleType(RuleType.APPROX)
+                .setConcat(true)
+                .setMaxPhonemes(10)
+                .setMaxInputLength(5)
+                .get();
+        // @formatter:on
+        assertNotNull(engine);
+        assertDoesNotThrow(() -> engine.encode("abcde"));
+        assertThrows(IllegalArgumentException.class, () -> 
engine.encode("abcdef"));
     }
 
     /**
-     * Tests that the default maximum input length (666) allows input of 
exactly that length to be encoded without throwing.
+     * Tests {@link PhoneticEngine.Builder#setMaxInputLength(int)} with a 
limit of 0:
+     * null input bypasses the length check but causes a {@link 
NullPointerException} downstream.
      */
     @Test
-    void testDefaultMaxInputLengthAllowsInputAtLimit() {
-        // Default max input length is 666 (Hubert Blaine 
Wolfeschlegelsteinhausenbergerdorff Sr.)
-        final PhoneticEngine engine = PhoneticEngine.builder().get();
-        final String input = repeat(666);
-        assertDoesNotThrow(() -> engine.encode(input));
+    void testSetMaxInputLengthZeroNullInputThrowsNpe() {
+        final PhoneticEngine engine = 
PhoneticEngine.builder().setMaxInputLength(0).get();
+        // null is not blocked by the length check, but encoding null causes 
NPE
+        assertThrows(NullPointerException.class, () -> engine.encode(null));
     }
 
     /**
-     * Tests that the default maximum input length (666) causes an {@link 
IllegalArgumentException}
-     * when input exceeds that limit.
+     * Tests {@link PhoneticEngine.Builder#setMaxInputLength(int)} with a 
limit of 0:
+     * any non-empty input is rejected.
      */
     @Test
-    void testDefaultMaxInputLengthRejectsInputBeyondLimit() {
-        final PhoneticEngine engine = PhoneticEngine.builder().get();
-        final String input = repeat(667);
-        assertThrows(IllegalArgumentException.class, () -> 
engine.encode(input));
+    void testSetMaxInputLengthZeroRejectsAnyInput() {
+        final PhoneticEngine engine = 
PhoneticEngine.builder().setMaxInputLength(0).get();
+        assertThrows(IllegalArgumentException.class, () -> engine.encode("a"));
     }
 
     /**
-     * Tests {@link PhoneticEngine.Builder#setMaxInputLength(int)} with a 
custom value:
-     * input exactly at the limit is accepted.
+     * Tests {@link PhoneticEngine.Builder#setMaxPhonemes(int)}.
      */
     @Test
-    void testSetMaxInputLengthAllowsInputAtCustomLimit() {
-        final int customLimit = 10;
-        final PhoneticEngine engine = 
PhoneticEngine.builder().setMaxInputLength(customLimit).get();
-        final String input = repeat(customLimit);
-        assertDoesNotThrow(() -> engine.encode(input));
+    void testSetMaxPhonemes() {
+        final int maxPhonemes = 10;
+        final PhoneticEngine engine = 
PhoneticEngine.builder().setMaxPhonemes(maxPhonemes).get();
+        assertEquals(maxPhonemes, engine.getMaxPhonemes());
     }
 
     /**
-     * Tests {@link PhoneticEngine.Builder#setMaxInputLength(int)} with a 
custom value:
-     * input one character beyond the limit is rejected with {@link 
IllegalArgumentException}.
+     * Tests {@link PhoneticEngine.Builder#setMaxPhonemes(int)} with {@link 
Integer#MAX_VALUE}.
      */
     @Test
-    void testSetMaxInputLengthRejectsInputBeyondCustomLimit() {
-        final int customLimit = 10;
-        final PhoneticEngine engine = 
PhoneticEngine.builder().setMaxInputLength(customLimit).get();
-        final String input = repeat(customLimit + 1);
-        assertThrows(IllegalArgumentException.class, () -> 
engine.encode(input));
+    void testSetMaxPhonemesMaxValue() {
+        final PhoneticEngine engine = 
PhoneticEngine.builder().setMaxPhonemes(Integer.MAX_VALUE).get();
+        assertEquals(Integer.MAX_VALUE, engine.getMaxPhonemes());
     }
 
     /**
-     * Tests {@link PhoneticEngine.Builder#setMaxInputLength(int)} with a 
limit of 0:
-     * any non-empty input is rejected.
+     * Tests {@link PhoneticEngine.Builder#setNameType(NameType)} with 
ASHKENAZI.
      */
     @Test
-    void testSetMaxInputLengthZeroRejectsAnyInput() {
-        final PhoneticEngine engine = 
PhoneticEngine.builder().setMaxInputLength(0).get();
-        assertThrows(IllegalArgumentException.class, () -> engine.encode("a"));
+    void testSetNameTypeAshkenazi() {
+        final PhoneticEngine engine = 
PhoneticEngine.builder().setNameType(NameType.ASHKENAZI).get();
+        assertEquals(NameType.ASHKENAZI, engine.getNameType());
     }
 
     /**
-     * Tests {@link PhoneticEngine.Builder#setMaxInputLength(int)} with a 
limit of 0:
-     * null input bypasses the length check but causes a {@link 
NullPointerException} downstream.
+     * Tests {@link PhoneticEngine.Builder#setNameType(NameType)}.
      */
     @Test
-    void testSetMaxInputLengthZeroNullInputThrowsNpe() {
-        final PhoneticEngine engine = 
PhoneticEngine.builder().setMaxInputLength(0).get();
-        // null is not blocked by the length check, but encoding null causes 
NPE
-        assertThrows(NullPointerException.class, () -> engine.encode(null));
+    void testSetNameTypeGeneric() {
+        final PhoneticEngine engine = 
PhoneticEngine.builder().setNameType(NameType.GENERIC).get();
+        assertEquals(NameType.GENERIC, engine.getNameType());
     }
 
     /**
-     * Tests {@link PhoneticEngine.Builder#setMaxInputLength(int)} that the 
setter returns
-     * the same builder instance to enable method chaining.
+     * Tests {@link PhoneticEngine.Builder#setNameType(NameType)} with 
SEPHARDIC.
      */
     @Test
-    void testSetMaxInputLengthReturnsBuilder() {
-        final PhoneticEngine.Builder builder = PhoneticEngine.builder();
-        assertNotNull(builder.setMaxInputLength(100));
+    void testSetNameTypeSephardic() {
+        final PhoneticEngine engine = 
PhoneticEngine.builder().setNameType(NameType.SEPHARDIC).get();
+        assertEquals(NameType.SEPHARDIC, engine.getNameType());
     }
 
     /**
-     * Tests that {@link PhoneticEngine.Builder#setMaxInputLength(int)} can be 
combined
-     * with other builder settings and still produces a valid engine.
+     * Tests {@link PhoneticEngine.Builder#setRuleType(RuleType)} with APPROX.
      */
     @Test
-    void testSetMaxInputLengthWithOtherSettings() {
-        // @formatter:off
-        final PhoneticEngine engine = PhoneticEngine.builder()
-                .setNameType(NameType.ASHKENAZI)
-                .setRuleType(RuleType.APPROX)
-                .setConcat(true)
-                .setMaxPhonemes(10)
-                .setMaxInputLength(5)
-                .get();
-        // @formatter:on
-        assertNotNull(engine);
-        assertDoesNotThrow(() -> engine.encode("abcde"));
-        assertThrows(IllegalArgumentException.class, () -> 
engine.encode("abcdef"));
+    void testSetRuleTypeApprox() {
+        final PhoneticEngine engine = 
PhoneticEngine.builder().setRuleType(RuleType.APPROX).get();
+        assertEquals(RuleType.APPROX, engine.getRuleType());
     }
 
     /**
-     * Tests that {@link PhoneticEngine.Builder#setMaxInputLength(int)} with 
{@link Integer#MAX_VALUE}
-     * allows very long input.
+     * Tests {@link PhoneticEngine.Builder#setRuleType(RuleType)} with EXACT.
      */
     @Test
-    void testSetMaxInputLengthMaxValue() {
-        final PhoneticEngine engine = 
PhoneticEngine.builder().setMaxInputLength(Integer.MAX_VALUE).get();
-        // A very long string should not trigger the length check
-        final String input = repeat(10_000);
-        assertDoesNotThrow(() -> engine.encode(input));
+    void testSetRuleTypeExact() {
+        final PhoneticEngine engine = 
PhoneticEngine.builder().setRuleType(RuleType.EXACT).get();
+        assertEquals(RuleType.EXACT, engine.getRuleType());
     }
 }

Reply via email to