ResourceFilesystem.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright (C) 2009-2016, Panagiotis Christopoulos Charitos.
  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. //==============================================================================
  11. ANKI_TEST(Resource, ResourceFilesystem)
  12. {
  13. printf("Test requires the data dir\n");
  14. HeapAllocator<U8> alloc(allocAligned, nullptr);
  15. ResourceFilesystem fs(alloc);
  16. {
  17. ANKI_TEST_EXPECT_NO_ERR(fs.addNewPath("data/dir/../dir/"));
  18. ResourceFilePtr file;
  19. ANKI_TEST_EXPECT_NO_ERR(fs.openFile("subdir0/hello.txt", file));
  20. StringAuto txt(alloc);
  21. ANKI_TEST_EXPECT_NO_ERR(file->readAllText(alloc, txt));
  22. ANKI_TEST_EXPECT_EQ(txt, "hello\n");
  23. }
  24. {
  25. ANKI_TEST_EXPECT_NO_ERR(fs.addNewPath("./data/dir.ankizip"));
  26. ResourceFilePtr file;
  27. ANKI_TEST_EXPECT_NO_ERR(fs.openFile("subdir0/hello.txt", file));
  28. StringAuto txt(alloc);
  29. ANKI_TEST_EXPECT_NO_ERR(file->readAllText(alloc, txt));
  30. ANKI_TEST_EXPECT_EQ(txt, "hell\n");
  31. }
  32. }
  33. } // end namespace anki