|
| 1 | +#include "CorePortIndexMapContainer.h" |
| 2 | + |
| 3 | +#include <gtest/gtest.h> |
| 4 | + |
| 5 | +using namespace saivs; |
| 6 | + |
| 7 | +TEST(CorePortIndexMapContainer, remove) |
| 8 | +{ |
| 9 | + auto cpim = std::make_shared<CorePortIndexMap>(0); |
| 10 | + |
| 11 | + CorePortIndexMapContainer cpimc; |
| 12 | + |
| 13 | + cpimc.insert(cpim); |
| 14 | + |
| 15 | + EXPECT_EQ(cpimc.size(), 1); |
| 16 | + |
| 17 | + cpimc.remove(1); |
| 18 | + |
| 19 | + EXPECT_EQ(cpimc.size(), 1); |
| 20 | + |
| 21 | + cpimc.remove(0); |
| 22 | + |
| 23 | + EXPECT_EQ(cpimc.size(), 0); |
| 24 | +} |
| 25 | + |
| 26 | +TEST(CorePortIndexMapContainer, getCorePortIndexMap) |
| 27 | +{ |
| 28 | + auto cpim = std::make_shared<CorePortIndexMap>(0); |
| 29 | + |
| 30 | + CorePortIndexMapContainer cpimc; |
| 31 | + |
| 32 | + cpimc.insert(cpim); |
| 33 | + |
| 34 | + EXPECT_EQ(cpimc.getCorePortIndexMap(1), nullptr); |
| 35 | + |
| 36 | + EXPECT_NE(cpimc.getCorePortIndexMap(0), nullptr); |
| 37 | +} |
| 38 | + |
| 39 | +TEST(CorePortIndexMapContainer, clear) |
| 40 | +{ |
| 41 | + auto cpim = std::make_shared<CorePortIndexMap>(0); |
| 42 | + |
| 43 | + CorePortIndexMapContainer cpimc; |
| 44 | + |
| 45 | + cpimc.insert(cpim); |
| 46 | + |
| 47 | + EXPECT_EQ(cpimc.size(), 1); |
| 48 | + |
| 49 | + cpimc.clear(); |
| 50 | + |
| 51 | + EXPECT_EQ(cpimc.size(), 0); |
| 52 | +} |
| 53 | + |
| 54 | +TEST(CorePortIndexMapContainer, hasCorePortIndexMap) |
| 55 | +{ |
| 56 | + auto cpim = std::make_shared<CorePortIndexMap>(0); |
| 57 | + |
| 58 | + CorePortIndexMapContainer cpimc; |
| 59 | + |
| 60 | + cpimc.insert(cpim); |
| 61 | + |
| 62 | + EXPECT_EQ(cpimc.hasCorePortIndexMap(0), true); |
| 63 | + |
| 64 | + EXPECT_EQ(cpimc.hasCorePortIndexMap(1), false); |
| 65 | +} |
| 66 | + |
| 67 | +TEST(CorePortIndexMapContainer, removeEmptyCorePortIndexMaps) |
| 68 | +{ |
| 69 | + auto cpime = std::make_shared<CorePortIndexMap>(0); |
| 70 | + |
| 71 | + CorePortIndexMapContainer cpimc; |
| 72 | + |
| 73 | + cpimc.insert(cpime); |
| 74 | + |
| 75 | + auto cpim = std::make_shared<CorePortIndexMap>(1); |
| 76 | + |
| 77 | + std::vector<uint32_t> ok {1,0}; |
| 78 | + |
| 79 | + EXPECT_EQ(cpim->add("foo", ok), true); |
| 80 | + |
| 81 | + EXPECT_EQ(cpim->isEmpty(), false); |
| 82 | + |
| 83 | + cpimc.insert(cpim); |
| 84 | + |
| 85 | + EXPECT_EQ(cpimc.size(), 2); |
| 86 | + |
| 87 | + cpimc.removeEmptyCorePortIndexMaps(); |
| 88 | + |
| 89 | + EXPECT_EQ(cpimc.size(), 1); |
| 90 | +} |
0 commit comments