1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- // Not sure where to begin with gtest?
- //
- // What can I test with gtest?
- //
- // googletest/googletest/docs/primer.md
- #include "lastseen.h"
- #include "gtest/gtest.h"
- namespace {
- TEST(LastSeenTest, negative) {
- LastSeen zero(2);
- // buffer: -1, -1
- EXPECT_TRUE(zero.seen_before(-1));
- EXPECT_TRUE(zero.seen_before(-1));
- }
- TEST(LastSeenTest, basic) {
- LastSeen one(1);
- EXPECT_FALSE(one.seen_before(0));
- EXPECT_TRUE(one.seen_before(0));
- EXPECT_TRUE(one.seen_before(0));
- EXPECT_FALSE(one.seen_before(1));
- EXPECT_TRUE(one.seen_before(1));
- EXPECT_FALSE(one.seen_before(0));
- }
- TEST(LastSeenTest, Deep2) {
- LastSeen two(2);
- EXPECT_FALSE(two.seen_before(0));
- EXPECT_FALSE(two.seen_before(1));
- // buffer: 0, 1
- EXPECT_TRUE(two.seen_before(0));
- EXPECT_TRUE(two.seen_before(1));
- EXPECT_TRUE(two.seen_before(0));
- EXPECT_TRUE(two.seen_before(1));
- EXPECT_FALSE(two.seen_before(2));
- // buffer: 1, 2
- EXPECT_TRUE(two.seen_before(2));
- EXPECT_TRUE(two.seen_before(1));
- EXPECT_TRUE(two.seen_before(2));
- EXPECT_TRUE(two.seen_before(1));
- EXPECT_FALSE(two.seen_before(0));
- }
- TEST(LastSeenTest, More) {
- int x;
- LastSeen seven(7);
- for (x = 0; x < 7; x++) {
- EXPECT_FALSE(seven.seen_before(x));
- }
- for (x = 0; x < 7; x++) {
- EXPECT_TRUE(seven.seen_before(x));
- }
- EXPECT_FALSE(seven.seen_before(8));
- }
- } // namespace
|