ResourceFilesystem.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright (C) 2009-2023, 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::allocateSingleton(allocAligned, nullptr);
  11. ResourceFilesystem fs;
  12. ANKI_TEST_EXPECT_NO_ERR(fs.init());
  13. {
  14. ANKI_TEST_EXPECT_NO_ERR(fs.addNewPath("Tests/Data/Dir/../Dir/", ResourceStringList()));
  15. ResourceFilePtr file;
  16. ANKI_TEST_EXPECT_NO_ERR(fs.openFile("subdir0/hello.txt", file));
  17. ResourceString txt;
  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", ResourceStringList()));
  23. ResourceFilePtr file;
  24. ANKI_TEST_EXPECT_NO_ERR(fs.openFile("subdir0/hello.txt", file));
  25. ResourceString txt;
  26. ANKI_TEST_EXPECT_NO_ERR(file->readAllText(txt));
  27. ANKI_TEST_EXPECT_EQ(txt, "hell\n");
  28. }
  29. }