Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions src/test/java/org/apache/commons/lang3/SE4560EighthTest.java
Original file line number Diff line number Diff line change
@@ -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}"));
}
}
51 changes: 51 additions & 0 deletions src/test/java/org/apache/commons/lang3/SE4560NinthTest.java
Original file line number Diff line number Diff line change
@@ -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));
}
}
65 changes: 65 additions & 0 deletions src/test/java/org/apache/commons/lang3/SE4560SeventhTest.java
Original file line number Diff line number Diff line change
@@ -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, ","));
}
}
57 changes: 57 additions & 0 deletions src/test/java/org/apache/commons/lang3/SE4560TenthTest.java
Original file line number Diff line number Diff line change
@@ -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);});
}
}