From 9a1fbf5e0eaf2b80268ecde87917b196e7fb04e9 Mon Sep 17 00:00:00 2001 From: Braden Miller Date: Sat, 12 Apr 2025 13:00:53 -0400 Subject: [PATCH 1/5] Seventh Test --- .../apache/commons/lang3/SE4560TenthTest.java | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/test/java/org/apache/commons/lang3/SE4560TenthTest.java diff --git a/src/test/java/org/apache/commons/lang3/SE4560TenthTest.java b/src/test/java/org/apache/commons/lang3/SE4560TenthTest.java new file mode 100644 index 00000000000..9be2db5415f --- /dev/null +++ b/src/test/java/org/apache/commons/lang3/SE4560TenthTest.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.lang3; + +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; + +public class SE4560TenthTest { + // Boundary value test on StringUtil's join() method + @Test + void JoinNullTest() { + String array[] = {null}; + assertEquals("", StringUtils.join(array, "", 0, 0)); + } + @Test + void JoinEmptyTest() { + String array[] = {}; + assertEquals("", StringUtils.join(array, "", 0, 0)); + } + @Test + void JoinNormalTest() { + String array[] = {"a", "b", "c"}; + assertEquals("a,b,c", StringUtils.join(array, ",", 0, 3)); + } + @Test + void JoinNumTest() { + Integer array[] = {1, 2, 3}; + assertEquals("1,2,3", StringUtils.join(array, ",", 0, 3)); + } + @Test + void JoinHighIndexTest() { + String array[] = {"a", "b", "c"}; + assertEquals("a,b,c", StringUtils.join(array, ",", 0, 5)); + } + @Test + void JoinLowIndexTest() { + String array[] = {"a", "b", "c"}; + assertEquals("a", StringUtils.join(array, ",", 0, 1)); + } + @Test + void JoinOutOfBoundsTest() { + String array[] = {"a", "b", "c"}; + assertThrows(IllegalArgumentException.class, () -> {StringUtils.join(array, ",", -1, 3);}); + } + @Test + void JoinNoIndexTest() { + String array[] = {"a", "b", "c"}; + assertEquals("a,b,c", StringUtils.join(array, ",")); + } +} From 66e6a550cf9afdb7747f915a1ac383e53e02040c Mon Sep 17 00:00:00 2001 From: Braden Miller Date: Sat, 12 Apr 2025 13:01:16 -0400 Subject: [PATCH 2/5] Eighth Test --- .../commons/lang3/SE4560EighthTest.java | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/test/java/org/apache/commons/lang3/SE4560EighthTest.java diff --git a/src/test/java/org/apache/commons/lang3/SE4560EighthTest.java b/src/test/java/org/apache/commons/lang3/SE4560EighthTest.java new file mode 100644 index 00000000000..0233210fd4c --- /dev/null +++ b/src/test/java/org/apache/commons/lang3/SE4560EighthTest.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.lang3; + +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; + +public class SE4560EighthTest { + // Boundary value tests on RegExUtil's removeAll() methods + @Test + void removeAllNullTest() { + assertEquals(null, RegExUtils.removeAll(null, "[a-z]")); + } + @Test + void removeAllNormalTest() { + assertEquals("abc", RegExUtils.removeAll("ABCabc", "[A-Z]")); + } + @Test + void removeAllEmptyTest() { + assertEquals("", RegExUtils.removeAll("ABCabc", ".*")); + } + @Test + void removeAllSpecialCharTest() { + assertEquals("abc", RegExUtils.removeAll("a?bc", "\\?")); + } + @Test + void removeAllAnchorTest() { + assertEquals("BCabc", RegExUtils.removeAll("ABCabc", "^.")); + } + @Test + void removeAllOrTest() { + assertEquals("Cc", RegExUtils.removeAll("ABCabc", "(ab)|(AB)")); + } + @Test + void removeAllRepeatingTest() { + assertEquals("ABCabc", RegExUtils.removeAll("ABCaaaabc", "a{3}")); + } +} From bfbb3b749ae52262778a1bf84141d671389f7eeb Mon Sep 17 00:00:00 2001 From: Braden Miller Date: Sat, 12 Apr 2025 13:01:34 -0400 Subject: [PATCH 3/5] Ninth Test --- .../apache/commons/lang3/SE4560NinthTest.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/test/java/org/apache/commons/lang3/SE4560NinthTest.java diff --git a/src/test/java/org/apache/commons/lang3/SE4560NinthTest.java b/src/test/java/org/apache/commons/lang3/SE4560NinthTest.java new file mode 100644 index 00000000000..2b5a4a04591 --- /dev/null +++ b/src/test/java/org/apache/commons/lang3/SE4560NinthTest.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.lang3; + +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; + +public class SE4560NinthTest { + // Boundary value tests on StringUtil's compare() method + @Test + void CompareNullTest() { + assertEquals(0, StringUtils.compare(null, null, true)); + assertEquals(-1, StringUtils.compare(null, " ", true)); + assertEquals(1, StringUtils.compare(null, " ", false)); + } + @Test + void CompareNormalTest() { + assertEquals(3, StringUtils.compare("d", "a", true)); + } + @Test + void CompareSpecialCharTest() { + assertEquals(53, StringUtils.compare("???", "\n", true)); + } + @Test + void CompareEqualTest() { + assertEquals(0, StringUtils.compare("abc", "abc", true)); + } + @Test + void CompareUpperTest() { + assertEquals(32, StringUtils.compare("abc", "ABC", true)); + } + @Test + void CompareLengthTest() { + assertEquals(3, StringUtils.compare("abcabc", "abc", true)); + } +} \ No newline at end of file From a1b77c09fd8dcfa2c0540f779506d3fde27a66a3 Mon Sep 17 00:00:00 2001 From: Braden Miller Date: Sat, 12 Apr 2025 13:02:37 -0400 Subject: [PATCH 4/5] Tenth Test --- .../commons/lang3/SE4560SeventhTest.java | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/test/java/org/apache/commons/lang3/SE4560SeventhTest.java diff --git a/src/test/java/org/apache/commons/lang3/SE4560SeventhTest.java b/src/test/java/org/apache/commons/lang3/SE4560SeventhTest.java new file mode 100644 index 00000000000..079a8c58b9e --- /dev/null +++ b/src/test/java/org/apache/commons/lang3/SE4560SeventhTest.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.lang3; + +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; + +public class SE4560SeventhTest { + // Class partition tests on StringUtil's abbreviate() methods + @Test + void AbbreviateShortTest() { + assertEquals("abc", StringUtils.abbreviate("abc", 4)); + } + @Test + void AbbreviateLongTest() { + assertEquals("a...", StringUtils.abbreviate("abcdefg", 4)); + } + @Test + void AbbreviateNullTest() { + assertEquals(null, StringUtils.abbreviate(null, 4)); + } + @Test + void AbbreviateNormalTest() { + assertEquals("abc...", StringUtils.abbreviate("abcdefghi", 6)); + } + @Test + void AbbreviateInvalidTest() { + assertThrows(IllegalArgumentException.class, () -> {StringUtils.abbreviate("abc", 1);}); + } + @Test + void AbbreviateOffsetTest() { + assertEquals("...abc...", StringUtils.abbreviate("12345abc12345", 5, 9)); + } + @Test + void AbbreviateMarkerTest() { + assertEquals("-abc-", StringUtils.abbreviate("123abc123","-", 3, 5)); + } + @Test + void AbbreviateMarkerInvalidTest() { + assertThrows(IllegalArgumentException.class, () -> {StringUtils.abbreviate("12345abc12345", ".....", 7, 10);}); + } +} From 2fa35303cab6bbde8c08b3a7aea59f5323d8bd58 Mon Sep 17 00:00:00 2001 From: Braden Miller Date: Sat, 12 Apr 2025 13:10:01 -0400 Subject: [PATCH 5/5] Renamed files to match --- .../commons/lang3/SE4560SeventhTest.java | 42 +++++++++++-------- .../apache/commons/lang3/SE4560TenthTest.java | 42 ++++++++----------- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/test/java/org/apache/commons/lang3/SE4560SeventhTest.java b/src/test/java/org/apache/commons/lang3/SE4560SeventhTest.java index 079a8c58b9e..5e10e1282a3 100644 --- a/src/test/java/org/apache/commons/lang3/SE4560SeventhTest.java +++ b/src/test/java/org/apache/commons/lang3/SE4560SeventhTest.java @@ -21,37 +21,45 @@ import org.junit.jupiter.api.Test; public class SE4560SeventhTest { - // Class partition tests on StringUtil's abbreviate() methods + // Boundary value test on StringUtil's join() method @Test - void AbbreviateShortTest() { - assertEquals("abc", StringUtils.abbreviate("abc", 4)); + void JoinNullTest() { + String array[] = {null}; + assertEquals("", StringUtils.join(array, "", 0, 0)); } @Test - void AbbreviateLongTest() { - assertEquals("a...", StringUtils.abbreviate("abcdefg", 4)); + void JoinEmptyTest() { + String array[] = {}; + assertEquals("", StringUtils.join(array, "", 0, 0)); } @Test - void AbbreviateNullTest() { - assertEquals(null, StringUtils.abbreviate(null, 4)); + void JoinNormalTest() { + String array[] = {"a", "b", "c"}; + assertEquals("a,b,c", StringUtils.join(array, ",", 0, 3)); } @Test - void AbbreviateNormalTest() { - assertEquals("abc...", StringUtils.abbreviate("abcdefghi", 6)); + void JoinNumTest() { + Integer array[] = {1, 2, 3}; + assertEquals("1,2,3", StringUtils.join(array, ",", 0, 3)); } @Test - void AbbreviateInvalidTest() { - assertThrows(IllegalArgumentException.class, () -> {StringUtils.abbreviate("abc", 1);}); + void JoinHighIndexTest() { + String array[] = {"a", "b", "c"}; + assertEquals("a,b,c", StringUtils.join(array, ",", 0, 5)); } @Test - void AbbreviateOffsetTest() { - assertEquals("...abc...", StringUtils.abbreviate("12345abc12345", 5, 9)); + void JoinLowIndexTest() { + String array[] = {"a", "b", "c"}; + assertEquals("a", StringUtils.join(array, ",", 0, 1)); } @Test - void AbbreviateMarkerTest() { - assertEquals("-abc-", StringUtils.abbreviate("123abc123","-", 3, 5)); + void JoinOutOfBoundsTest() { + String array[] = {"a", "b", "c"}; + assertThrows(IllegalArgumentException.class, () -> {StringUtils.join(array, ",", -1, 3);}); } @Test - void AbbreviateMarkerInvalidTest() { - assertThrows(IllegalArgumentException.class, () -> {StringUtils.abbreviate("12345abc12345", ".....", 7, 10);}); + void JoinNoIndexTest() { + String array[] = {"a", "b", "c"}; + assertEquals("a,b,c", StringUtils.join(array, ",")); } } diff --git a/src/test/java/org/apache/commons/lang3/SE4560TenthTest.java b/src/test/java/org/apache/commons/lang3/SE4560TenthTest.java index 9be2db5415f..db7455c0677 100644 --- a/src/test/java/org/apache/commons/lang3/SE4560TenthTest.java +++ b/src/test/java/org/apache/commons/lang3/SE4560TenthTest.java @@ -21,45 +21,37 @@ import org.junit.jupiter.api.Test; public class SE4560TenthTest { - // Boundary value test on StringUtil's join() method + // Class partition tests on StringUtil's abbreviate() methods @Test - void JoinNullTest() { - String array[] = {null}; - assertEquals("", StringUtils.join(array, "", 0, 0)); + void AbbreviateShortTest() { + assertEquals("abc", StringUtils.abbreviate("abc", 4)); } @Test - void JoinEmptyTest() { - String array[] = {}; - assertEquals("", StringUtils.join(array, "", 0, 0)); + void AbbreviateLongTest() { + assertEquals("a...", StringUtils.abbreviate("abcdefg", 4)); } @Test - void JoinNormalTest() { - String array[] = {"a", "b", "c"}; - assertEquals("a,b,c", StringUtils.join(array, ",", 0, 3)); + void AbbreviateNullTest() { + assertEquals(null, StringUtils.abbreviate(null, 4)); } @Test - void JoinNumTest() { - Integer array[] = {1, 2, 3}; - assertEquals("1,2,3", StringUtils.join(array, ",", 0, 3)); + void AbbreviateNormalTest() { + assertEquals("abc...", StringUtils.abbreviate("abcdefghi", 6)); } @Test - void JoinHighIndexTest() { - String array[] = {"a", "b", "c"}; - assertEquals("a,b,c", StringUtils.join(array, ",", 0, 5)); + void AbbreviateInvalidTest() { + assertThrows(IllegalArgumentException.class, () -> {StringUtils.abbreviate("abc", 1);}); } @Test - void JoinLowIndexTest() { - String array[] = {"a", "b", "c"}; - assertEquals("a", StringUtils.join(array, ",", 0, 1)); + void AbbreviateOffsetTest() { + assertEquals("...abc...", StringUtils.abbreviate("12345abc12345", 5, 9)); } @Test - void JoinOutOfBoundsTest() { - String array[] = {"a", "b", "c"}; - assertThrows(IllegalArgumentException.class, () -> {StringUtils.join(array, ",", -1, 3);}); + void AbbreviateMarkerTest() { + assertEquals("-abc-", StringUtils.abbreviate("123abc123","-", 3, 5)); } @Test - void JoinNoIndexTest() { - String array[] = {"a", "b", "c"}; - assertEquals("a,b,c", StringUtils.join(array, ",")); + void AbbreviateMarkerInvalidTest() { + assertThrows(IllegalArgumentException.class, () -> {StringUtils.abbreviate("12345abc12345", ".....", 7, 10);}); } }