diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-03-04 00:27:54 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-03-04 01:12:19 +0300 |
commit | 79bb654b80d5eb7a65814f80b9ca7ca1ccd62a00 (patch) | |
tree | f9669ee10e2ea3f2c41abaa84830da9efe7f9411 /src/integrity_unittest.cc | |
parent | a6c70dd1f32c38cc81cfd4b28f929d7c13d86db1 (diff) | |
download | manaverse-79bb654b80d5eb7a65814f80b9ca7ca1ccd62a00.tar.gz manaverse-79bb654b80d5eb7a65814f80b9ca7ca1ccd62a00.tar.bz2 manaverse-79bb654b80d5eb7a65814f80b9ca7ca1ccd62a00.tar.xz manaverse-79bb654b80d5eb7a65814f80b9ca7ca1ccd62a00.zip |
Reimplement VirtFs in correct way. Now all tests should pass.
Diffstat (limited to 'src/integrity_unittest.cc')
-rw-r--r-- | src/integrity_unittest.cc | 78 |
1 files changed, 34 insertions, 44 deletions
diff --git a/src/integrity_unittest.cc b/src/integrity_unittest.cc index 0095f22ca..a0789d09c 100644 --- a/src/integrity_unittest.cc +++ b/src/integrity_unittest.cc @@ -25,6 +25,7 @@ #include "being/actorsprite.h" +#include "fs/files.h" #include "fs/virtfs.h" #include "fs/virtfsrwops.h" #include "fs/virtfstools.h" @@ -116,8 +117,13 @@ TEST_CASE("integrity tests", "integrity") SDL_Init(SDL_INIT_VIDEO); logger = new Logger(); ResourceManager::init(); - VirtFs::addDirToSearchPath("data", Append_false); - VirtFs::addDirToSearchPath("../data", Append_false); + std::string name("data/test/test.zip"); + std::string prefix; + if (Files::existsLocal(name) == false) + prefix = "../" + prefix; + + VirtFs::addDirToSearchPathSilent("data", Append_false); + VirtFs::addDirToSearchPathSilent("../data", Append_false); #ifdef USE_SDL2 imageHelper = new SurfaceImageHelper; @@ -221,12 +227,10 @@ TEST_CASE("integrity tests", "integrity") SECTION("integrity Loader::getImage test 2") { - VirtFs::addZipToSearchPath("data/test/test.zip", Append_false); - VirtFs::addZipToSearchPath("../data/test/test.zip", Append_false); + VirtFs::addZipToSearchPath(prefix + "data/test/test.zip", Append_false); Image *const image = Loader::getImage( "dir/hide.png"); - VirtFs::removeZipFromSearchPath("data/test/test.zip"); - VirtFs::removeZipFromSearchPath("../data/test/test.zip"); + VirtFs::removeZipFromSearchPath(prefix + "data/test/test.zip"); REQUIRE(image != nullptr); REQUIRE(image->getSDLSurface() != nullptr); image->decRef(); @@ -234,12 +238,10 @@ TEST_CASE("integrity tests", "integrity") SECTION("integrity Loader::getImage test 3") { - VirtFs::addZipToSearchPath("data/test/test.zip", Append_false); - VirtFs::addZipToSearchPath("../data/test/test.zip", Append_false); + VirtFs::addZipToSearchPath(prefix + "data/test/test.zip", Append_false); Image *const image = Loader::getImage( "dir/brimmedhat.png"); - VirtFs::removeZipFromSearchPath("data/test/test.zip"); - VirtFs::removeZipFromSearchPath("../data/test/test.zip"); + VirtFs::removeZipFromSearchPath(prefix + "data/test/test.zip"); REQUIRE(image != nullptr); REQUIRE(image->getSDLSurface() != nullptr); image->decRef(); @@ -247,8 +249,7 @@ TEST_CASE("integrity tests", "integrity") SECTION("integrity Loader::getImage test 4") { - VirtFs::addZipToSearchPath("data/test/test.zip", Append_false); - VirtFs::addZipToSearchPath("../data/test/test.zip", Append_false); + VirtFs::addZipToSearchPath(prefix + "data/test/test.zip", Append_false); SDL_RWops *const rw = VirtFs::RWopsOpenRead(name1); if (!rw) @@ -260,13 +261,10 @@ TEST_CASE("integrity tests", "integrity") SDL_RWclose(rw); REQUIRE(sz == size1); SDL_RWclose(rw); - VirtFs::removeZipFromSearchPath("data/test/test.zip"); - VirtFs::removeZipFromSearchPath("../data/test/test.zip"); - VirtFs::addDirToSearchPath("data/test", Append_true); - VirtFs::addDirToSearchPath("../data/test", Append_true); + VirtFs::removeZipFromSearchPath(prefix + "data/test/test.zip"); + VirtFs::addDirToSearchPathSilent(prefix + "data/test", Append_true); REQUIRE(compareBuffers(buf) == true); - VirtFs::removeDirFromSearchPath("data/test"); - VirtFs::removeDirFromSearchPath("../data/test"); + VirtFs::removeDirFromSearchPathSilent(prefix + "data/test"); } #ifdef USE_PHYSFS @@ -410,18 +408,17 @@ TEST_CASE("integrity tests", "integrity") VirtFs::removeZipFromSearchPath("data/test/test.zip"); VirtFs::removeZipFromSearchPath("../data/test/test.zip"); - VirtFs::addDirToSearchPath("data/test", Append_true); - VirtFs::addDirToSearchPath("../data/test", Append_true); + VirtFs::addDirToSearchPathSilent("data/test", Append_true); + VirtFs::addDirToSearchPathSilent("../data/test", Append_true); REQUIRE(compareBuffers(buf) == true); - VirtFs::removeDirFromSearchPath("data/test"); - VirtFs::removeDirFromSearchPath("../data/test"); + VirtFs::removeDirFromSearchPathSilent("data/test"); + VirtFs::removeDirFromSearchPathSilent("../data/test"); } #endif // USE_PHYSFS SECTION("integrity Loader::getImage test 7") { - VirtFs::addZipToSearchPath("data/test/test.zip", Append_false); - VirtFs::addZipToSearchPath("../data/test/test.zip", Append_false); + VirtFs::addZipToSearchPath(prefix + "data/test/test.zip", Append_false); SDL_RWops *const rw = VirtFs::RWopsOpenRead(name1); if (!rw) @@ -448,19 +445,17 @@ TEST_CASE("integrity tests", "integrity") REQUIRE(sz == size1); SDL_RWclose(rw); - VirtFs::removeZipFromSearchPath("data/test/test.zip"); - VirtFs::removeZipFromSearchPath("../data/test/test.zip"); - VirtFs::addDirToSearchPath("data/test", Append_true); - VirtFs::addDirToSearchPath("../data/test", Append_true); + VirtFs::removeZipFromSearchPath(prefix + "data/test/test.zip"); + VirtFs::addDirToSearchPathSilent("data/test", Append_true); + VirtFs::addDirToSearchPathSilent("../data/test", Append_true); REQUIRE(compareBuffers(buf) == true); - VirtFs::removeDirFromSearchPath("data/test"); - VirtFs::removeDirFromSearchPath("../data/test"); + VirtFs::removeDirFromSearchPathSilent("data/test"); + VirtFs::removeDirFromSearchPathSilent("../data/test"); } SECTION("integrity Loader::getImage test 8") { - VirtFs::addZipToSearchPath("data/test/test.zip", Append_false); - VirtFs::addZipToSearchPath("../data/test/test.zip", Append_false); + VirtFs::addZipToSearchPath(prefix + "data/test/test.zip", Append_false); SDL_RWops *const rw = VirtFs::RWopsOpenRead(name1); if (!rw) @@ -473,36 +468,31 @@ TEST_CASE("integrity tests", "integrity") } SDL_Surface *const tmpImage = IMG_LoadPNG_RW(rw); SDL_RWclose(rw); - VirtFs::removeZipFromSearchPath("data/test/test.zip"); - VirtFs::removeZipFromSearchPath("../data/test/test.zip"); + VirtFs::removeZipFromSearchPath(prefix + "data/test/test.zip"); REQUIRE(tmpImage != nullptr); SDL_FreeSurface(tmpImage); } SECTION("integrity Loader::getImage test 9") { - VirtFs::addZipToSearchPath("data/test/test.zip", Append_false); - VirtFs::addZipToSearchPath("../data/test/test.zip", Append_false); + VirtFs::addZipToSearchPath(prefix + "data/test/test.zip", Append_false); SDL_RWops *const rw = VirtFs::RWopsOpenRead(name1); if (!rw) logger->log("Physfs error: %s", VirtFs::getLastError()); REQUIRE(rw != nullptr); Resource *const res = imageHelper->load(rw); - VirtFs::removeZipFromSearchPath("data/test/test.zip"); - VirtFs::removeZipFromSearchPath("../data/test/test.zip"); + VirtFs::removeZipFromSearchPath(prefix + "data/test/test.zip"); REQUIRE(res != nullptr); delete res; } SECTION("integrity Loader::getImage test 10") { - VirtFs::addZipToSearchPath("data/test/test.zip", Append_false); - VirtFs::addZipToSearchPath("../data/test/test.zip", Append_false); + VirtFs::addZipToSearchPath(prefix + "data/test/test.zip", Append_false); Image *const image = Loader::getImage( name1); - VirtFs::removeZipFromSearchPath("data/test/test.zip"); - VirtFs::removeZipFromSearchPath("../data/test/test.zip"); + VirtFs::removeZipFromSearchPath(prefix + "data/test/test.zip"); REQUIRE(image != nullptr); REQUIRE(image->getSDLSurface() != nullptr); image->decRef(); @@ -513,8 +503,8 @@ TEST_CASE("integrity tests", "integrity") delete client; client = nullptr; - VirtFs::removeDirFromSearchPath("data"); - VirtFs::removeDirFromSearchPath("../data"); + VirtFs::removeDirFromSearchPathSilent("data"); + VirtFs::removeDirFromSearchPathSilent("../data"); delete2(logger); // VirtFs::deinit(); } |