Research portable Memory game | Исследовать портируемую игру Память
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.0KB

  1. #include <string>
  2. #include "ctx.h"
  3. #include "memory_Context.h"
  4. #include <iostream>
  5. std::string ctx_test_Controller_executeFunctions_set() {
  6. auto c = memory_createContext();
  7. ctx_Controller<memory_Context> ctrl(c);
  8. // Disable automatic invocation of executeFunctions.
  9. ctrl.isProcessingQueue = true;
  10. ctrl.set("input", "123");
  11. std::cout << "input: '" << ctrl.context.input << "'" << std::endl;
  12. auto processInput = [](memory_Context c) -> memory_Context {
  13. if (c.recentField == "input") {
  14. c.outputHelp = "Checked";
  15. c.recentField = "outputHelp";
  16. return c;
  17. }
  18. c.recentField = "none";
  19. return c;
  20. };
  21. ctrl.registerFunction(processInput);
  22. // Apply 'input'.
  23. ctrl.executeFunctions();
  24. // Apply 'outputHelp'.
  25. ctrl.executeFunctions();
  26. std::cout << "input: '" << ctrl.context.input << "'" << std::endl;
  27. if (
  28. ctrl.context.input == "123" &&
  29. ctrl.context.outputHelp == "Checked"
  30. ) {
  31. return "OK: ctx_Controller_executeFunctions_set";
  32. }
  33. return "ERR: ctx_Controller_executeFunctions_set";
  34. }