ResourceFilesystem.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. {
  9. ANKI_TEST(Resource, ResourceFilesystem)
  10. {
  11. printf("Test requires the Data dir\n");
  12. HeapAllocator<U8> alloc(allocAligned, nullptr);
  13. ResourceFilesystem fs(alloc);
  14. {
  15. ANKI_TEST_EXPECT_NO_ERR(fs.addNewPath("Tests/Data/Dir/../Dir/"));
  16. ResourceFilePtr file;
  17. ANKI_TEST_EXPECT_NO_ERR(fs.openFile("subdir0/hello.txt", file));
  18. StringAuto txt(alloc);
  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.ankizip"));
  24. ResourceFilePtr file;
  25. ANKI_TEST_EXPECT_NO_ERR(fs.openFile("subdir0/hello.txt", file));
  26. StringAuto txt(alloc);
  27. ANKI_TEST_EXPECT_NO_ERR(file->readAllText(txt));
  28. ANKI_TEST_EXPECT_EQ(txt, "hell\n");
  29. }
  30. }
  31. } // end namespace anki