Михаил Капелько 3 months ago
parent
commit
9acfa6592b
3 changed files with 32 additions and 11 deletions
  1. +27
    -9
      v4/ctx_test2.cpp
  2. +2
    -1
      v4/ctx_test2.h
  3. +3
    -1
      v4/main.cpp

+ 27
- 9
v4/ctx_test2.cpp View File

@@ -7,7 +7,7 @@ std::string s(const char *str) {
return std::string(str); return std::string(str);
} }


std::string ctx_test_Controller_executeFunctions_set() {
std::string test_ctx_Controller_executeFunctions_set() {
auto c = memory_createContext(); auto c = memory_createContext();
ctx_Controller<memory_Context> ctrl(c); ctx_Controller<memory_Context> ctrl(c);
// Disable automatic invocation of executeFunctions. // Disable automatic invocation of executeFunctions.
@@ -29,14 +29,6 @@ std::string ctx_test_Controller_executeFunctions_set() {
ctrl.executeFunctions(); ctrl.executeFunctions();
// Apply 'outputHelp'. // Apply 'outputHelp'.
ctrl.executeFunctions(); ctrl.executeFunctions();
std::cout
<< "input: '"
<< ctrl.context.input
<< "'"
<< ((ctrl.context.input == "123") ? "1" : "0")
<< " "
<< ((ctrl.context.outputHelp == "Checked") ? "1" : "0")
<< std::endl;
if ( if (
ctrl.context.input == "123" && ctrl.context.input == "123" &&
ctrl.context.outputHelp == "Checked" ctrl.context.outputHelp == "Checked"
@@ -45,3 +37,29 @@ std::string ctx_test_Controller_executeFunctions_set() {
} }
return "ERR: ctx_Controller_executeFunctions_set"; return "ERR: ctx_Controller_executeFunctions_set";
} }

std::string test_ctx_Controller_processQueue() {
auto c = memory_createContext();
ctx_Controller<memory_Context> ctrl(c);

auto processInput = [](memory_Context c) -> memory_Context {
if (c.recentField == "input") {
c.outputHelp = "Checked";
c.recentField = "outputHelp";
return c;
}
c.recentField = "none";
return c;
};

ctrl.registerFunction(processInput);
ctrl.set("input", s("abc"));
if (
ctrl.context.input == "abc" &&
ctrl.context.outputHelp == "Checked"
) {
return "OK: ctx_Controller_processQueue";
}
return "ERR: ctx_Controller_processQueue";
}


+ 2
- 1
v4/ctx_test2.h View File

@@ -3,6 +3,7 @@
#ifndef ctx_test_HEADER #ifndef ctx_test_HEADER
#define ctx_test_HEADER #define ctx_test_HEADER


std::string ctx_test_Controller_executeFunctions_set();
std::string test_ctx_Controller_executeFunctions_set();
std::string test_ctx_Controller_processQueue();


#endif // ctx_test_HEADER #endif // ctx_test_HEADER

+ 3
- 1
v4/main.cpp View File

@@ -7,7 +7,9 @@


int main() { int main() {
std::cout std::cout
<< ctx_test_Controller_executeFunctions_set()
<< test_ctx_Controller_executeFunctions_set()
<< std::endl
<< test_ctx_Controller_processQueue()
<< std::endl << std::endl
<< llm_test_isDigit_digit() << llm_test_isDigit_digit()
<< std::endl << std::endl


Loading…
Cancel
Save