This commit is contained in:
Михаил Капелько
2024-06-07 22:20:13 +03:00
parent e4aa609d4c
commit db12076b45
5 changed files with 30 additions and 11 deletions

View File

@@ -65,14 +65,6 @@ template <class T> class ctx_Controller {
callbacks.push_back(execCB);
}
/*
void registerFunctions(const std::list<T *(T)> funcs) {
for (const auto &f : funcs) {
functions.push_back(f);
}
}
*/
void reportContext() {
for (const auto &cb : callbacks) {
cb(context);

View File

@@ -1,7 +1,7 @@
#include <string>
#include "any.h"
#include "ctx.h"
#include "memory_Context.h"
#include <iostream>
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<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";
}

View File

@@ -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

View File

@@ -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()

View File

@@ -2,8 +2,6 @@
#include "any.h"
#include "memory_Context.h"
#include <iostream>
libany::any memory_Context::field(const std::string &fieldName) {
if (fieldName == "didLaunch") {
return didLaunch;