Atomic_unittest.cc revision cd139dc7
1cd139dc7SShuo Chen#include "../Atomic.h" 2cd139dc7SShuo Chen#include <assert.h> 3cd139dc7SShuo Chen 4cd139dc7SShuo Chenint main() 5cd139dc7SShuo Chen{ 6cd139dc7SShuo Chen muduo::AtomicInt64 a0; 7cd139dc7SShuo Chen assert(a0.get() == 0); 8cd139dc7SShuo Chen assert(a0.getAndAdd(1) == 0); 9cd139dc7SShuo Chen assert(a0.get() == 1); 10cd139dc7SShuo Chen assert(a0.addAndGet(2) == 3); 11cd139dc7SShuo Chen assert(a0.get() == 3); 12cd139dc7SShuo Chen assert(a0.incrementAndGet() == 4); 13cd139dc7SShuo Chen assert(a0.get() == 4); 14cd139dc7SShuo Chen a0.increment(); 15cd139dc7SShuo Chen assert(a0.get() == 5); 16cd139dc7SShuo Chen assert(a0.addAndGet(-3) == 2); 17cd139dc7SShuo Chen assert(a0.getAndSet(100) == 2); 18cd139dc7SShuo Chen assert(a0.get() == 100); 19cd139dc7SShuo Chen} 20cd139dc7SShuo Chen 21