Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Jan 27, 2025
2 parents 88ee36e + 61db19e commit 88c4dd8
Showing 1 changed file with 85 additions and 0 deletions.
85 changes: 85 additions & 0 deletions src/test/java/org/cactoos/list/NoNullsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
import org.hamcrest.core.IsEqual;
import org.junit.jupiter.api.Test;
import org.llorllale.cactoos.matchers.Assertion;
import org.llorllale.cactoos.matchers.IsTrue;
import org.llorllale.cactoos.matchers.Throws;

/**
Expand Down Expand Up @@ -141,4 +143,87 @@ void getThrowsErrorIfListIteratorPreviousValueIsNullValue() {
)
).affirm();
}

@Test
void indexOfThrowsErrorIfArgumentIsNull() {
new Assertion<>(
"must throw error if searched value is null",
() -> new NoNulls<>(
new ListOf<>(1, 2, 3)
).indexOf(null),
new Throws<>(
"Item can't be NULL in #indexOf(T)",
IllegalArgumentException.class
)
).affirm();
}

@Test
void indexOfTest() {
new Assertion<>(
"must return first index",
new NoNulls<>(
new ListOf<>(1, 2, 2, 2, 5)
).indexOf(2),
new IsEqual<>(1)
).affirm();
}

@Test
void lastIndexOfThrowsErrorIfArgumentIsNull() {
new Assertion<>(
"must throw error if searched value is null",
() -> new NoNulls<>(
new ListOf<>(1, 2, 3)
).lastIndexOf(null),
new Throws<>(
"Item can't be NULL in #lastIndexOf(T)",
IllegalArgumentException.class
)
).affirm();
}

@Test
void lastIndexOfTest() {
new Assertion<>(
"must return last index",
new NoNulls<>(
new ListOf<>(1, 2, 2, 2, 5)
).lastIndexOf(2),
new IsEqual<>(3)
).affirm();
}

@Test
void sizeTest() {
new Assertion<>(
"must return list size",
new NoNulls<>(
new ListOf<>(1, 2, 2, 2, 5)
).size(),
new IsEqual<>(5)
).affirm();
}

@Test
void isEmptyTrueTest() {
new Assertion<>(
"must return true if list is empty",
new NoNulls<>(
new ListOf<>()
).isEmpty(),
new IsTrue()
).affirm();
}

@Test
void isEmptyFalseTest() {
new Assertion<>(
"must return false if list is not empty",
new NoNulls<>(
new ListOf<>(1, 2, 3)
).isEmpty(),
new IsEqual<>(false)
).affirm();
}
}

0 comments on commit 88c4dd8

Please sign in to comment.