schema progress

This commit is contained in:
Sascha Kühl
2025-02-04 15:19:01 +01:00
parent 6a5974337d
commit f01e9ff87f
17 changed files with 416 additions and 276 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ add_executable(CoreTests
utils/FieldAttributeTest.cpp
utils/VersionTest.cpp
utils/StringTest.cpp
object/PrototypeTreeTest.cpp
object/SchemaTest.cpp
)
target_link_libraries(CoreTests matador-core Catch2::Catch2WithMain)
@@ -1,35 +1,52 @@
#include <catch2/catch_test_macros.hpp>
#include "matador/object/schema.hpp"
struct node {};
using namespace matador;
struct person {
virtual ~person() = default;
};
struct student final : person {};
struct teacher final : person {};
TEST_CASE("Test empty prototype tree", "[prototype_tree][empty]") {
const object::schema tree;
REQUIRE( tree.empty() );
}
TEST_CASE("Test add type to prototype tree", "[prototype_tree][add]") {
object::schema tree;
REQUIRE( tree.empty() );
auto res = tree.attach<person>("person");
REQUIRE( res.is_ok() );
res = tree.attach<student, person>("student");
REQUIRE( res.is_ok() );
res = tree.attach<teacher, person>("teacher");
REQUIRE( res.is_ok() );
REQUIRE( tree.size() == 3 );
}
#include <catch2/catch_test_macros.hpp>
#include "matador/object/schema.hpp"
struct node {};
using namespace matador;
struct person {
virtual ~person() = default;
};
struct student final : person {};
struct teacher final : person {};
TEST_CASE("Test empty prototype tree", "[schema_node][empty]") {
const object::schema tree;
REQUIRE( tree.empty() );
}
TEST_CASE("Test add type to prototype tree", "[schema_node][add]") {
object::schema tree;
REQUIRE( tree.empty() );
auto res = tree.attach<person>("person");
REQUIRE( res.is_ok() );
res = tree.attach<student, person>("student");
REQUIRE( res.is_ok() );
res = tree.attach<teacher, person>("teacher");
REQUIRE( res.is_ok() );
REQUIRE( !tree.empty() );
REQUIRE( tree.size() == 3 );
}
TEST_CASE("Test next and previous of schema node", "[schema_node][next][previous]") {
object::schema tree;
REQUIRE( tree.empty() );
auto res = tree.attach<person>("person");
REQUIRE( res.is_ok() );
REQUIRE( tree.size() == 1 );
auto it = tree.begin();
REQUIRE( it->name() == "person" );
REQUIRE( (--it)->name() == "person" );
REQUIRE( ++it == tree.end() );
}