<commit_before>#include "helpers.hpp"
#include <combinations.hpp>

#include <set>
#include <vector>
#include <string>
#include <iterator>

#include "catch.hpp"


using iter::combinations;
using itertest::BasicIterable;
using itertest::SolidInt;
using CharCombSet = std::multiset<std::vector<char>>;

TEST_CASE("combinations: Simple combination of 4", "[combinations]") {
    std::string s{"ABCD"};
    CharCombSet sc;
    for (auto v : combinations(s, 2)) {
        std::vector<char> vcopy(std::begin(v), std::end(v));
        sc.insert(vcopy);
    }

    CharCombSet ans = 
        {{'A','B'}, {'A','C'}, {'A','D'}, {'B','C'}, {'B','D'}, {'C','D'}};
    REQUIRE( ans == sc );
}

TEST_CASE("combinations: size too large gives no results", "[combinations]") {
    std::string s{"ABCD"};
    auto c = combinations(s, 5);
    REQUIRE( std::begin(c) == std::end(c) );
}

TEST_CASE("combinations: size 0 gives nothing", "[combinations]") {
    std::string s{"ABCD"};
    auto c = combinations(s, 0);
    REQUIRE( std::begin(c) == std::end(c) );
}

TEST_CASE("combinations: binds to lvalues, moves rvalues", "[combinations]") {
    BasicIterable<char> bi{'x', 'y', 'z'};
    SECTION("binds to lvalues") {
        combinations(bi, 1);
        REQUIRE_FALSE( bi.was_moved_from() );
    }
    SECTION("moves rvalues") {
        combinations(std::move(bi), 1);
        REQUIRE( bi.was_moved_from() );
    }
}

TEST_CASE("combinations: doesn't move or copy elements of iterable",
        "[combinations]") {
    constexpr SolidInt arr[] = {{6}, {7}, {8}};
    for (auto&& i : combinations(arr, 1)) {
        (void)i;
    }
}
<commit_msg>uses vector instead of set so it's printable<commit_after>#include "helpers.hpp"
#include <combinations.hpp>

#include <set>
#include <vector>
#include <string>
#include <iterator>

#include "catch.hpp"


using iter::combinations;
using itertest::BasicIterable;
using itertest::SolidInt;
using CharCombSet = std::vector<std::vector<char>>;

TEST_CASE("combinations: Simple combination of 4", "[combinations]") {
    std::string s{"ABCD"};
    CharCombSet sc;
    for (auto v : combinations(s, 2)) {
        sc.emplace_back(std::begin(v), std::end(v));
    }

    CharCombSet ans = 
        {{'A','B'}, {'A','C'}, {'A','D'}, {'B','C'}, {'B','D'}, {'C','D'}};
    REQUIRE( ans == sc );
}

TEST_CASE("combinations: size too large gives no results", "[combinations]") {
    std::string s{"ABCD"};
    auto c = combinations(s, 5);
    REQUIRE( std::begin(c) == std::end(c) );
}

TEST_CASE("combinations: size 0 gives nothing", "[combinations]") {
    std::string s{"ABCD"};
    auto c = combinations(s, 0);
    REQUIRE( std::begin(c) == std::end(c) );
}

TEST_CASE("combinations: binds to lvalues, moves rvalues", "[combinations]") {
    BasicIterable<char> bi{'x', 'y', 'z'};
    SECTION("binds to lvalues") {
        combinations(bi, 1);
        REQUIRE_FALSE( bi.was_moved_from() );
    }
    SECTION("moves rvalues") {
        combinations(std::move(bi), 1);
        REQUIRE( bi.was_moved_from() );
    }
}

TEST_CASE("combinations: doesn't move or copy elements of iterable",
        "[combinations]") {
    constexpr SolidInt arr[] = {{6}, {7}, {8}};
    for (auto&& i : combinations(arr, 1)) {
        (void)i;
    }
}

{'fraction_non_alphanumeric': 0.19895287958115182, 'fraction_numerical': 0.006775485063135201, 'mean_word_length': 3.906344410876133, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, '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': '6864014', 'n_tokens_mistral': 1216, 'n_tokens_neox': 1149, 'n_words': 265}