<commit_before>#include "TMAPI.h"
#include "TMExceptions.h"

#define BOOST_TEST_NO_LIB
#include <boost/test/unit_test.hpp>
using namespace std;

struct TMAPITestFixture {
    TMAPITestFixture() : api(tapeLength) {}

    const size_t tapeLength = 11;
    const size_t startHeadPosition = 11/2;
    TMAPI api;
};
BOOST_FIXTURE_TEST_SUITE(plain_API_for_11_long_tape, TMAPITestFixture)

BOOST_AUTO_TEST_CASE( example_proper_use_with_instant_execution ) {
    api.insertAlphabet("#10");
    api.insertGraph({"Start #/1;L next", "next #/1;L next2", "next2 #/0;L Stop"});
    api.compileInstertedGraph();
    api.executeGraphInstantly(); // ########### >> ###011#####
    // head position:                    ^           ^
    std::array<char, 11> outputTape = {'#', '#', '#', '0', '1', '1', '#', '#', '#', '#', '#'};
    BOOST_CHECK_EQUAL_COLLECTIONS(api.tape->begin(), api.tape->end(), outputTape.begin(), outputTape.end());
    BOOST_CHECK_EQUAL(api.tape->getHeadPosition(), startHeadPosition - 3);
}

BOOST_AUTO_TEST_CASE( example_proper_use_with_setting_custom_HeadPositon_with_instant_execution ) {
    api.insertAlphabet("#10");
    api.setHeadPosition(startHeadPosition - 1);
    api.insertGraph({"Start #/1;L next", "next #/1;L next2", "next2 #/0;L Stop"});
    api.compileInstertedGraph();
    api.executeGraphInstantly(); // ########### >> ##011######
    // head position:                   ^           ^
    std::array<char, 11> outputTape = {'#', '#', '0', '1', '1', '#', '#', '#', '#', '#', '#'};
    BOOST_CHECK_EQUAL_COLLECTIONS(api.tape->begin(), api.tape->end(), outputTape.begin(), outputTape.end());
    BOOST_CHECK_EQUAL(api.tape->getHeadPosition(), startHeadPosition - 3 - 1);
}

BOOST_AUTO_TEST_CASE( doSingleStep_on_the_tape ) {
    api.insertAlphabet("#10");
    api.insertGraph({"Start #/1;L next", "next #/1;L next2", "next2 #/0;L Stop"});
    api.compileInstertedGraph();
    api.doSingleStep(); // ########### >> #####1#####
    // head position:           ^             ^
    std::array<char, 11> outputTape = {'#', '#', '#', '#', '#', '1', '#', '#', '#', '#', '#'};
    BOOST_CHECK_EQUAL_COLLECTIONS(api.tape->begin(), api.tape->end(), outputTape.begin(), outputTape.end());
    BOOST_CHECK_EQUAL(api.tape->getHeadPosition(), startHeadPosition - 1);
}

BOOST_AUTO_TEST_CASE( doSingleStep_on_the_tape_with_previously_set_headPosition ) {
    api.insertAlphabet("#10");
    api.setHeadPosition(startHeadPosition - 1);
    api.insertGraph({"Start #/1;L next", "next #/1;L next2", "next2 #/0;L Stop"});
    api.compileInstertedGraph();
    api.doSingleStep(); // ########### >> ####1######
    // head position:          ^             ^
    std::array<char, 11> outputTape = {'#', '#', '#', '#', '1', '#', '#', '#', '#', '#', '#'};
    BOOST_CHECK_EQUAL_COLLECTIONS(api.tape->begin(), api.tape->end(), outputTape.begin(), outputTape.end());
    BOOST_CHECK_EQUAL(api.tape->getHeadPosition(), startHeadPosition - 1 - 1);
}

BOOST_AUTO_TEST_CASE( execution_without_setting_alphabet ) {
    api.insertGraph({"Start #/1;L next", "next #/1;L next2", "next2 #/0;L Stop"});
    api.compileInstertedGraph();
    BOOST_CHECK_THROW(api.doSingleStep(), CharacterOutOfAlphabet);
    BOOST_CHECK_THROW(api.executeGraphInstantly(), CharacterOutOfAlphabet);
    BOOST_CHECK_EQUAL(api.tape->getHeadPosition(), startHeadPosition);
}

BOOST_AUTO_TEST_CASE( execution_without_compilation_of_the_graph ) {
    api.insertAlphabet("#10");
    api.insertGraph({"Start #/1;L next", "next #/1;L next2", "next2 #/0;L Stop"});
    BOOST_CHECK_THROW(api.executeGraphInstantly(), CommandNotExist);
    BOOST_CHECK_THROW(api.doSingleStep(), CommandNotExist);
    BOOST_CHECK_EQUAL(api.tape->getHeadPosition(), startHeadPosition);
}

