<commit_before>#define CATCH_CONFIG_MAIN  // This tells Catch to provide a main()
#include "catch.hpp"

#include <memory>

#include "serialization.hpp"

struct Class1 {
    Class1(int x = 1, int y = 2): x(x), y(y) {}
    int x;
    int y;

    WARPED_REGISTER_SERIALIZABLE_MEMBERS(x, y);
};

TEST_CASE("Objects can be serialized", "[serialization]") {
    std::stringstream ss;
    Class1 c1 {3, 4};
    Class1 c2;

    REQUIRE(c2.x == 1);
    REQUIRE(c2.y == 2);

    {
        cereal::JSONOutputArchive oarchive(ss);
        oarchive(c1);
    }

    {
        cereal::JSONInputArchive iarchive(ss);
        iarchive(c2);
    }
    REQUIRE(c2.x == 3);
    REQUIRE(c2.y == 4);
}

struct BaseClass {
    virtual int f() = 0;
};

struct DerivedClass : public BaseClass {
    int f() { return 2; }
    int x;
    WARPED_REGISTER_SERIALIZABLE_MEMBERS(x);
};
WARPED_REGISTER_POLYMORPHIC_SERIALIZABLE_CLASS(DerivedClass);

TEST_CASE("Polymorphic Objects can be serialized", "[serialization]") {
    std::stringstream ss;
    std::unique_ptr<BaseClass> c{new DerivedClass()};

    REQUIRE(c->f() == 2);
    {
        cereal::JSONOutputArchive oarchive(ss);
        oarchive(c);
    }

    {
        cereal::JSONInputArchive iarchive(ss);
        iarchive(c);
    }
    REQUIRE(c->f() == 2);
}<commit_msg>Added explicit default constructor to test case<commit_after>#define CATCH_CONFIG_MAIN  // This tells Catch to provide a main()
#include "catch.hpp"

#include <memory>

#include "serialization.hpp"

struct Class1 {
    Class1(int x=1, int y=2): x(x), y(y) {}
    int x;
    int y;

    WARPED_REGISTER_SERIALIZABLE_MEMBERS(x, y);
};

TEST_CASE("Objects can be serialized", "[serialization]") {
    std::stringstream ss;
    Class1 c1 {3, 4};
    Class1 c2 {1, 2};

    REQUIRE(c2.x == 1);
    REQUIRE(c2.y == 2);

    {
        cereal::JSONOutputArchive oarchive(ss);
        oarchive(c1);
    }

    {
        cereal::JSONInputArchive iarchive(ss);
        iarchive(c2);
    }
    REQUIRE(c2.x == 3);
    REQUIRE(c2.y == 4);
}

struct BaseClass {
    virtual int f() = 0;
};

struct DerivedClass : public BaseClass {
    DerivedClass() = default;
    DerivedClass(int x) : x(x) {}
    int f() { return 2; }
    int x;
    WARPED_REGISTER_SERIALIZABLE_MEMBERS(x);
};
WARPED_REGISTER_POLYMORPHIC_SERIALIZABLE_CLASS(DerivedClass);

TEST_CASE("Polymorphic Objects can be serialized", "[serialization]") {
    std::stringstream ss;
    std::unique_ptr<BaseClass> c{new DerivedClass(1)};

    REQUIRE(c->f() == 2);
    {
        cereal::JSONOutputArchive oarchive(ss);
        oarchive(c);
    }

    {
        cereal::JSONInputArchive iarchive(ss);
        iarchive(c);
    }
    REQUIRE(c->f() == 2);
}
{'fraction_non_alphanumeric': 0.1446587537091988, 'fraction_numerical': 0.018916913946587538, 'mean_word_length': 3.031390134529148, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '2105713', 'n_tokens_mistral': 1064, 'n_tokens_neox': 999, 'n_words': 205}