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.

41 lines
1.1KB

  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. std::cout << "01\n";
  11. ctrl.set("input", "123");
  12. std::cout << "input: '" << ctrl.context.input << "'" << std::endl;
  13. std::cout << "02\n";
  14. auto processInput = [](memory_Context c) -> memory_Context {
  15. if (c.recentField == "input") {
  16. c.outputHelp = "Checked";
  17. c.recentField = "outputHelp";
  18. return c;
  19. }
  20. c.recentField = "none";
  21. return c;
  22. };
  23. ctrl.registerFunction(processInput);
  24. // Apply 'input'.
  25. ctrl.executeFunctions();
  26. // Apply 'outputHelp'.
  27. ctrl.executeFunctions();
  28. std::cout << "input: '" << ctrl.context.input << "'" << std::endl;
  29. if (
  30. ctrl.context.input == "123" &&
  31. ctrl.context.outputHelp == "Checked"
  32. ) {
  33. return "OK: ctx_Controller_executeFunctions_set";
  34. }
  35. return "ERR: ctx_Controller_executeFunctions_set";
  36. }