test_activeobject.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. Minetest
  3. Copyright (C) 2018 nerzhul, Loic BLOT <loic.blot@unix-experience.fr>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #include "test.h"
  17. #include "activeobject.h"
  18. class TestActiveObject : public TestBase
  19. {
  20. public:
  21. TestActiveObject() { TestManager::registerTestModule(this); }
  22. const char *getName() { return "TestActiveObject"; }
  23. void runTests(IGameDef *gamedef);
  24. void testAOAttributes();
  25. };
  26. static TestActiveObject g_test_instance;
  27. void TestActiveObject::runTests(IGameDef *gamedef)
  28. {
  29. TEST(testAOAttributes);
  30. }
  31. class TestAO : public ActiveObject
  32. {
  33. public:
  34. TestAO(u16 id) : ActiveObject(id) {}
  35. virtual ActiveObjectType getType() const { return ACTIVEOBJECT_TYPE_TEST; }
  36. virtual bool getCollisionBox(aabb3f *toset) const { return false; }
  37. virtual bool getSelectionBox(aabb3f *toset) const { return false; }
  38. virtual bool collideWithObjects() const { return false; }
  39. };
  40. void TestActiveObject::testAOAttributes()
  41. {
  42. TestAO ao(44);
  43. UASSERT(ao.getId() == 44);
  44. ao.setId(558);
  45. UASSERT(ao.getId() == 558);
  46. }