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.

ctx_test.cpp 1.8KB

6 months ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #include <map>
  2. #include <string>
  3. #include <vector>
  4. #include "ctx.h"
  5. #include "llm.h"
  6. #include "memory_Context.h"
  7. #include "main.h"
  8. std::string ctx_test_Controller_executeFunctions_set(
  9. ) {
  10. auto c = memory_createContext();
  11. auto ctrl = ctx_Controller(c);
  12. // Disable automatic invocation of executeFunctions.
  13. ctrl.isProcessingQueue = true;
  14. ctrl.set("input", "123");
  15. ctrl.registerFunction(__processInput);
  16. // Apply 'input'.
  17. ctrl.executeFunctions();
  18. // Apply 'outputHelp'.
  19. ctrl.executeFunctions();
  20. if (
  21. c.input == "123" &&
  22. c.outputHelp == "Checked"
  23. ) {
  24. return "OK: ctx_Controller_executeFunctions_set";
  25. }
  26. return "ERR: ctx_Controller_executeFunctions_set";
  27. }
  28. std::string ctx_test_Controller_processQueue(
  29. ) {
  30. auto c = memory_createContext();
  31. auto ctrl = ctx_Controller(c);
  32. ctrl.registerFunction(__processInput);
  33. ctrl.set("input", "abc");;
  34. if (
  35. c.input == "abc" &&
  36. c.outputHelp == "Checked"
  37. ) {
  38. return "OK: ctx_Controller_processQueue";
  39. }
  40. return "ERR: ctx_Controller_processQueue";
  41. }
  42. std::string ctx_test_memoryContext_field(
  43. ) {
  44. auto c = memory_createContext();
  45. c.input = "abc";
  46. if (
  47. c.field("input") == "abc"
  48. ) {
  49. return "OK: ctx_memoryContext_field";
  50. }
  51. return "ERR: ctx_memoryContext_field";
  52. }
  53. std::string ctx_test_memoryContext_setField(
  54. ) {
  55. auto c = memory_createContext();
  56. c.input = "abc";
  57. c.setField("input", "123");
  58. if (
  59. c.field("input") == "123"
  60. ) {
  61. return "OK: ctx_memoryContext_setField";
  62. }
  63. return "ERR: ctx_memoryContext_setField";
  64. }
  65. // Auxiliary functions.
  66. memory_Context __processInput(
  67. memory_Context c
  68. ) {
  69. if (
  70. c.recentField == "input"
  71. ) {
  72. c.outputHelp = "Checked";
  73. c.recentField = "outputHelp";
  74. return c;
  75. }
  76. c.recentField = "none";
  77. return c;
  78. }