ResourceFilesystem.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. // Copyright (C) 2009-present, 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. ResourceFilesystem fs;
  11. ANKI_TEST_EXPECT_NO_ERR(fs.init());
  12. {
  13. ANKI_TEST_EXPECT_NO_ERR(fs.addNewPath("Tests/Data/Dir/../Dir/", ResourceStringList(), ResourceStringList()));
  14. ResourceFilePtr file;
  15. ANKI_TEST_EXPECT_NO_ERR(fs.openFile("subdir0/hello.txt", file));
  16. ResourceString txt;
  17. ANKI_TEST_EXPECT_NO_ERR(file->readAllText(txt));
  18. ANKI_TEST_EXPECT_EQ(txt, "hello\n");
  19. }
  20. {
  21. ANKI_TEST_EXPECT_NO_ERR(fs.addNewPath("./Tests/Data/Dir.AnKiZLibip", ResourceStringList(), ResourceStringList()));
  22. ResourceFilePtr file;
  23. ANKI_TEST_EXPECT_NO_ERR(fs.openFile("subdir0/hello.txt", file));
  24. ResourceString txt;
  25. ANKI_TEST_EXPECT_NO_ERR(file->readAllText(txt));
  26. ANKI_TEST_EXPECT_EQ(txt, "hell\n");
  27. }
  28. }