From 0f0e265b94b2b259e1b5054eff187fd093459b29 Mon Sep 17 00:00:00 2001 From: Borislav Stanimirov Date: Tue, 3 Dec 2024 14:21:59 +0200 Subject: [PATCH] test(schema): restore dummy schema test, ref #149 --- dummy-plugin/test/CMakeLists.txt | 18 +++++++++--------- dummy-plugin/test/t-dummy-schema.cpp | 21 ++++++++++++++++----- schema/code/ac/schema/CallHelpers.hpp | 7 +++++-- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/dummy-plugin/test/CMakeLists.txt b/dummy-plugin/test/CMakeLists.txt index 2d8fa620..9888a857 100644 --- a/dummy-plugin/test/CMakeLists.txt +++ b/dummy-plugin/test/CMakeLists.txt @@ -23,15 +23,15 @@ add_doctest_test(aclp-dummy-plib ac::jalog ) -# add_doctest_test(aclp-dummy-schema -# SOURCES -# t-dummy-schema.cpp -# LIBRARIES -# ac-dev::test-util -# aclp::dummy-plib -# ac-test-data::dummy -# ac::jalog -# ) +add_doctest_test(aclp-dummy-schema + SOURCES + t-dummy-schema.cpp + LIBRARIES + ac-dev::test-util + aclp-dummy-baselib + ac-test-data::dummy + ac::jalog +) add_doctest_test(aclp-dummy-plugin SOURCES diff --git a/dummy-plugin/test/t-dummy-schema.cpp b/dummy-plugin/test/t-dummy-schema.cpp index 64825e07..8da64252 100644 --- a/dummy-plugin/test/t-dummy-schema.cpp +++ b/dummy-plugin/test/t-dummy-schema.cpp @@ -8,16 +8,23 @@ #include +#include + +#include +#include + #include #include -#include #include struct LoadDummyFixture { - LoadDummyFixture() { - add_dummy_to_ac_local_global_registry(); + PlibHelper helper; + LoadDummyFixture() + : helper(ac::dummy::getPluginInterface()) + { + helper.addLoadersToGlobalRegistry(); } }; @@ -31,8 +38,12 @@ TEST_CASE("dummy schema") { REQUIRE(!!model); - using Instance = ac::local::schema::Dummy::InstanceGeneral; + using Instance = ac::local::schema::DummyLoader::InstanceGeneral; auto instance = Model_createInstance(*model, {.cutoff = 2}); - auto result = Instance_runOp(*instance, {.input = {"a", "b", "c"}}); + + using Interface = ac::local::schema::DummyInterface; + auto result = Instance_runOp(*instance, + {.input = std::vector{"a", "b", "c"}} + ); CHECK(result.result == "a one b two c one"); } diff --git a/schema/code/ac/schema/CallHelpers.hpp b/schema/code/ac/schema/CallHelpers.hpp index 397a43b5..663264b2 100644 --- a/schema/code/ac/schema/CallHelpers.hpp +++ b/schema/code/ac/schema/CallHelpers.hpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: MIT // #pragma once +#include "IOVisitors.hpp" #include #include #include @@ -10,12 +11,14 @@ namespace ac::local { template auto Model_createInstance(Model& model, typename Instance::Params p) { - return model.createInstance(Instance::id, p.toDict()); + return model.createInstance(Instance::id, schema::Struct_toDict(std::move(p))); } template typename Op::Return Instance_runOp(Instance& instance, typename Op::Params p, ProgressCb cb = {}) { - return Op::Return::fromDict(instance.runOp(Op::id, p.toDict(), std::move(cb))); + return schema::Struct_fromDict( + instance.runOp(Op::id, schema::Struct_toDict(std::move(p)), std::move(cb)) + ); } } // namespace ac::local