<commit_before>// Copyright 2010-2012 RethinkDB, all rights reserved.
#include "unittest/gtest.hpp"

#include "mock/dummy_protocol.hpp"
#include "protocol_api.hpp"

namespace unittest {
using mock::dummy_protocol_t;
TEST(RegionMap, BasicSets) {
    region_map_t<dummy_protocol_t, int> rmap(dummy_protocol_t::region_t('a', 'z'), 0);
    rmap.set(dummy_protocol_t::region_t('a', 'm'), 1);
    rmap.set(dummy_protocol_t::region_t('n', 'z'), 2);
    for (region_map_t<dummy_protocol_t, int>::iterator it  = rmap.begin();
         it != rmap.end();
         ++it) {
        if (region_is_superset(dummy_protocol_t::region_t('a', 'm'), it->first)) {
            EXPECT_EQ(1, it->second);
        } else if (region_is_superset(dummy_protocol_t::region_t('n', 'z'), it->first)) {
            EXPECT_EQ(2, it->second);
        } else {
            ADD_FAILURE() << "Got unexpected region from region map.";
        }
    }
}

TEST(RegionMap, Mask) {
    region_map_t<dummy_protocol_t, int> rmap(dummy_protocol_t::region_t('a', 'z'), 0);
    rmap.set(dummy_protocol_t::region_t('a', 'm'), 1);
    rmap.set(dummy_protocol_t::region_t('n', 'z'), 2);

    region_map_t<dummy_protocol_t, int> masked_map = rmap.mask(dummy_protocol_t::region_t('g', 'r'));

    EXPECT_TRUE(masked_map.get_domain() == dummy_protocol_t::region_t('g', 'r'));

    for (region_map_t<dummy_protocol_t, int>::iterator it  = masked_map.begin();
         it != masked_map.end();
         ++it) {
        if (region_is_superset(dummy_protocol_t::region_t('a', 'm'), it->first)) {
            EXPECT_EQ(1, it->second);
        } else if (region_is_superset(dummy_protocol_t::region_t('n', 'z'), it->first)) {
            EXPECT_EQ(2, it->second);
        } else {
            ADD_FAILURE() << "Got unexpected region from region map.";
        }
    }
}
} //namespace unittest<commit_msg>Made the RegionMap tests use the rdb protocol.<commit_after>// Copyright 2010-2012 RethinkDB, all rights reserved.
#include "unittest/gtest.hpp"

#include "hash_region.hpp"
#include "rdb_protocol/protocol.hpp"
#include "protocol_api.hpp"

namespace unittest {

hash_region_t<key_range_t> make_region(std::string low, std::string high) {
    return hash_region_t<key_range_t>(key_range_t(key_range_t::closed, store_key_t(low),
                                                  key_range_t::open, store_key_t(high)));
}

TEST(RegionMap, BasicSets) {
    region_map_t<rdb_protocol_t, int> rmap(make_region("a", "z"), 0);
    rmap.set(make_region("a", "n"), 1);
    rmap.set(make_region("n", "z"), 2);
    for (region_map_t<rdb_protocol_t, int>::iterator it  = rmap.begin();
         it != rmap.end();
         ++it) {
        if (region_is_superset(make_region("a", "n"), it->first)) {
            EXPECT_EQ(1, it->second);
        } else if (region_is_superset(make_region("n", "z"), it->first)) {
            EXPECT_EQ(2, it->second);
        } else {
            ADD_FAILURE() << "Got unexpected region from region map.";
        }
    }
}

TEST(RegionMap, Mask) {
    region_map_t<rdb_protocol_t, int> rmap(make_region("a", "z"), 0);
    rmap.set(make_region("a", "n"), 1);
    rmap.set(make_region("n", "z"), 2);

    region_map_t<rdb_protocol_t, int> masked_map = rmap.mask(make_region("g", "s"));

    EXPECT_TRUE(masked_map.get_domain() == make_region("g", "s"));

    for (region_map_t<rdb_protocol_t, int>::iterator it  = masked_map.begin();
         it != masked_map.end();
         ++it) {
        if (region_is_superset(make_region("a", "n"), it->first)) {
            EXPECT_EQ(1, it->second);
        } else if (region_is_superset(make_region("n", "z"), it->first)) {
            EXPECT_EQ(2, it->second);
        } else {
            ADD_FAILURE() << "Got unexpected region from region map.";
        }
    }
}
} //namespace unittest
{'fraction_non_alphanumeric': 0.17119493537325245, 'fraction_numerical': 0.00949617515167502, 'mean_word_length': 3.328767123287671, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4482102', 'n_tokens_mistral': 1385, 'n_tokens_neox': 1363, 'n_words': 238}