Scheduler
countingWheelTest.cpp
Go to the documentation of this file.
1 
10 #include <gtest/gtest.h>
11 #include <utils/countingWheel.h>
12 
13 
14 TEST(CountingWheel, testInitialization)
15 {
16  Utils::CountingWheel wheel(7);
17  wheel.initialize();
18  EXPECT_EQ(0u, wheel.getValue());
19  EXPECT_EQ(7u, wheel.getBase());
20 }
21 
22 
23 TEST(CountingWheel, incrementAndCarryTest)
24 {
25  Utils::CountingWheel wheel(3);
26  wheel.initialize();
27  bool carry = wheel.increment();
28  EXPECT_EQ(1u, wheel.getValue());
29  EXPECT_FALSE(carry);
30 
31  carry = wheel.increment();
32  EXPECT_EQ(2u, wheel.getValue());
33  EXPECT_FALSE(carry);
34 
35  carry = wheel.increment();
36  EXPECT_EQ(0u, wheel.getValue());
37  EXPECT_TRUE(carry);
38 }
39 TEST(CountingWheel, baseZeroTest)
40 {
41  Utils::CountingWheel wheel0(0);
42  bool carry = false;
43  wheel0.initialize();
44  EXPECT_EQ(0u, wheel0.getValue());
45  carry = wheel0.increment();
46  EXPECT_EQ(0u, wheel0.getValue());
47  EXPECT_TRUE(carry);
48 }
49 
50 
unsigned int getBase()
TEST(CountingWheel, testInitialization)
unsigned int getValue()