iterate_keys_ut.cpp 707 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include <library/cpp/iterator/iterate_keys.h>
  2. #include <library/cpp/testing/gtest/gtest.h>
  3. #include <map>
  4. using namespace testing;
  5. TEST(IterateKeys, ConstMappingIteration) {
  6. const std::map<int, int> squares{
  7. {1, 1},
  8. {2, 4},
  9. {3, 9},
  10. };
  11. EXPECT_THAT(
  12. IterateKeys(squares),
  13. ElementsAre(1, 2, 3)
  14. );
  15. }
  16. TEST(IterateKeys, ConstMultiMappingIteration) {
  17. const std::multimap<int, int> primesBelow{
  18. {2, 2},
  19. {5, 3},
  20. {5, 5},
  21. {11, 7},
  22. {11, 11},
  23. {23, 13},
  24. {23, 17},
  25. {23, 23},
  26. };
  27. EXPECT_THAT(
  28. IterateKeys(primesBelow),
  29. ElementsAre(2, 5, 5, 11, 11, 23, 23, 23)
  30. );
  31. }