ERM_VR.cpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * ERM_VR.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include "../scripting/ScriptFixture.h"
  12. namespace test
  13. {
  14. namespace scripting
  15. {
  16. using namespace ::testing;
  17. class ERM_VR : public Test, public ScriptFixture
  18. {
  19. protected:
  20. void SetUp() override
  21. {
  22. ScriptFixture::setUp();
  23. }
  24. };
  25. TEST_F(ERM_VR, C)
  26. {
  27. std::stringstream source;
  28. source << "VERM" << std::endl;
  29. source << "!?PI;" << std::endl;
  30. source << "!!VRv2:S99;" << std::endl;
  31. source << "!!VRv45:S100;" << std::endl;
  32. source << "!!VRv42:C3/5/75/?k/v2;" << std::endl;
  33. JsonNode actualState = runScript(VLC->scriptHandler->erm, source.str());
  34. SCOPED_TRACE("\n" + subject->code);
  35. EXPECT_EQ(actualState["ERM"]["Q"]["k"], JsonUtils::floatNode(100)) << actualState.toJson(true);
  36. const JsonNode & v = actualState["ERM"]["v"];
  37. EXPECT_EQ(v["42"], JsonUtils::floatNode(3)) << actualState.toJson(true);
  38. EXPECT_EQ(v["43"], JsonUtils::floatNode(5)) << actualState.toJson(true);
  39. EXPECT_EQ(v["44"], JsonUtils::floatNode(75)) << actualState.toJson(true);
  40. EXPECT_EQ(v["46"], JsonUtils::floatNode(99)) << actualState.toJson(true);
  41. }
  42. TEST_F(ERM_VR, H)
  43. {
  44. std::stringstream source;
  45. source << "VERM" << std::endl;
  46. source << "!?PI;" << std::endl;
  47. source << "!!VRz100:S^Test!^;" << std::endl;
  48. source << "!!VRz101:S^^;" << std::endl;
  49. source << "!!VRz102:S^ ^;" << std::endl;
  50. source << "!!VRz100:H200;" << std::endl;
  51. source << "!!VRz101:H201;" << std::endl;
  52. source << "!!VRz102:H202;" << std::endl;
  53. JsonNode actualState = runScript(VLC->scriptHandler->erm, source.str());
  54. SCOPED_TRACE("\n" + subject->code);
  55. const JsonNode & f = actualState["ERM"]["F"];
  56. EXPECT_EQ(f["200"], JsonUtils::boolNode(true)) << actualState.toJson(true);
  57. EXPECT_EQ(f["201"], JsonUtils::boolNode(false)) << actualState.toJson(true);
  58. EXPECT_EQ(f["202"], JsonUtils::boolNode(false)) << actualState.toJson(true);
  59. }
  60. TEST_F(ERM_VR, U)
  61. {
  62. std::stringstream source;
  63. source << "VERM" << std::endl;
  64. source << "!?PI;" << std::endl;
  65. source << "!!VRz100:S^Test!^;" << std::endl;
  66. source << "!!VRz101:S^est^;" << std::endl;
  67. source << "!!VRz100:Uz101;" << std::endl;
  68. JsonNode actualState = runScript(VLC->scriptHandler->erm, source.str());
  69. SCOPED_TRACE("\n" + subject->code);
  70. const JsonNode & f = actualState["ERM"]["F"];
  71. EXPECT_EQ(f["1"], JsonUtils::boolNode(true)) << actualState.toJson(true);
  72. }
  73. }
  74. }