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