ResourceFilesystem.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright (C) 2009-2016, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #include "tests/framework/Framework.h"
  6. #define private public
  7. #include "anki/resource/ResourceFilesystem.h"
  8. namespace anki
  9. {
  10. ANKI_TEST(Resource, ResourceFilesystem)
  11. {
  12. printf("Test requires the data dir\n");
  13. HeapAllocator<U8> alloc(allocAligned, nullptr);
  14. ResourceFilesystem fs(alloc);
  15. {
  16. ANKI_TEST_EXPECT_NO_ERR(fs.addNewPath("data/dir/../dir/"));
  17. ResourceFilePtr file;
  18. ANKI_TEST_EXPECT_NO_ERR(fs.openFile("subdir0/hello.txt", file));
  19. StringAuto txt(alloc);
  20. ANKI_TEST_EXPECT_NO_ERR(file->readAllText(alloc, txt));
  21. ANKI_TEST_EXPECT_EQ(txt, "hello\n");
  22. }
  23. {
  24. ANKI_TEST_EXPECT_NO_ERR(fs.addNewPath("./data/dir.ankizip"));
  25. ResourceFilePtr file;
  26. ANKI_TEST_EXPECT_NO_ERR(fs.openFile("subdir0/hello.txt", file));
  27. StringAuto txt(alloc);
  28. ANKI_TEST_EXPECT_NO_ERR(file->readAllText(alloc, txt));
  29. ANKI_TEST_EXPECT_EQ(txt, "hell\n");
  30. }
  31. }
  32. } // end namespace anki