|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AtomicIntegerArrayTest | Line # 13 | 167 | 54 | 92.7% |
0.9273504
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| AtomicIntegerArrayTest.Counter | Line # 269 | 12 | 7 | 100% |
1.0
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| (19) | |||
| Result | |||
|
0.1484375
|
AtomicIntegerArrayTest.testCountingInMultipleThreads
AtomicIntegerArrayTest.testCountingInMultipleThreads
|
1 PASS | |
|
0.0703125
|
AtomicIntegerArrayTest.testSerialization
AtomicIntegerArrayTest.testSerialization
|
1 PASS | |
|
0.06640625
|
AtomicIntegerArrayTest.testToString
AtomicIntegerArrayTest.testToString
|
1 PASS | |
|
0.0546875
|
AtomicIntegerArrayTest.testWeakCompareAndSet
AtomicIntegerArrayTest.testWeakCompareAndSet
|
1 PASS | |
|
0.05078125
|
AtomicIntegerArrayTest.testCompareAndSet
AtomicIntegerArrayTest.testCompareAndSet
|
1 PASS | |
|
0.05078125
|
AtomicIntegerArrayTest.testIncrementAndGet
AtomicIntegerArrayTest.testIncrementAndGet
|
1 PASS | |
|
0.05078125
|
AtomicIntegerArrayTest.testCompareAndSetInMultipleThreads
AtomicIntegerArrayTest.testCompareAndSetInMultipleThreads
|
1 PASS | |
|
0.05078125
|
AtomicIntegerArrayTest.testGetAndIncrement
AtomicIntegerArrayTest.testGetAndIncrement
|
1 PASS | |
|
0.04296875
|
AtomicIntegerArrayTest.testGetLazySet
AtomicIntegerArrayTest.testGetLazySet
|
1 PASS | |
|
0.04296875
|
AtomicIntegerArrayTest.testGetSet
AtomicIntegerArrayTest.testGetSet
|
1 PASS | |
|
0.0390625
|
AtomicIntegerArrayTest.testIndexing
AtomicIntegerArrayTest.testIndexing
|
1 PASS | |
|
0.0390625
|
AtomicIntegerArrayTest.testDecrementAndGet
AtomicIntegerArrayTest.testDecrementAndGet
|
1 PASS | |
|
0.0390625
|
AtomicIntegerArrayTest.testGetAndAdd
AtomicIntegerArrayTest.testGetAndAdd
|
1 PASS | |
|
0.0390625
|
AtomicIntegerArrayTest.testAddAndGet
AtomicIntegerArrayTest.testAddAndGet
|
1 PASS | |
|
0.03515625
|
AtomicIntegerArrayTest.testGetAndDecrement
AtomicIntegerArrayTest.testGetAndDecrement
|
1 PASS | |
|
0.03515625
|
AtomicIntegerArrayTest.testGetAndSet
AtomicIntegerArrayTest.testGetAndSet
|
1 PASS | |
|
0.03125
|
AtomicIntegerArrayTest.testConstructor2
AtomicIntegerArrayTest.testConstructor2
|
1 PASS | |
|
0.0234375
|
AtomicIntegerArrayTest.testConstructor
AtomicIntegerArrayTest.testConstructor
|
1 PASS | |
|
0.015625
|
AtomicIntegerArrayTest.testConstructor2NPE
AtomicIntegerArrayTest.testConstructor2NPE
|
1 PASS | |
| 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 |
public static void main (String[] args) { |
| 16 | 0 | junit.textui.TestRunner.run (suite()); |
| 17 | } | |
| 18 | 1 |
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 |
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 |
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 |
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 |
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 |
public void testGetSet() { |
| 83 | ||