@@ -88,3 +88,31 @@ std::string test_ctx_Controller_registerFieldCallback_match() { | |||||
} | } | ||||
return "ERR: ctx_Controller_registerFieldCallback_match"; | return "ERR: ctx_Controller_registerFieldCallback_match"; | ||||
} | } | ||||
std::string test_ctx_Controller_registerFieldCallback_mismatch() { | |||||
auto c = memory_createContext(); | |||||
ctx_Controller<memory_Context> ctrl(c); | |||||
c.input = "123"; | |||||
c.outputHelp = "you"; | |||||
// A field other than 'input' is marked recent. | |||||
c.recentField = "outputHelp"; | |||||
std::string callbackInput = ""; | |||||
auto setCallbackInput = [&callbackInput](memory_Context c) { | |||||
if ( | |||||
c.recentField == "input" | |||||
) { | |||||
callbackInput = c.input; | |||||
} | |||||
}; | |||||
ctrl.registerFieldCallback("input", setCallbackInput); | |||||
ctrl.reportContext(); | |||||
if ( | |||||
callbackInput == "" | |||||
) { | |||||
return "OK: ctx_Controller_registerFieldCallback_mismatch"; | |||||
} | |||||
return "ERR: ctx_Controller_registerFieldCallback_mismatch"; | |||||
} |
@@ -6,5 +6,6 @@ | |||||
std::string test_ctx_Controller_executeFunctions_set(); | 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(); | |||||
#endif // ctx_test_HEADER | #endif // ctx_test_HEADER |
@@ -113,7 +113,7 @@ def ctx_test_Controller_registerFieldCallback_mismatch( | |||||
): | ): | ||||
return "OK: ctx_Controller_registerFieldCallback_mismatch" | return "OK: ctx_Controller_registerFieldCallback_mismatch" | ||||
#} | #} | ||||
return f"ERR: ctx_Controller_registerFieldCallback_mismatch" | |||||
return "ERR: ctx_Controller_registerFieldCallback_mismatch" | |||||
#} | #} | ||||
def ctx_test_memoryContext_field( | def ctx_test_memoryContext_field( | ||||
@@ -13,6 +13,8 @@ int main() { | |||||
<< std::endl | << std::endl | ||||
<< test_ctx_Controller_registerFieldCallback_match() | << test_ctx_Controller_registerFieldCallback_match() | ||||
<< std::endl | << std::endl | ||||
<< test_ctx_Controller_registerFieldCallback_mismatch() | |||||
<< std::endl | |||||
<< llm_test_isDigit_digit() | << llm_test_isDigit_digit() | ||||
<< std::endl | << std::endl | ||||
<< llm_test_isDigit_notDigit() | << llm_test_isDigit_notDigit() | ||||