Research portable Memory game | Исследовать портируемую игру Память
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

48 satır
1.2KB

  1. #include <string>
  2. #include "ctx.h"
  3. #include "memory_Context.h"
  4. #include <iostream>
  5. std::string s(const char *str) {
  6. return std::string(str);
  7. }
  8. std::string ctx_test_Controller_executeFunctions_set() {
  9. auto c = memory_createContext();
  10. ctx_Controller<memory_Context> ctrl(c);
  11. // Disable automatic invocation of executeFunctions.
  12. ctrl.isProcessingQueue = true;
  13. ctrl.set("input", s("123"));
  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
  29. << "input: '"
  30. << ctrl.context.input
  31. << "'"
  32. << ((ctrl.context.input == "123") ? "1" : "0")
  33. << " "
  34. << ((ctrl.context.outputHelp == "Checked") ? "1" : "0")
  35. << std::endl;
  36. if (
  37. ctrl.context.input == "123" &&
  38. ctrl.context.outputHelp == "Checked"
  39. ) {
  40. return "OK: ctx_Controller_executeFunctions_set";
  41. }
  42. return "ERR: ctx_Controller_executeFunctions_set";
  43. }