-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathExampleTest.java
More file actions
34 lines (29 loc) · 1.06 KB
/
ExampleTest.java
File metadata and controls
34 lines (29 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.List;
import org.junit.jupiter.api.Test;
class ExampleTest {
@Test
void createListWithSingleElement() {
List<Integer> singleElementList = InmutableList.alternativeOf(42);
assertEquals(1, singleElementList.size());
assertEquals(42, singleElementList.get(0));
}
@Test
void createListWithMultipleElements() {
List<String> multiElementList = InmutableList.alternativeOf("apple", "banana", "cherry");
assertEquals(3, multiElementList.size());
assertEquals("banana", multiElementList.get(1));
}
@Test
void createListWithVarargs() {
List<Integer> varargsList = InmutableList.alternativeOf(1, 2, 3, 4, 5);
assertEquals(5, varargsList.size());
assertEquals(4, varargsList.get(3));
}
@Test
void checkImmutability() {
List<String> immutableList = InmutableList.alternativeOf("one", "two", "three");
assertThrows(UnsupportedOperationException.class, () -> immutableList.add("four"));
}
}