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