Research portable Memory game | Исследовать портируемую игру Память
25개 이상의 토픽을 선택하실 수 없습니다.
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- #include <string>
- #include "ctx.h"
- #include "memory_Context.h"
- #include <iostream>
-
- std::string s(const char *str) {
- return std::string(str);
- }
-
- std::string ctx_test_Controller_executeFunctions_set() {
- auto c = memory_createContext();
- ctx_Controller<memory_Context> ctrl(c);
- // Disable automatic invocation of executeFunctions.
- ctrl.isProcessingQueue = true;
- ctrl.set("input", s("123"));
-
- 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);
- // Apply 'input'.
- ctrl.executeFunctions();
- // Apply 'outputHelp'.
- ctrl.executeFunctions();
- std::cout
- << "input: '"
- << ctrl.context.input
- << "'"
- << ((ctrl.context.input == "123") ? "1" : "0")
- << " "
- << ((ctrl.context.outputHelp == "Checked") ? "1" : "0")
- << std::endl;
- if (
- ctrl.context.input == "123" &&
- ctrl.context.outputHelp == "Checked"
- ) {
- return "OK: ctx_Controller_executeFunctions_set";
- }
- return "ERR: ctx_Controller_executeFunctions_set";
- }
|