<commit_before>#include "core/wordwrap.h"

#include "tests/stringeq.h"
#include "catch.hpp"

using namespace euphoria::core;
using namespace euphoria::tests;


TEST_CASE("test wordwrap", "[wordwrap]")
{
    auto measure = [](const std::string& str) { return str.size() <= 6; };

    CHECK(StringEq(WordWrap("", measure), {""}));
    CHECK(StringEq(WordWrap("aaa bb", measure), {"aaa bb"}));
    CHECK(StringEq(WordWrap("123456789", measure), {"123456789"}));
    CHECK(StringEq(WordWrap("dog 123456789", measure), {"dog", "123456789"}));
    CHECK(StringEq(WordWrap("123456789 dog", measure), {"123456789", "dog"}));
    CHECK(StringEq(WordWrap("AAA BB CC DDDDD", measure), {
        "AAA BB",
        "CC",
        "DDDDD"
    }));
}<commit_msg>added reference link<commit_after>#include "core/wordwrap.h"

#include "tests/stringeq.h"
#include "catch.hpp"

using namespace euphoria::core;
using namespace euphoria::tests;


TEST_CASE("test wordwrap", "[wordwrap]")
{
    auto measure = [](const std::string& str) { return str.size() <= 6; };

    CHECK(StringEq(WordWrap("", measure), {""}));
    CHECK(StringEq(WordWrap("aaa bb", measure), {"aaa bb"}));
    CHECK(StringEq(WordWrap("123456789", measure), {"123456789"}));
    CHECK(StringEq(WordWrap("dog 123456789", measure), {"dog", "123456789"}));
    CHECK(StringEq(WordWrap("123456789 dog", measure), {"123456789", "dog"}));

    // AAA sample from https://en.wikipedia.org/wiki/Line_wrap_and_word_wrap#Minimum_raggedness
    CHECK(StringEq(WordWrap("AAA BB CC DDDDD", measure), {
        "AAA BB",
        "CC",
        "DDDDD"
    }));
}
{'fraction_non_alphanumeric': 0.19799498746867167, 'fraction_numerical': 0.06892230576441102, 'mean_word_length': 4.807272727272728, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 1, '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': '6054530', 'n_tokens_mistral': 637, 'n_tokens_neox': 526, 'n_words': 110}