EntityPoint.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Copyright (C) 2022 The V-Gears Team
  3. *
  4. * This file is part of V-Gears
  5. *
  6. * V-Gears is free software: you can redistribute it and/or modify it under
  7. * terms of the GNU General Public License as published by the Free Software
  8. * Foundation, version 3.0 (GPLv3) of the License.
  9. *
  10. * V-Gears is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #include <boost/test/unit_test.hpp>
  16. #include "LuaIncludes.h"
  17. #include "core/EntityPoint.h"
  18. BOOST_AUTO_TEST_CASE(TestEntityPoint){
  19. EntityPoint point("entry");
  20. point.SetPosition(Ogre::Vector3(4.0f, -2.0f, 5.5f));
  21. sol::state lua;
  22. lua.open_libraries(sol::lib::base, sol::lib::coroutine);
  23. lua.new_usertype<EntityPoint>("EntityPoint", "get_position", &EntityPoint::ScriptGetPosition);
  24. lua["point"] = &point;
  25. const sol::protected_function_result result = lua.safe_script(
  26. "local thread = coroutine.create(function() return point:get_position() end)\n"
  27. "local ok, x, y, z = coroutine.resume(thread)\n"
  28. "assert(ok and x == 4 and y == -2 and z == 5.5)"
  29. );
  30. BOOST_REQUIRE(result.valid());
  31. }