• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 The Guava Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5  * in compliance with the License. You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software distributed under the
10  * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11  * express or implied. See the License for the specific language governing permissions and
12  * limitations under the License.
13  */
14 
15 package com.google.common.collect;
16 
17 import com.google.common.annotations.GwtCompatible;
18 import junit.framework.TestCase;
19 
20 /**
21  * Tests for {@code Count}.
22  *
23  * @author Louis Wasserman
24  */
25 @GwtCompatible
26 @ElementTypesAreNonnullByDefault
27 public class CountTest extends TestCase {
testGet()28   public void testGet() {
29     assertEquals(20, new Count(20).get());
30   }
31 
testGetAndAdd()32   public void testGetAndAdd() {
33     Count holder = new Count(20);
34     assertEquals(20, holder.get());
35     holder.add(1);
36     assertEquals(21, holder.get());
37   }
38 
testAddAndGet()39   public void testAddAndGet() {
40     Count holder = new Count(20);
41     assertEquals(21, holder.addAndGet(1));
42   }
43 
testGetAndSet()44   public void testGetAndSet() {
45     Count holder = new Count(10);
46     assertEquals(10, holder.getAndSet(20));
47     assertEquals(20, holder.get());
48   }
49 
testSet()50   public void testSet() {
51     Count holder = new Count(10);
52     holder.set(20);
53     assertEquals(20, holder.get());
54   }
55 }
56