| 27 | namespace tensorflow { |
| 28 | |
| 29 | TEST(PendingCounts, Simple) { |
| 30 | const int C = 300; |
| 31 | PendingCounts::Layout layout; |
| 32 | std::vector<PendingCounts::Handle> h(C); |
| 33 | for (int id = 0; id < C; id++) { |
| 34 | h[id] = layout.CreateHandle(id, id); |
| 35 | } |
| 36 | |
| 37 | PendingCounts c(layout); |
| 38 | for (int id = 0; id < C; id++) { |
| 39 | c.set_initial_count(h[id], id); |
| 40 | } |
| 41 | for (int id = 0; id < C; id++) { |
| 42 | EXPECT_EQ(c.pending(h[id]), id); |
| 43 | EXPECT_EQ(c.dead_count(h[id]), 0); |
| 44 | } |
| 45 | |
| 46 | for (int id = 0; id < C; id++) { |
| 47 | c.increment_dead_count(h[id]); |
| 48 | // The dead count is no longer updated once pending is 0. |
| 49 | EXPECT_EQ(c.dead_count(h[id]), (id == 0) ? 0 : 1); |
| 50 | } |
| 51 | |
| 52 | EXPECT_EQ(c.decrement_pending(h[1], 1), 0); |
| 53 | EXPECT_EQ(c.decrement_pending(h[3], 1), 2); |
| 54 | EXPECT_EQ(c.decrement_pending(h[3], 1), 1); |
| 55 | c.decrement_pending(h[5], 1); |
| 56 | c.decrement_pending(h[5], 3); |
| 57 | c.decrement_pending(h[170], 1); |
| 58 | c.decrement_pending(h[170], 13); |
| 59 | EXPECT_EQ(c.pending(h[1]), 0); |
| 60 | EXPECT_EQ(c.pending(h[3]), 1); |
| 61 | EXPECT_EQ(c.pending(h[5]), 1); |
| 62 | EXPECT_EQ(c.pending(h[170]), 156); |
| 63 | } |
| 64 | |
| 65 | TEST(PendingCounts, CopyConstructor) { |
| 66 | const int C = 300; |
nothing calls this directly
no test coverage detected