@@ -65,14 +65,6 @@ template <class T> class ctx_Controller { | |||||
callbacks.push_back(execCB); | callbacks.push_back(execCB); | ||||
} | } | ||||
/* | |||||
void registerFunctions(const std::list<T *(T)> funcs) { | |||||
for (const auto &f : funcs) { | |||||
functions.push_back(f); | |||||
} | |||||
} | |||||
*/ | |||||
void reportContext() { | void reportContext() { | ||||
for (const auto &cb : callbacks) { | for (const auto &cb : callbacks) { | ||||
cb(context); | cb(context); | ||||
@@ -1,7 +1,7 @@ | |||||
#include <string> | #include <string> | ||||
#include "any.h" | |||||
#include "ctx.h" | #include "ctx.h" | ||||
#include "memory_Context.h" | #include "memory_Context.h" | ||||
#include <iostream> | |||||
std::string s(const char *str) { | std::string s(const char *str) { | ||||
return std::string(str); | return std::string(str); | ||||
@@ -116,3 +116,26 @@ std::string test_ctx_Controller_registerFieldCallback_mismatch() { | |||||
} | } | ||||
return "ERR: 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<std::string>(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"; | |||||
} |
@@ -7,5 +7,7 @@ std::string test_ctx_Controller_executeFunctions_set(); | |||||
std::string test_ctx_Controller_processQueue(); | std::string test_ctx_Controller_processQueue(); | ||||
std::string test_ctx_Controller_registerFieldCallback_match(); | std::string test_ctx_Controller_registerFieldCallback_match(); | ||||
std::string test_ctx_Controller_registerFieldCallback_mismatch(); | std::string test_ctx_Controller_registerFieldCallback_mismatch(); | ||||
std::string test_memory_Context_field(); | |||||
std::string test_memory_Context_setField(); | |||||
#endif // ctx_test_HEADER | #endif // ctx_test_HEADER |
@@ -15,6 +15,10 @@ int main() { | |||||
<< std::endl | << std::endl | ||||
<< test_ctx_Controller_registerFieldCallback_mismatch() | << test_ctx_Controller_registerFieldCallback_mismatch() | ||||
<< std::endl | << std::endl | ||||
<< test_memory_Context_field() | |||||
<< std::endl | |||||
<< test_memory_Context_setField() | |||||
<< std::endl | |||||
<< llm_test_isDigit_digit() | << llm_test_isDigit_digit() | ||||
<< std::endl | << std::endl | ||||
<< llm_test_isDigit_notDigit() | << llm_test_isDigit_notDigit() | ||||
@@ -2,8 +2,6 @@ | |||||
#include "any.h" | #include "any.h" | ||||
#include "memory_Context.h" | #include "memory_Context.h" | ||||
#include <iostream> | |||||
libany::any memory_Context::field(const std::string &fieldName) { | libany::any memory_Context::field(const std::string &fieldName) { | ||||
if (fieldName == "didLaunch") { | if (fieldName == "didLaunch") { | ||||
return didLaunch; | return didLaunch; | ||||