<commit_before>#include "unit_tests/tests.hpp"
#include "grune/all.hpp"

using namespace grune;

class grammar_tests : public CppUnit::TestFixture 
{
    CPPUNIT_TEST_SUITE(grammar_tests);
    CPPUNIT_TEST(test_to_string);
    CPPUNIT_TEST(test_generate);
    CPPUNIT_TEST_SUITE_END();

    grammar test_grammar() const
    {
        non_terminal A("A");
        non_terminal B("B");
        non_terminal C("C");

        symbol a("a");
        symbol b("b");
        symbol c("c");

        production p1(
            A, { { a, B } }
        );        
        production p2(
            B, { { b, C } }
        );
        production p3(
            C, { { c }, { } }
        );

        return grammar(
            { A, B, C },
            { a, b, c },
            { p1, p2, p3 }, 
            A
        );
    }

public:
    void test_to_string()
    {
        std::string expected = 
            "A = \"a\", B;\n"
            "B = \"b\", C;\n"
            "C = \"c\" | \"\";\n";
        CPPUNIT_ASSERT_EQUAL(expected, test_grammar().to_string());
    }<commit_msg>Clean up test grammar.<commit_after>#include "unit_tests/tests.hpp"
#include "grune/all.hpp"

using namespace grune;

class grammar_tests : public CppUnit::TestFixture 
{
    CPPUNIT_TEST_SUITE(grammar_tests);
    CPPUNIT_TEST(test_to_string);
    CPPUNIT_TEST(test_generate);
    CPPUNIT_TEST_SUITE_END();

    grammar test_grammar() const
    {
        non_terminal A("A");
        non_terminal B("B");
        non_terminal C("C");

        symbol a("a");
        symbol b("b");
        symbol c("c");

        production p1(
            A, { { a, B } }
        );        
        production p2(
            B, { { b, C } }
        );
        production p3(
            C, { { c } }
        );
        production p4(
            C, { { } }
        );

        return grammar(
            { A, B, C },
            { a, b, c },
            { p1, p2, p3, p4 }, 
            A
        );
    }

public:
    void test_to_string()
    {
        std::string expected = 
            "A = \"a\", B;\n"
            "B = \"b\", C;\n"
            "C = \"c\" | \"\";\n";
        CPPUNIT_ASSERT_EQUAL(expected, test_grammar().to_string());
    }
{'fraction_non_alphanumeric': 0.15129486597001363, 'fraction_numerical': 0.006360745115856429, 'mean_word_length': 1.4575892857142858, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3600583', 'n_tokens_mistral': 769, 'n_tokens_neox': 734, 'n_words': 151}