BOOST_AUTO_TEST_CASE( execution_without_the_graph ) {
    api.insertAlphabet("#10");
    api.compileInstertedGraph();
    BOOST_CHECK_THROW(api.executeGraphInstantly(), CommandNotExist);
    BOOST_CHECK_THROW(api.doSingleStep(), CommandNotExist);<commit_msg>[FIX] misspelling from API class<commit_after>#include "TMAPI.h"
#include "TMExceptions.h"

#define BOOST_TEST_NO_LIB
#include <boost/test/unit_test.hpp>
using namespace std;

struct TMAPITestFixture {
    TMAPITestFixture() : api(tapeLength) {}

    const size_t tapeLength = 11;
    const size_t startHeadPosition = 11/2;
    TMAPI api;
};
BOOST_FIXTURE_TEST_SUITE(plain_API_for_11_long_tape, TMAPITestFixture)

BOOST_AUTO_TEST_CASE( example_proper_use_with_instant_execution ) {
    api.insertAlphabet("#10");
    api.insertGraph({"Start #/1;L next", "next #/1;L next2", "next2 #/0;L Stop"});
    api.compileInsertedGraph();
    api.executeGraphInstantly(); // ########### >> ###011#####
    // head position:                    ^           ^
    std::array<char, 11> outputTape = {'#', '#', '#', '0', '1', '1', '#', '#', '#', '#', '#'};
    BOOST_CHECK_EQUAL_COLLECTIONS(api.tape->begin(), api.tape->end(), outputTape.begin(), outputTape.end());
    BOOST_CHECK_EQUAL(api.tape->getHeadPosition(), startHeadPosition - 3);
}

BOOST_AUTO_TEST_CASE( example_proper_use_with_setting_custom_HeadPositon_with_instant_execution ) {
    api.insertAlphabet("#10");
    api.setHeadPosition(startHeadPosition - 1);
    api.insertGraph({"Start #/1;L next", "next #/1;L next2", "next2 #/0;L Stop"});
    api.compileInsertedGraph();
    api.executeGraphInstantly(); // ########### >> ##011######
    // head position:                   ^           ^
    std::array<char, 11> outputTape = {'#', '#', '0', '1', '1', '#', '#', '#', '#', '#', '#'};
    BOOST_CHECK_EQUAL_COLLECTIONS(api.tape->begin(), api.tape->end(), outputTape.begin(), outputTape.end());
    BOOST_CHECK_EQUAL(api.tape->getHeadPosition(), startHeadPosition - 3 - 1);
}

BOOST_AUTO_TEST_CASE( doSingleStep_on_the_tape ) {
    api.insertAlphabet("#10");
    api.insertGraph({"Start #/1;L next", "next #/1;L next2", "next2 #/0;L Stop"});
    api.compileInsertedGraph();
    api.doSingleStep(); // ########### >> #####1#####
    // head position:           ^             ^
    std::array<char, 11> outputTape = {'#', '#', '#', '#', '#', '1', '#', '#', '#', '#', '#'};
    BOOST_CHECK_EQUAL_COLLECTIONS(api.tape->begin(), api.tape->end(), outputTape.begin(), outputTape.end());
    BOOST_CHECK_EQUAL(api.tape->getHeadPosition(), startHeadPosition - 1);
}

BOOST_AUTO_TEST_CASE( doSingleStep_on_the_tape_with_previously_set_headPosition ) {
    api.insertAlphabet("#10");
    api.setHeadPosition(startHeadPosition - 1);
    api.insertGraph({"Start #/1;L next", "next #/1;L next2", "next2 #/0;L Stop"});
    api.compileInsertedGraph();
    api.doSingleStep(); // ########### >> ####1######
    // head position:          ^             ^
    std::array<char, 11> outputTape = {'#', '#', '#', '#', '1', '#', '#', '#', '#', '#', '#'};
    BOOST_CHECK_EQUAL_COLLECTIONS(api.tape->begin(), api.tape->end(), outputTape.begin(), outputTape.end());
    BOOST_CHECK_EQUAL(api.tape->getHeadPosition(), startHeadPosition - 1 - 1);
}

BOOST_AUTO_TEST_CASE( execution_without_setting_alphabet ) {
    api.insertGraph({"Start #/1;L next", "next #/1;L next2", "next2 #/0;L Stop"});
    api.compileInsertedGraph();
    BOOST_CHECK_THROW(api.doSingleStep(), CharacterOutOfAlphabet);
    BOOST_CHECK_THROW(api.executeGraphInstantly(), CharacterOutOfAlphabet);
    BOOST_CHECK_EQUAL(api.tape->getHeadPosition(), startHeadPosition);
}

BOOST_AUTO_TEST_CASE( execution_without_compilation_of_the_graph ) {
    api.insertAlphabet("#10");
    api.insertGraph({"Start #/1;L next", "next #/1;L next2", "next2 #/0;L Stop"});
    BOOST_CHECK_THROW(api.executeGraphInstantly(), CommandNotExist);
    BOOST_CHECK_THROW(api.doSingleStep(), CommandNotExist);
    BOOST_CHECK_EQUAL(api.tape->getHeadPosition(), startHeadPosition);
}

BOOST_AUTO_TEST_CASE( execution_without_the_graph ) {
    api.insertAlphabet("#10");
    api.compileInsertedGraph();
    BOOST_CHECK_THROW(api.executeGraphInstantly(), CommandNotExist);
    BOOST_CHECK_THROW(api.doSingleStep(), CommandNotExist);
{'fraction_non_alphanumeric': 0.20107809953616648, 'fraction_numerical': 0.020308386611508085, 'mean_word_length': 4.5058661145617664, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5001048', 'n_tokens_mistral': 2915, 'n_tokens_neox': 2787, 'n_words': 389}