Files
cpp-course/modules/07_stl_containers/test/associative_containers_test.cpp
T

19 lines
594 B
C++
Raw Normal View History

2026-08-11 17:40:36 +03:00
#include "associative_containers.hpp"
#include <gtest/gtest.h>
TEST(AssociativeContainers, WordFrequencies) {
const auto freq = stl_containers::word_frequencies({"a", "b", "a"});
EXPECT_EQ(freq.at("a"), 2);
EXPECT_EQ(freq.at("b"), 1);
}
TEST(AssociativeContainers, UniqueSorted) {
EXPECT_EQ(stl_containers::unique_sorted({3, 1, 2, 2}), (std::set<int>{1, 2, 3}));
}
TEST(AssociativeContainers, InvertMap) {
const std::map<int, std::string> input{{1, "one"}, {2, "two"}};
const auto inverted = stl_containers::invert_map(input);
EXPECT_EQ(inverted.at("one"), 1);
}