diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/main.cpp | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/test/main.cpp b/test/main.cpp index faf5a16..f17ef67 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -1,17 +1,32 @@ -#include <gtest/gtest.h> #include "resources.h" +#include "zstd_resources.h" #include <cstdio> +#include <cstdlib> -int main(int argc, char** argv) +embed::Resources<zstd_data::compression> zstd_ctx(zstd_data::dictionary); + +int main(int, char **) { -// testing::InitGoogleTest(&argc, argv); -// return RUN_ALL_TESTS(); - embed::Resources ctx(metadata); - constexpr auto raw = entries.at("/icons/chevron-up.svg"); - static_assert(!raw.empty()); - const auto x = ctx.decompress(raw); - for(const char c : x) - printf("%c", c); - delete[] x.data(); - return 0; + for(const auto &pair : zstd_data::entries) { + const auto s = staticdata::entries.at(pair.first); + const auto v = zstd_ctx.decompress(pair.second); + + if(s.size() != v.size()) { + printf("failed comparing sizes at path [%s]\n", pair.first.data()); + printf("s: %li != v: %li\n", s.size(), v.size()); + return EXIT_FAILURE; + } + + if(!std::equal(s.begin(), s.end(), v.begin(), v.end())) { + printf("failed comparing values at path [%s]\n", pair.first.data()); + for(const char &c : s) + printf("%c", c); + for(const char &c : v) + printf("%c", c); + return EXIT_FAILURE; + } + } + printf("Zstd compression test complete\n"); + + return EXIT_SUCCESS; } |