Open Source Tomb Raider Engine
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.

Script.cpp 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*!
  2. * \file test/Script.cpp
  3. * \brief Game script loader unit test
  4. *
  5. * \author xythobuz
  6. */
  7. #include <iostream>
  8. #include "global.h"
  9. #include "test.h"
  10. #include "utils/strings.h"
  11. #include "Script.h"
  12. #define printStrings(cnt, acc, name) { \
  13. std::cout << name << " (" << cnt << ")" << std::endl; \
  14. for (unsigned int i = 0; i < cnt; i++) { \
  15. std::cout << " " << acc(i) << std::endl; \
  16. } \
  17. std::cout << std::endl; \
  18. }
  19. #define printStrings2D(c, cnt, acc, name) { \
  20. std::cout << name << " (" << c << "*" << cnt << ")" << std::endl; \
  21. for (unsigned int a = 0; a < cnt; a++) { \
  22. std::cout << " "; \
  23. for (unsigned int i = 0; i < c; i++) { \
  24. std::cout << acc(i, a) << " "; \
  25. } \
  26. std::cout << std::endl; \
  27. } \
  28. std::cout << std::endl; \
  29. }
  30. int main() {
  31. Script s;
  32. char *f = fullPath("~/.OpenRaider/paks/tr2/TOMBPC.DAT", 0);
  33. assertEqual(s.load(f), 0);
  34. delete [] f;
  35. printStrings(s.levelCount(), s.getLevelName, "Level Names");
  36. printStrings(s.levelCount(), s.getLevelFilename, "Level Filenames");
  37. printStrings(s.cutsceneCount(), s.getCutsceneFilename, "Cutscenes");
  38. printStrings(s.titleCount(), s.getTitleFilename, "Titles");
  39. printStrings(s.videoCount(), s.getVideoFilename, "Videos");
  40. printStrings(s.gameStringCount(), s.getGameString, "Game Strings");
  41. printStrings(s.pcStringCount(), s.getPCString, "PC Strings");
  42. printStrings2D(4, s.levelCount(), s.getPuzzleString, "Puzzles");
  43. printStrings2D(2, s.levelCount(), s.getPickupString, "Pickups");
  44. printStrings2D(4, s.levelCount(), s.getKeyString, "Keys");
  45. //std::cout << "This test always fails so you can see its output!" << std::endl;
  46. //return 1;
  47. return 0;
  48. }