| 74 | const int64_t ReservationTrackerTest::MIN_BUFFER_LEN; |
| 75 | |
| 76 | TEST_F(ReservationTrackerTest, BasicSingleTracker) { |
| 77 | const int64_t limit = 16; |
| 78 | root_.InitRootTracker(NULL, limit); |
| 79 | ASSERT_EQ(0, root_.GetReservation()); |
| 80 | ASSERT_EQ(0, root_.GetUsedReservation()); |
| 81 | |
| 82 | // Fail to increase reservation. |
| 83 | ASSERT_FALSE(root_.IncreaseReservation(limit + 1)); |
| 84 | ASSERT_EQ(0, root_.GetReservation()); |
| 85 | ASSERT_EQ(0, root_.GetUsedReservation()); |
| 86 | ASSERT_EQ(0, root_.GetUnusedReservation()); |
| 87 | |
| 88 | // Successfully increase reservation. |
| 89 | ASSERT_TRUE(root_.IncreaseReservation(limit - 1)); |
| 90 | ASSERT_EQ(limit - 1, root_.GetReservation()); |
| 91 | ASSERT_EQ(0, root_.GetUsedReservation()); |
| 92 | ASSERT_EQ(limit - 1, root_.GetUnusedReservation()); |
| 93 | |
| 94 | // Adjust usage. |
| 95 | root_.AllocateFrom(2); |
| 96 | ASSERT_EQ(limit - 1, root_.GetReservation()); |
| 97 | ASSERT_EQ(2, root_.GetUsedReservation()); |
| 98 | ASSERT_EQ(limit - 3, root_.GetUnusedReservation()); |
| 99 | root_.ReleaseTo(1); |
| 100 | ASSERT_EQ(1, root_.GetUsedReservation()); |
| 101 | root_.ReleaseTo(1); |
| 102 | ASSERT_EQ(0, root_.GetUsedReservation()); |
| 103 | ASSERT_EQ(limit - 1, root_.GetReservation()); |
| 104 | ASSERT_EQ(limit - 1, root_.GetUnusedReservation()); |
| 105 | } |
| 106 | |
| 107 | TEST_F(ReservationTrackerTest, BasicTwoLevel) { |
| 108 | const int64_t limit = 16; |
nothing calls this directly
no test coverage detected