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}")); + } +} 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 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..5e10e1282a3 --- /dev/null +++ b/src/test/java/org/apache/commons/lang3/SE4560SeventhTest.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 SE4560SeventhTest { + // 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, ",")); + } +} 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..db7455c0677 --- /dev/null +++ b/src/test/java/org/apache/commons/lang3/SE4560TenthTest.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 SE4560TenthTest { + // 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);}); + } +}