Clover Coverage Report - Backport Util Concurrent v3.0
Coverage timestamp: Fri May 9 2008 11:05:23 EST
178   364   61   7.12
52   268   0.34   12.5
25     2.44  
2    
 
  AtomicLongArrayTest       Line # 14 166 54 93.1% 0.93133044
  AtomicLongArrayTest.Counter       Line # 268 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    import edu.emory.mathcs.backport.java.util.*;
13   
 
14    public class AtomicLongArrayTest extends JSR166TestCase {
 
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(AtomicLongArrayTest.class);
20    }
21   
22    /**
23    * constructor creates array of given size with all elements zero
24    */
 
25  1 toggle public void testConstructor(){
26  1 AtomicLongArray ai = new AtomicLongArray(SIZE);
27  21 for (int i = 0; i < SIZE; ++i)
28  20 assertEquals(0,ai.get(i));
29    }
30   
31    /**
32    * constructor with null array throws NPE
33    */
 
34  1 toggle public void testConstructor2NPE() {
35  1 try {
36  1 long[] a = null;
37  1 AtomicLongArray ai = new AtomicLongArray(a);
38    } catch (NullPointerException success) {
39    } catch (Exception ex) {
40  0 unexpectedException();
41    }
42    }
43   
44    /**
45    * constructor with array is of same size and has all elements
46    */
 
47  1 toggle public void testConstructor2() {
48  1 long[] a = { 17L, 3L, -42L, 99L, -7L};
49  1 AtomicLongArray ai = new AtomicLongArray(a);
50  1 assertEquals(a.length, ai.length());
51  6 for (int i = 0; i < a.length; ++i)
52  5 assertEquals(a[i], ai.get(i));
53    }
54   
55    /**
56    * get and set for out of bound indices throw IndexOutOfBoundsException
57    */
 
58  1 toggle public void testIndexing(){
59  1 AtomicLongArray ai = new AtomicLongArray(SIZE);
60  1 try {
61  1 ai.get(SIZE);
62    } catch(IndexOutOfBoundsException success){
63    }
64  1 try {
65  1 ai.get(-1);
66    } catch(IndexOutOfBoundsException success){
67    }
68  1 try {
69  1 ai.set(SIZE, 0);
70    } catch(IndexOutOfBoundsException success){
71    }
72  1 try {
73  1 ai.set(-1, 0);
74    } catch(IndexOutOfBoundsException success){
75    }
76    }
77   
78    /**
79    * get returns the last value set at index
80    */
 
81  1 toggle public void testGetSet(){
82  1 AtomicLongArray ai = new AtomicLongArray(SIZE);