Skip to content

Commit

Permalink
Merge pull request #1772 from Alan-95-hub/more-no-nulls-tests
Browse files Browse the repository at this point in the history
Add more no nulls list tests
  • Loading branch information
yegor256 authored Mar 3, 2025
2 parents cf5bfaa + fff3f1b commit 5c8a25b
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions src/test/java/org/cactoos/list/NoNullsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
import org.hamcrest.Matchers;
import org.hamcrest.core.IsEqual;
import org.junit.jupiter.api.Test;
import org.llorllale.cactoos.matchers.Assertion;
Expand Down Expand Up @@ -273,4 +274,72 @@ void addValidInputTest() {
)
).affirm();
}

@Test
void addAllTest() {
final List<Integer> list = new NoNulls<>(
new ListOf<>(1, 2, 3)
);
new Assertion<>(
"must return true on success",
list.addAll(new ListOf<>(4, 5, 6)),
new IsTrue()
).affirm();
new Assertion<>(
"must add items to the end of the list",
list,
Matchers.contains(1, 2, 3, 4, 5, 6)
).affirm();
}

@Test
void addAllWithIndexTest() {
final List<Integer> list = new NoNulls<>(
new ListOf<>(1, 2, 3)
);
new Assertion<>(
"must return true on success",
list.addAll(1, new ListOf<>(4, 5, 6)),
new IsTrue()
).affirm();
new Assertion<>(
"must add items to list at specified index",
list,
Matchers.contains(1, 4, 5, 6, 2, 3)
).affirm();
}

@Test
void removeAllChangedTest() {
final List<Integer> list = new NoNulls<>(
new ListOf<>(1, 2, 3, 4, 5, 6)
);
new Assertion<>(
"must return true if list changed",
list.removeAll(new ListOf<>(10, 4, 2, 9, -3)),
new IsTrue()
).affirm();
new Assertion<>(
"must remove specified items",
list,
Matchers.contains(1, 3, 5, 6)
).affirm();
}

@Test
void removeAllDidNotChangeTest() {
final List<Integer> list = new NoNulls<>(
new ListOf<>(1, 2, 3, 4, 5, 6)
);
new Assertion<>(
"must return false if list did not change",
list.removeAll(new ListOf<>(10, 0, 7, 9, -3)),
new IsEqual<>(false)
).affirm();
new Assertion<>(
"list must be the same",
list,
Matchers.contains(1, 2, 3, 4, 5, 6)
).affirm();
}
}

0 comments on commit 5c8a25b

Please sign in to comment.