1#include "../Atomic.h"
2#include <assert.h>
3
4int main()
5{
6  {
7  muduo::AtomicInt64 a0;
8  assert(a0.get() == 0);
9  assert(a0.getAndAdd(1) == 0);
10  assert(a0.get() == 1);
11  assert(a0.addAndGet(2) == 3);
12  assert(a0.get() == 3);
13  assert(a0.incrementAndGet() == 4);
14  assert(a0.get() == 4);
15  a0.increment();
16  assert(a0.get() == 5);
17  assert(a0.addAndGet(-3) == 2);
18  assert(a0.getAndSet(100) == 2);
19  assert(a0.get() == 100);
20  }
21
22  {
23  muduo::AtomicInt32 a1;
24  assert(a1.get() == 0);
25  assert(a1.getAndAdd(1) == 0);
26  assert(a1.get() == 1);
27  assert(a1.addAndGet(2) == 3);
28  assert(a1.get() == 3);
29  assert(a1.incrementAndGet() == 4);
30  assert(a1.get() == 4);
31  a1.increment();
32  assert(a1.get() == 5);
33  assert(a1.addAndGet(-3) == 2);
34  assert(a1.getAndSet(100) == 2);
35  assert(a1.get() == 100);
36  }
37}
38
39