<commit_before>#include <gtest/gtest.h>
#include <formatString.h>

TEST(TextTest, IndentationTest) {
    ASSERT_TRUE(true);
}<commit_msg>增加formatText 的测试<commit_after>#include <gtest/gtest.h>
#include <string>
#include <formatString.h>

void pushString(text::FormatString &formatString, const std::string &str) {
    for (char c: str)
        formatString.normalCharProcess(c);
}

void setLineFeed(text::FormatString &formatString, int count) {
    for (int i = 0; i < count; i++)
        formatString.lineFeedProcess();
}

void setBackSpace(text::FormatString &formatString, int count) {
    for (int i = 0; i < count; i++)
        formatString.backSpaceProcess();
}

TEST(FormatTextTest, NormalCharTest) {
    text::FormatString formatString;
    pushString(formatString, "Hello world!");
    ASSERT_STREQ("Hello world!\n", formatString.toString().c_str());
}

TEST(FormatTextTest, lineFeedTest) {
    text::FormatString formatString;
    pushString(formatString, "(");
    setLineFeed(formatString, 3);
    pushString(formatString, ")");
    ASSERT_STREQ(""
                         "(\n"
                         " \n"
                         " \n"
                         " )\n", formatString.toString().c_str());
}

TEST(FormatTextTest, backSpaceTest) {
    text::FormatString formatString;
    pushString(formatString, "(");
    formatString.lineFeedProcess();
    pushString(formatString, "bcd)");

    formatString.backSpaceProcess();
    formatString.backSpaceProcess();
    formatString.lineFeedProcess();
    formatString.normalCharProcess(')');

    ASSERT_STREQ(""
                         "(\n"
                         " bc\n"
                         " )\n", formatString.toString().c_str());
}

TEST(FormatTextTest, multiBracketLineFeedTest) {
    text::FormatString formatString;
    pushString(formatString, "(((");
    setLineFeed(formatString, 3);
    pushString(formatString, ")");
    formatString.lineFeedProcess();
    pushString(formatString, ")");
    formatString.lineFeedProcess();
    pushString(formatString, ")");
    ASSERT_STREQ(""
                         "(((\n"
                         "   \n"
                         "   \n"
                         "   )\n"
                         "  )\n"
                         " )\n", formatString.toString().c_str());
}

TEST(FormatTextTest, MultiBracketBackSpaceTest) {
    text::FormatString formatString;
    pushString(formatString, "(((");
    setLineFeed(formatString, 3);
    pushString(formatString, ")");
    formatString.lineFeedProcess();
    pushString(formatString, ")");
    formatString.lineFeedProcess();
    pushString(formatString, ")");
    setBackSpace(formatString, 4);
    pushString(formatString, ")");
    formatString.lineFeedProcess();
    pushString(formatString, ")");
    ASSERT_STREQ(""
                         "(((\n"
                         "   \n"
                         "   \n"
                         "   ))\n"
                         " )\n", formatString.toString().c_str());
}
{'fraction_non_alphanumeric': 0.1441891441891442, 'fraction_numerical': 0.001998001998001998, 'mean_word_length': 2.330376940133038, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 8, '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': '2602212', 'n_tokens_mistral': 889, 'n_tokens_neox': 858, 'n_words': 136}