ResourceFilesystem.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright (C) 2009-2021, 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. #include <AnKi/Resource/ResourceFilesystem.h>
  7. namespace anki {
  8. ANKI_TEST(Resource, ResourceFilesystem)
  9. {
  10. printf("Test requires the Data dir\n");
  11. HeapAllocator<U8> alloc(allocAligned, nullptr);
  12. ResourceFilesystem fs(alloc);
  13. {
  14. ANKI_TEST_EXPECT_NO_ERR(fs.addNewPath("Tests/Data/Dir/../Dir/", StringListAuto(alloc)));
  15. ResourceFilePtr file;
  16. ANKI_TEST_EXPECT_NO_ERR(fs.openFile("subdir0/hello.txt", file));
  17. StringAuto txt(alloc);
  18. ANKI_TEST_EXPECT_NO_ERR(file->readAllText(txt));
  19. ANKI_TEST_EXPECT_EQ(txt, "hello\n");
  20. }
  21. {
  22. ANKI_TEST_EXPECT_NO_ERR(fs.addNewPath("./Tests/Data/Dir.AnKiZLibip", StringListAuto(alloc)));
  23. ResourceFilePtr file;
  24. ANKI_TEST_EXPECT_NO_ERR(fs.openFile("subdir0/hello.txt", file));
  25. StringAuto txt(alloc);
  26. ANKI_TEST_EXPECT_NO_ERR(file->readAllText(txt));
  27. ANKI_TEST_EXPECT_EQ(txt, "hell\n");
  28. }
  29. }
  30. } // end namespace anki