1 #include "utils/stl_utils.hpp"
2
3 #include <string>
4 #include <vector>
5
6 #include <gmock/gmock.h>
7 #include <gtest/gtest.h>
8
9 namespace redfish::stl_utils
10 {
11 namespace
12 {
13 using ::testing::ElementsAre;
14
TEST(FirstDuplicate,ReturnsIteratorToFirstDuplicate)15 TEST(FirstDuplicate, ReturnsIteratorToFirstDuplicate)
16 {
17 std::vector<std::string> strVec = {"s1", "s4", "s1", "s2", "", "s3", "s3"};
18 auto iter = firstDuplicate(strVec.begin(), strVec.end());
19 ASSERT_NE(iter, strVec.end());
20 EXPECT_EQ(*iter, "s3");
21 }
22
TEST(RemoveDuplicates,AllDuplicatesAreRempvedInplace)23 TEST(RemoveDuplicates, AllDuplicatesAreRempvedInplace)
24 {
25 std::vector<std::string> strVec = {"s1", "s4", "s1", "s2", "", "s3", "s3"};
26 removeDuplicate(strVec);
27
28 EXPECT_THAT(strVec, ElementsAre("s1", "s4", "s2", "", "s3"));
29 }
30 } // namespace
31 } // namespace redfish::stl_utils
32