View Javadoc
1   package ch.qos.logback.core.util;
2   
3   import static org.junit.Assert.*;
4   
5   import org.junit.After;
6   import org.junit.Before;
7   import org.junit.Test;
8   
9   public class COWArrayListTest {
10  
11      Integer[] model = new Integer[0];
12      COWArrayList<Integer> cowaList = new COWArrayList<Integer>(model);
13  
14      @Before
15      public void setUp() throws Exception {
16      }
17  
18      @After
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      
37      @Test
38      public void basicToArrayTyped() {
39          cowaList.add(1);
40          Integer[] result = cowaList.asTypedArray();
41          assertArrayEquals(new Integer[] { 1 }, result);
42      }
43  
44  }