<commit_before>/**
 * Tests of str_rope and rope_node.
 *
 * @author <NAME>
 **/

#include <catch.hpp>
#include <primitives/str_rope.h>

TEST_CASE("Empty rope_node", "[rope_node]") {
    std::unique_ptr<rope_node> node = std::make_unique<rope_node>();

    SECTION("Empty node has nullptr left & right") {
        REQUIRE(!node->data.left);
        REQUIRE(!node->data.right);
    }

    SECTION("Empty node to string") {
        REQUIRE(*node->to_string().get() == "");
    }
}

TEST_CASE("String rope_node", "[rope_node]") {
    std::unique_ptr<rope_node> node = std::make_unique<rope_node>(std::string("wow!"));
}

TEST_CASE("Copy constructor for rope_node", "[rope_node]") {
    std::unique_ptr<rope_node> node = std::make_unique<rope_node>(std::string("that's a low price!"));

    std::unique_ptr<rope_node> dupl = std::make_unique<rope_node>(*node.get());

    REQUIRE(*dupl->to_string().get() == *node->to_string().get());
}

<commit_msg>Add more tests for rope_node<commit_after>/**
 * Tests of str_rope and rope_node.
 *
 * @author <NAME>
 **/

#include <catch.hpp>
#include <primitives/str_rope.h>

TEST_CASE("Empty rope_node", "[rope_node]") {
    std::unique_ptr<rope_node> node = std::make_unique<rope_node>();

    SECTION("Empty node has nullptr left & right") {
        REQUIRE(!node->data.left);
        REQUIRE(!node->data.right);
    }

    SECTION("Empty node to string") {
        REQUIRE(*node->to_string().get() == "");
    }

    SECTION("Empty node is not a leaf") {
        REQUIRE(!node->is_leaf);
    }
}

TEST_CASE("String rope_node", "[rope_node]") {
    std::unique_ptr<rope_node> node = std::make_unique<rope_node>(std::string("wow!"));

    SECTION("String node is a leaf") {
        REQUIRE(node->is_leaf);
    }
}

TEST_CASE("Copy constructor for rope_node", "[rope_node]") {
    SECTION("Copied node is a leaf node") {
        std::unique_ptr<rope_node> node = std::make_unique<rope_node>(std::string("that's a low price!"));

        std::unique_ptr<rope_node> dupl = std::make_unique<rope_node>(*node.get());

        REQUIRE(*dupl->to_string().get() == *node->to_string().get());
        REQUIRE(dupl->is_leaf);
    }

    SECTION("Copied node is not a leaf node") {
        rope_node node;
        rope_node dupl(node);

        REQUIRE(!dupl.is_leaf);
    }
}


{'fraction_non_alphanumeric': 0.18454190186712982, 'fraction_numerical': 0.0, 'mean_word_length': 3.8505263157894736, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 38, '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': '4526738', 'n_tokens_mistral': 866, 'n_tokens_neox': 840, 'n_words': 142}