View Javadoc
1   package ch.qos.logback.core.util;
2   
3   import org.junit.jupiter.api.AfterEach;
4   import org.junit.jupiter.api.BeforeEach;
5   import org.junit.jupiter.api.Test;
6   
7   import static org.junit.jupiter.api.Assertions.assertArrayEquals;
8   
9   public class COWArrayListTest {
10  
11      Integer[] model = new Integer[0];
12      COWArrayList<Integer> cowaList = new COWArrayList<Integer>(model);
13  
14      @BeforeEach
15      public void setUp() throws Exception {
16      }
17  
18      @AfterEach
19      public void tearDown() throws Exception {
20      }
21  
22      @Test
23      public void basicToArray() {
24          cowaList.add(1);
25          Object[] result = cowaList.toArray();
26          assertArrayEquals(new Integer[] { 1 }, result);
27      }
28  
29      @Test
30      public void basicToArrayWithModel() {
31          cowaList.add(1);
32          Integer[] result = cowaList.toArray(model);
33          assertArrayEquals(new Integer[] { 1 }, result);
34      }
35  
36      @Test
37      public void basicToArrayTyped() {
38          cowaList.add(1);
39          Integer[] result = cowaList.asTypedArray();
40          assertArrayEquals(new Integer[] { 1 }, result);
41      }
42  
43  }