#include <catch2/catch.hpp>
#include <string>
#include <unordered_map>

auto check_code_mapping(
    std::unordered_map<std::string, std::string> const& country_codes,
    std::string const& code,
    std::string const& name) -> void
{
    auto const country = country_codes.find(code);
    REQUIRE(country != country_codes.end());

    auto const [key, value] = *country;
    CHECK(code == key);
    CHECK(name == value);
}

TEST_CASE()
{
    auto country_codes = std::unordered_map<std::string, std::string> {
        { "AU", "Australia" },
        { "NZ", "New Zealand" },
        { "CK", "Cook Islands" },
        { "ID", "Indonesia" },
        { "DK", "Denmark" },
        { "CN", "China" },
        { "JP", "Japan" },
        { "ZM", "Zambia" },
        { "YE", "Yemen" },
        { "CA", "Canada" },
        { "BR", "Brazil" },
        { "AQ", "Antarctica" },
    };
    CHECK(country_codes.contains("AU"));
    CHECK(not country_codes.contains("DE")); // Germany not present
    country_codes.emplace("DE", "Germany");
    CHECK(country_codes.contains("DE"));
}
