From e4aa609d4cfe98f11074a198b56d235cd826bb28 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:08:18 +0300 Subject: [PATCH] d --- v4/ctx_test2.cpp | 28 ++++++++++++++++++++++++++++ v4/ctx_test2.h | 1 + v4/ctx_test2.py | 2 +- v4/main.cpp | 2 ++ 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/v4/ctx_test2.cpp b/v4/ctx_test2.cpp index 5ddfbdf..9317244 100644 --- a/v4/ctx_test2.cpp +++ b/v4/ctx_test2.cpp @@ -88,3 +88,31 @@ std::string test_ctx_Controller_registerFieldCallback_match() { } return "ERR: ctx_Controller_registerFieldCallback_match"; } + +std::string test_ctx_Controller_registerFieldCallback_mismatch() { + auto c = memory_createContext(); + ctx_Controller 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"; +} diff --git a/v4/ctx_test2.h b/v4/ctx_test2.h index b01d057..8f2ea17 100644 --- a/v4/ctx_test2.h +++ b/v4/ctx_test2.h @@ -6,5 +6,6 @@ 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(); #endif // ctx_test_HEADER diff --git a/v4/ctx_test2.py b/v4/ctx_test2.py index 3d1fd58..cde26fd 100644 --- a/v4/ctx_test2.py +++ b/v4/ctx_test2.py @@ -113,7 +113,7 @@ def ctx_test_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( diff --git a/v4/main.cpp b/v4/main.cpp index 84cb9c0..5a37b7d 100644 --- a/v4/main.cpp +++ b/v4/main.cpp @@ -13,6 +13,8 @@ int main() { << std::endl << test_ctx_Controller_registerFieldCallback_match() << std::endl + << test_ctx_Controller_registerFieldCallback_mismatch() + << std::endl << llm_test_isDigit_digit() << std::endl << llm_test_isDigit_notDigit()