aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/iterator/ut/iterate_keys_ut.cpp
blob: 49eb866b6eca7f0c71d0950a86720612514b8776 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <library/cpp/iterator/iterate_keys.h>

#include <library/cpp/testing/gtest/gtest.h>

#include <map>

using namespace testing;

TEST(IterateKeys, ConstMappingIteration) {
    const std::map<int, int> squares{
        {1, 1},
        {2, 4},
        {3, 9},
    };
    EXPECT_THAT(
        IterateKeys(squares),
        ElementsAre(1, 2, 3)
    );
}

TEST(IterateKeys, ConstMultiMappingIteration) {
    const std::multimap<int, int> primesBelow{
        {2, 2},
        {5, 3},
        {5, 5},
        {11, 7},
        {11, 11},
        {23, 13},
        {23, 17},
        {23, 23},
    };

    EXPECT_THAT(
        IterateKeys(primesBelow),
        ElementsAre(2, 5, 5, 11, 11, 23, 23, 23)
    );
}