ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/AtomicLongTest.java
(Generate patch)

Comparing jsr166/src/test/tck/AtomicLongTest.java (file contents):
Revision 1.12 by jsr166, Mon Nov 16 04:57:10 2009 UTC vs.
Revision 1.13 by jsr166, Mon Nov 16 05:30:07 2009 UTC

# Line 21 | Line 21 | public class AtomicLongTest extends JSR1
21      /**
22       * constructor initializes to given value
23       */
24 <    public void testConstructor(){
24 >    public void testConstructor() {
25          AtomicLong ai = new AtomicLong(1);
26          assertEquals(1,ai.get());
27      }
# Line 29 | Line 29 | public class AtomicLongTest extends JSR1
29      /**
30       * default constructed initializes to zero
31       */
32 <    public void testConstructor2(){
32 >    public void testConstructor2() {
33          AtomicLong ai = new AtomicLong();
34          assertEquals(0,ai.get());
35      }
# Line 37 | Line 37 | public class AtomicLongTest extends JSR1
37      /**
38       * get returns the last value set
39       */
40 <    public void testGetSet(){
40 >    public void testGetSet() {
41          AtomicLong ai = new AtomicLong(1);
42          assertEquals(1,ai.get());
43          ai.set(2);
# Line 50 | Line 50 | public class AtomicLongTest extends JSR1
50      /**
51       * get returns the last value lazySet in same thread
52       */
53 <    public void testGetLazySet(){
53 >    public void testGetLazySet() {
54          AtomicLong ai = new AtomicLong(1);
55          assertEquals(1,ai.get());
56          ai.lazySet(2);
# Line 63 | Line 63 | public class AtomicLongTest extends JSR1
63      /**
64       * compareAndSet succeeds in changing value if equal to expected else fails
65       */
66 <    public void testCompareAndSet(){
66 >    public void testCompareAndSet() {
67          AtomicLong ai = new AtomicLong(1);
68          assertTrue(ai.compareAndSet(1,2));
69          assertTrue(ai.compareAndSet(2,-4));
# Line 100 | Line 100 | public class AtomicLongTest extends JSR1
100       * repeated weakCompareAndSet succeeds in changing value when equal
101       * to expected
102       */
103 <    public void testWeakCompareAndSet(){
103 >    public void testWeakCompareAndSet() {
104          AtomicLong ai = new AtomicLong(1);
105          while (!ai.weakCompareAndSet(1,2));
106          while (!ai.weakCompareAndSet(2,-4));
# Line 112 | Line 112 | public class AtomicLongTest extends JSR1
112      /**
113       * getAndSet returns previous value and sets to given value
114       */
115 <    public void testGetAndSet(){
115 >    public void testGetAndSet() {
116          AtomicLong ai = new AtomicLong(1);
117          assertEquals(1,ai.getAndSet(0));
118          assertEquals(0,ai.getAndSet(-10));
# Line 122 | Line 122 | public class AtomicLongTest extends JSR1
122      /**
123       * getAndAdd returns previous value and adds given value
124       */
125 <    public void testGetAndAdd(){
125 >    public void testGetAndAdd() {
126          AtomicLong ai = new AtomicLong(1);
127          assertEquals(1,ai.getAndAdd(2));
128          assertEquals(3,ai.get());
# Line 133 | Line 133 | public class AtomicLongTest extends JSR1
133      /**
134       * getAndDecrement returns previous value and decrements
135       */
136 <    public void testGetAndDecrement(){
136 >    public void testGetAndDecrement() {
137          AtomicLong ai = new AtomicLong(1);
138          assertEquals(1,ai.getAndDecrement());
139          assertEquals(0,ai.getAndDecrement());
# Line 143 | Line 143 | public class AtomicLongTest extends JSR1
143      /**
144       * getAndIncrement returns previous value and increments
145       */
146 <    public void testGetAndIncrement(){
146 >    public void testGetAndIncrement() {
147          AtomicLong ai = new AtomicLong(1);
148          assertEquals(1,ai.getAndIncrement());
149          assertEquals(2,ai.get());
# Line 157 | Line 157 | public class AtomicLongTest extends JSR1
157      /**
158       * addAndGet adds given value to current, and returns current value
159       */
160 <    public void testAddAndGet(){
160 >    public void testAddAndGet() {
161          AtomicLong ai = new AtomicLong(1);
162          assertEquals(3,ai.addAndGet(2));
163          assertEquals(3,ai.get());
# Line 168 | Line 168 | public class AtomicLongTest extends JSR1
168      /**
169       * decrementAndGet decrements and returns current value
170       */
171 <    public void testDecrementAndGet(){
171 >    public void testDecrementAndGet() {
172          AtomicLong ai = new AtomicLong(1);
173          assertEquals(0,ai.decrementAndGet());
174          assertEquals(-1,ai.decrementAndGet());
# Line 179 | Line 179 | public class AtomicLongTest extends JSR1
179      /**
180       * incrementAndGet increments and returns current value
181       */
182 <    public void testIncrementAndGet(){
182 >    public void testIncrementAndGet() {
183          AtomicLong ai = new AtomicLong(1);
184          assertEquals(2,ai.incrementAndGet());
185          assertEquals(2,ai.get());
# Line 207 | Line 207 | public class AtomicLongTest extends JSR1
207              ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
208              AtomicLong r = (AtomicLong) in.readObject();
209              assertEquals(l.get(), r.get());
210 <        } catch (Exception e){
210 >        } catch (Exception e) {
211              unexpectedException();
212          }
213      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines