ResourceFilesystem.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright (C) 2009-2022, 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. ANKI_TEST(Resource, ResourceFilesystem)
  8. {
  9. printf("Test requires the Data dir\n");
  10. ConfigSet config(allocAligned, nullptr);
  11. HeapMemoryPool pool(allocAligned, nullptr);
  12. ResourceFilesystem fs;
  13. ANKI_TEST_EXPECT_NO_ERR(fs.init(config, allocAligned, nullptr));
  14. {
  15. ANKI_TEST_EXPECT_NO_ERR(fs.addNewPath("Tests/Data/Dir/../Dir/", StringListRaii(&pool)));
  16. ResourceFilePtr file;
  17. ANKI_TEST_EXPECT_NO_ERR(fs.openFile("subdir0/hello.txt", file));
  18. StringRaii txt(&pool);
  19. ANKI_TEST_EXPECT_NO_ERR(file->readAllText(txt));
  20. ANKI_TEST_EXPECT_EQ(txt, "hello\n");
  21. }
  22. {
  23. ANKI_TEST_EXPECT_NO_ERR(fs.addNewPath("./Tests/Data/Dir.AnKiZLibip", StringListRaii(&pool)));
  24. ResourceFilePtr file;
  25. ANKI_TEST_EXPECT_NO_ERR(fs.openFile("subdir0/hello.txt", file));
  26. StringRaii txt(&pool);
  27. ANKI_TEST_EXPECT_NO_ERR(file->readAllText(txt));
  28. ANKI_TEST_EXPECT_EQ(txt, "hell\n");
  29. }
  30. }