From db12076b452d331da9abc5621f29b9454f666266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Fri, 7 Jun 2024 22:20:13 +0300 Subject: [PATCH] d --- v4/ctx.h | 8 -------- v4/ctx_test2.cpp | 25 ++++++++++++++++++++++++- v4/ctx_test2.h | 2 ++ v4/main.cpp | 4 ++++ v4/memory_Context.cpp | 2 -- 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/v4/ctx.h b/v4/ctx.h index c0df3fc..975c0aa 100644 --- a/v4/ctx.h +++ b/v4/ctx.h @@ -65,14 +65,6 @@ template class ctx_Controller { callbacks.push_back(execCB); } - /* - void registerFunctions(const std::list funcs) { - for (const auto &f : funcs) { - functions.push_back(f); - } - } - - */ void reportContext() { for (const auto &cb : callbacks) { cb(context); diff --git a/v4/ctx_test2.cpp b/v4/ctx_test2.cpp index 9317244..d1ca931 100644 --- a/v4/ctx_test2.cpp +++ b/v4/ctx_test2.cpp @@ -1,7 +1,7 @@ #include +#include "any.h" #include "ctx.h" #include "memory_Context.h" -#include std::string s(const char *str) { return std::string(str); @@ -116,3 +116,26 @@ std::string test_ctx_Controller_registerFieldCallback_mismatch() { } return "ERR: ctx_Controller_registerFieldCallback_mismatch"; } + +std::string test_memory_Context_field() { + auto c = memory_createContext(); + c.input = "abc"; + if ( + libany::any_cast(c.field("input")) == "abc" + ) { + return "OK: memory_Context_field"; + } + return "ERR: memory_Context_field"; +} + +std::string test_memory_Context_setField() { + auto c = memory_createContext(); + c.input = "abc"; + c.setField("input", s("123")); + if ( + c.input == "123" + ) { + return "OK: memory_Context_setField"; + } + return "ERR: memory_Context_setField"; +} diff --git a/v4/ctx_test2.h b/v4/ctx_test2.h index 8f2ea17..85a7114 100644 --- a/v4/ctx_test2.h +++ b/v4/ctx_test2.h @@ -7,5 +7,7 @@ std::string test_ctx_Controller_executeFunctions_set(); std::string test_ctx_Controller_processQueue(); std::string test_ctx_Controller_registerFieldCallback_match(); std::string test_ctx_Controller_registerFieldCallback_mismatch(); +std::string test_memory_Context_field(); +std::string test_memory_Context_setField(); #endif // ctx_test_HEADER diff --git a/v4/main.cpp b/v4/main.cpp index 5a37b7d..79633dc 100644 --- a/v4/main.cpp +++ b/v4/main.cpp @@ -15,6 +15,10 @@ int main() { << std::endl << test_ctx_Controller_registerFieldCallback_mismatch() << std::endl + << test_memory_Context_field() + << std::endl + << test_memory_Context_setField() + << std::endl << llm_test_isDigit_digit() << std::endl << llm_test_isDigit_notDigit() diff --git a/v4/memory_Context.cpp b/v4/memory_Context.cpp index c8f041e..60a2ed0 100644 --- a/v4/memory_Context.cpp +++ b/v4/memory_Context.cpp @@ -2,8 +2,6 @@ #include "any.h" #include "memory_Context.h" -#include - libany::any memory_Context::field(const std::string &fieldName) { if (fieldName == "didLaunch") { return didLaunch;