From c64c76e273084cfd5b8628fb268e803957fc3025 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Sat, 23 Mar 2024 17:48:09 +0100 Subject: codec, io_codec: forst and rpc work --- modules/codec/tests/schema.cpp | 69 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'modules/codec/tests/schema.cpp') diff --git a/modules/codec/tests/schema.cpp b/modules/codec/tests/schema.cpp index 408a142..77d369d 100644 --- a/modules/codec/tests/schema.cpp +++ b/modules/codec/tests/schema.cpp @@ -3,6 +3,7 @@ #include #include "../c++/schema.hpp" #include "../c++/schema_hash.hpp" +#include "../c++/schema_factory.hpp" namespace { template @@ -70,4 +71,72 @@ SAW_TEST("Schema Hashes"){ schema_test_pair >::check(); } + +SAW_TEST("Schema Factory Compiles"){ + using namespace saw; + + auto factory = build_schema>(); + + auto str = factory + .add() + .add() + .add_maybe() + .add_maybe() + ; + + using FactorySchema = decltype(str)::Schema; + + using Schema = schema::Struct< + schema::Member, + schema::Member, + schema::Member + >; + + SAW_EXPECT(is_struct::value, "Expected a struct"); + + schema_hash_test_multi< + schema_test_pair, + schema_test_pair + >::check(); +} + +template +auto ensure_types_one(saw::schema_factory builder){ + return builder + .template add_maybe, "foo">() + .template add_maybe() + ; +} + +template +auto ensure_types_two(saw::schema_factory builder){ + return builder + .template add_maybe, "foo">() + .template add_maybe() + ; +} + +SAW_TEST("Schema Factory Multimethod"){ + using namespace saw; + auto builder = build_schema>(); + + /** + * This would basically be multiple components + */ + auto b2 = ensure_types_one(builder); + auto b3 = ensure_types_two(b2); + + using Schema = schema::Struct< + schema::Member, "foo">, + schema::Member, + schema::Member + >; + + schema_hash_test_multi< + schema_test_pair, + schema_test_pair + >::check(); + + +} } -- cgit v1.2.3