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
15package com.google.common.collect;
16
17import com.google.common.annotations.GwtCompatible;
18
19import junit.framework.TestCase;
20
21/**
22 * Tests for {@code Count}.
23 *
24 * @author Louis Wasserman
25 */
26@GwtCompatible
27public class CountTest extends TestCase {
28  public void testGet() {
29    assertEquals(20, new Count(20).get());
30  }
31
32  public void testGetAndAdd() {
33    Count holder = new Count(20);
34    assertEquals(20, holder.getAndAdd(1));
35    assertEquals(21, holder.get());
36  }
37
38  public void testAddAndGet() {
39    Count holder = new Count(20);
40    assertEquals(21, holder.addAndGet(1));
41  }
42
43  public void testGetAndSet() {
44    Count holder = new Count(10);
45    assertEquals(10, holder.getAndSet(20));
46    assertEquals(20, holder.get());
47  }
48
49  public void testSet() {
50    Count holder = new Count(10);
51    holder.set(20);
52    assertEquals(20, holder.get());
53  }
54}
55