Clover Coverage Report - Backport Util Concurrent v3.0
Coverage timestamp: Fri May 9 2008 11:05:23 EST
179   369   61   7.16
52   268   0.34   12.5
25     2.44  
2    
 
  AtomicIntegerArrayTest       Line # 13 167 54 92.7% 0.9273504
  AtomicIntegerArrayTest.Counter       Line # 269 12 7 100% 1.0
 
  (19)
 
1    /*
2    * Written by Doug Lea with assistance from members of JCP JSR-166
3    * Expert Group and released to the public domain, as explained at
4    * http://creativecommons.org/licenses/publicdomain
5    * Other contributors include Andrew Wright, Jeffrey Hayes,
6    * Pat Fisher, Mike Judd.
7    */
8   
9    import junit.framework.*;
10    import edu.emory.mathcs.backport.java.util.concurrent.atomic.*;
11    import java.io.*;
12   
 
13    public class AtomicIntegerArrayTest extends JSR166TestCase {
14   
 
15  0 toggle public static void main (String[] args) {
16  0 junit.textui.TestRunner.run (suite());
17    }
 
18  1 toggle public static Test suite() {
19  1 return new TestSuite(AtomicIntegerArrayTest.class);
20    }
21   
22   
23    /**
24    * constructor creates array of given size with all elements zero
25    */
 
26  1 toggle public void testConstructor() {
27  1 AtomicIntegerArray ai = new AtomicIntegerArray(SIZE);
28  21 for (int i = 0; i < SIZE; ++i)
29  20 assertEquals(0,ai.get(i));
30    }
31   
32    /**
33    * constructor with null array throws NPE
34    */
 
35  1 toggle public void testConstructor2NPE() {
36  1 try {
37  1 int[] a = null;
38  1 AtomicIntegerArray ai = new AtomicIntegerArray(a);
39    } catch (NullPointerException success) {
40    } catch (Exception ex) {
41  0 unexpectedException();
42    }
43    }
44   
45    /**
46    * constructor with array is of same size and has all elements
47    */
 
48  1 toggle public void testConstructor2() {
49  1 int[] a = { 17, 3, -42, 99, -7};
50  1 AtomicIntegerArray ai = new AtomicIntegerArray(a);
51  1 assertEquals(a.length, ai.length());
52  6 for (int i = 0; i < a.length; ++i)
53  5 assertEquals(a[i], ai.get(i));
54    }
55   
56    /**
57    * get and set for out of bound indices throw IndexOutOfBoundsException
58    */
 
59  1 toggle public void testIndexing(){
60  1 AtomicIntegerArray ai = new AtomicIntegerArray(SIZE);
61  1 try {
62  1 ai.get(SIZE);
63    } catch(IndexOutOfBoundsException success){
64    }
65  1 try {
66  1 ai.get(-1);
67    } catch(IndexOutOfBoundsException success){
68    }
69  1 try {
70  1 ai.set(SIZE, 0);
71    } catch(IndexOutOfBoundsException success){
72    }
73  1 try {
74  1 ai.set(-1, 0);
75    } catch(IndexOutOfBoundsException success){
76    }
77    }
78   
79    /**
80    * get returns the last value set at index
81    */
 
82  1 toggle public void testGetSet() {
83