MCPcopy Create free account
hub / github.com/facebook/CacheLib / testAddSubIncDecBasic

Function testAddSubIncDecBasic

cachelib/common/tests/CounterTests.cpp:26–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24
25template <typename Counter>
26void testAddSubIncDecBasic(Counter& a) {
27 EXPECT_EQ(0, a.get());
28 a.add(1);
29 EXPECT_EQ(1, a.get());
30 a.add(5);
31 EXPECT_EQ(6, a.get());
32 a.sub(1);
33 EXPECT_EQ(5, a.get());
34 a.inc();
35 EXPECT_EQ(6, a.get());
36 a.dec();
37 EXPECT_EQ(5, a.get());
38}
39
40TEST(AtomicCounter, AddSubIncDecBasic) {
41 AtomicCounter a{0};

Callers 1

TESTFunction · 0.85

Calls 5

getMethod · 0.45
addMethod · 0.45
subMethod · 0.45
incMethod · 0.45
decMethod · 0.45

Tested by

no test coverage detected