2
0

ERM_FU.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * ERM_FU.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_FU : public Test, public ScriptFixture
  18. {
  19. protected:
  20. void SetUp() override
  21. {
  22. ScriptFixture::setUp();
  23. }
  24. };
  25. TEST_F(ERM_FU, P)
  26. {
  27. std::stringstream source;
  28. source << "VERM" << std::endl;
  29. source << "!?PI;" << std::endl;
  30. source << "!!FU1:P;" << std::endl;
  31. source << "!?FU1;" << std::endl;
  32. source << "!!VRv1:S30;" << std::endl;
  33. JsonNode actualState = runScript(VLC->scriptHandler->erm, source.str());
  34. SCOPED_TRACE("\n" + subject->code);
  35. const JsonNode & v = actualState["ERM"]["v"];
  36. EXPECT_EQ(v["1"], JsonUtils::floatNode(30)) << actualState.toJson(true);
  37. }
  38. TEST_F(ERM_FU, E)
  39. {
  40. std::stringstream source;
  41. source << "VERM" << std::endl;
  42. source << "!?PI;" << std::endl;
  43. source << "!!FU1:P33/?v1;" << std::endl;
  44. source << "!?FU1;" << std::endl;
  45. source << "!!VRx2:Sx1 +10;" << std::endl;
  46. source << "!!FU:E;" << std::endl;
  47. source << "!!VRx2:+1;" << std::endl;
  48. JsonNode actualState = runScript(VLC->scriptHandler->erm, source.str());
  49. SCOPED_TRACE("\n" + subject->code);
  50. const JsonNode & v = actualState["ERM"]["v"];
  51. EXPECT_EQ(v["1"], JsonUtils::floatNode(43)) << actualState.toJson(true);
  52. }
  53. }
  54. }