<commit_before>#define BOOST_TEST_MODULE "test_util_flat_map"

#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
#include <boost/test/unit_test.hpp>
#else
#define BOOST_TEST_NO_LIB
#include <boost/test/included/unit_test.hpp>
#endif

#include "util/flat_map.hpp"

BOOST_AUTO_TEST_CASE(construct)
{
    {
        const mill::flat_map<std::string, int> fm;
        BOOST_TEST(fm.empty());
        BOOST_TEST(fm.size() == 0u);
        BOOST_TEST(not fm.contains("foo"));
        BOOST_TEST(not fm.contains("bar"));
        BOOST_TEST(fm.count("foo") == 0u);
        BOOST_TEST(fm.count("bar") == 0u);
    }
    {
        const mill::flat_map<std::string, int> fm{{"foo", 42}, {"bar", 54}};
        BOOST_TEST(not fm.empty());
        BOOST_TEST(fm.size() == 2u);
        BOOST_TEST(fm.contains("foo"));
        BOOST_TEST(fm.contains("bar"));
        BOOST_TEST(fm.count("foo") == 1u);
        BOOST_TEST(fm.count("bar") == 1u);
        BOOST_TEST(fm.at("foo") == 42);
        BOOST_TEST(fm.at("bar") == 54);
    }
    {
        mill::flat_map<std::string, int> fm;
        BOOST_TEST(fm.empty());
        BOOST_TEST(fm.size() == 0u);

        fm = {{"foo", 42}, {"bar", 54}};
        BOOST_TEST(not fm.empty());
        BOOST_TEST(fm.size() == 2u);
        BOOST_TEST(fm.contains("foo"));
        BOOST_TEST(fm.contains("bar"));
        BOOST_TEST(fm.count("foo") == 1u);
        BOOST_TEST(fm.count("bar") == 1u);
        BOOST_TEST(fm.at("foo") == 42);
        BOOST_TEST(fm.at("bar") == 54);
    }
    {
        const std::vector<std::pair<std::string, int>> list = {{"foo", 42}, {"bar", 54}};
        const mill::flat_map<std::string, int> fm(list.begin(), list.end());
        BOOST_TEST(not fm.empty());
        BOOST_TEST(fm.size() == 2u);
        BOOST_TEST(fm.contains("foo"));
        BOOST_TEST(fm.contains("bar"));
        BOOST_TEST(fm.count("foo") == 1u);
        BOOST_TEST(fm.count("bar") == 1u);
        BOOST_TEST(fm.at("foo") == 42);
        BOOST_TEST(fm.at("bar") == 54);
    }
}

BOOST_AUTO_TEST_CASE(insertion)
{
    {
        mill::flat_map<std::string, int> fm;
        BOOST_TEST(fm.empty());
        BOOST_TEST(fm.size() == 0u);

        fm["foo"] = 42;
        fm.emplace("bar", 54);
        fm.insert(std::make_pair("baz", 69));

        BOOST_TEST(not fm.empty());
        BOOST_TEST(fm.size() == 3u);
        BOOST_TEST(fm.at("foo") == 42);
        BOOST_TEST(fm.at("bar") == 54);
        BOOST_TEST(fm.at("baz") == 69);
    }
}<commit_msg>:white_check_mark: add test for insertion<commit_after>#define BOOST_TEST_MODULE "test_util_flat_map"

#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
#include <boost/test/unit_test.hpp>
#else
#define BOOST_TEST_NO_LIB
#include <boost/test/included/unit_test.hpp>
#endif

#include "util/flat_map.hpp"

BOOST_AUTO_TEST_CASE(construct)
{
    {
        const mill::flat_map<std::string, int> fm;
        BOOST_TEST(fm.empty());
        BOOST_TEST(fm.size() == 0u);
        BOOST_TEST(not fm.contains("foo"));
        BOOST_TEST(not fm.contains("bar"));
        BOOST_TEST(fm.count("foo") == 0u);
        BOOST_TEST(fm.count("bar") == 0u);
    }
    {
        const mill::flat_map<std::string, int> fm{{"foo", 42}, {"bar", 54}};
        BOOST_TEST(not fm.empty());
        BOOST_TEST(fm.size() == 2u);
        BOOST_TEST(fm.contains("foo"));
        BOOST_TEST(fm.contains("bar"));
        BOOST_TEST(fm.count("foo") == 1u);
        BOOST_TEST(fm.count("bar") == 1u);
        BOOST_TEST(fm.at("foo") == 42);
        BOOST_TEST(fm.at("bar") == 54);
    }
    {
        mill::flat_map<std::string, int> fm;
        BOOST_TEST(fm.empty());
        BOOST_TEST(fm.size() == 0u);

        fm = {{"foo", 42}, {"bar", 54}};
        BOOST_TEST(not fm.empty());
        BOOST_TEST(fm.size() == 2u);
        BOOST_TEST(fm.contains("foo"));
        BOOST_TEST(fm.contains("bar"));
        BOOST_TEST(fm.count("foo") == 1u);
        BOOST_TEST(fm.count("bar") == 1u);
        BOOST_TEST(fm.at("foo") == 42);
        BOOST_TEST(fm.at("bar") == 54);
    }
    {
        const std::vector<std::pair<std::string, int>> list = {{"foo", 42}, {"bar", 54}};
        const mill::flat_map<std::string, int> fm(list.begin(), list.end());
        BOOST_TEST(not fm.empty());
        BOOST_TEST(fm.size() == 2u);
        BOOST_TEST(fm.contains("foo"));
        BOOST_TEST(fm.contains("bar"));
        BOOST_TEST(fm.count("foo") == 1u);
        BOOST_TEST(fm.count("bar") == 1u);
        BOOST_TEST(fm.at("foo") == 42);
        BOOST_TEST(fm.at("bar") == 54);
    }
}

BOOST_AUTO_TEST_CASE(insertion)
{
    {
        mill::flat_map<std::string, int> fm;
        BOOST_TEST(fm.empty());
        BOOST_TEST(fm.size() == 0u);

        fm["foo"] = 42;
        fm.emplace("bar", 54);
        fm.insert(std::make_pair("baz", 69));

        BOOST_TEST(not fm.empty());
        BOOST_TEST(fm.diagnosis());
        BOOST_TEST(fm.size() == 3u);

        BOOST_TEST(fm.at("foo") == 42);
        BOOST_TEST(fm.at("bar") == 54);
        BOOST_TEST(fm.at("baz") == 69);
    }
    {
        mill::flat_map<std::string, int> fm;
        BOOST_TEST(fm.empty());
        BOOST_TEST(fm.size() == 0u);

        const std::vector<std::pair<std::string, int>> list = {{"foo", 42}, {"bar", 54}, {"baz", 69}};

        fm.insert(list.begin(), list.end());

        BOOST_TEST(not fm.empty());
        BOOST_TEST(fm.diagnosis());
        BOOST_TEST(fm.size() == 3u);

        BOOST_TEST(fm.at("foo") == 42);
        BOOST_TEST(fm.at("bar") == 54);
        BOOST_TEST(fm.at("baz") == 69);
    }

}
{'fraction_non_alphanumeric': 0.20670187579675833, 'fraction_numerical': 0.021125478054999088, 'mean_word_length': 2.7083051991897364, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4094994', 'n_tokens_mistral': 2227, 'n_tokens_neox': 1961, 'n_words': 288}