<commit_before>#include "init.hpp"

#include "CatchingRule"
#include "PredicateRule"

using namespace sprout;

struct FakeException {};

BOOST_AUTO_TEST_CASE(testCatching)
{
    auto rule = makeCatching<FakeException>(
        makeAddingPredicate<char, std::string>([](const char& input) {
            if (input == 'a') {
                throw FakeException();
            }
            return true;
        })
    );

    {
        std::stringstream str("abc");
        auto cursor = makeCursor<char>(str);

        auto tokens = rule.parse(cursor);
        BOOST_CHECK(!tokens);
    }

    {
        std::stringstream str("bbb");
        auto cursor = makeCursor<char>(str);

        auto tokens = rule.parse(cursor);
        BOOST_REQUIRE(tokens);
        std::cout << *tokens << std::endl;
        BOOST_CHECK(*tokens == "bbb");
    }
}<commit_msg>minor debug<commit_after>#include "init.hpp"

#include "CatchingRule"
#include "PredicateRule"

using namespace sprout;

struct FakeException {};

BOOST_AUTO_TEST_CASE(testCatching)
{
    auto rule = makeCatching<FakeException>(
        makeAddingPredicate<char, std::string>([](const char& input) {
            if (input == 'a') {
                throw FakeException();
            }
            return true;
        })
    );

    {
        std::stringstream str("abc");
        auto cursor = makeCursor<char>(str);

        auto tokens = rule.parse(cursor);
        BOOST_CHECK(!tokens);
    }

    {
        std::stringstream str("bbb");
        auto cursor = makeCursor<char>(str);

        auto tokens = rule.parse(cursor);
        BOOST_REQUIRE(tokens);
        BOOST_CHECK(*tokens == "bbb");
    }
}
{'fraction_non_alphanumeric': 0.13622664255575648, 'fraction_numerical': 0.0, 'mean_word_length': 2.367139959432049, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 11, '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': '3046213', 'n_tokens_mistral': 514, 'n_tokens_neox': 489, 'n_words': 96}