aboutsummaryrefslogtreecommitdiff
path: root/test/main.cpp
blob: f18332ce8e5a35552dc40fe62a222d55ad1dfd3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "resources.h"
#include "zstd_resources.h"
#include <cstdio>
#include <cstdlib>

int main(int, char **)
{
    constexpr auto size = staticdata::entries.size();
    constexpr embed::Resources static_ctx(staticdata::entries, staticdata::values);
    const embed::CompressedResources zstd_ctx(zstd_data::entries, zstd_data::values, zstd_data::compression, zstd_data::dictionary);
    for(std::size_t i = 0; i < size; ++i) {
        const auto s = static_ctx.value(i);
        const auto v = zstd_ctx.decompress(i);

        if(s.size() != v.size()) {
            printf("  raw data at path [%s] size=%li\n", staticdata::entries.at(i), s.size());
            printf(" zstd data at path [%s] size=%li\n", zstd_data::entries.at(i), v.size());
            return EXIT_FAILURE;
        }

        if(!std::equal(s.begin(), s.end(), v.begin(), v.end())) {
            printf("failed comparing values at path [%s]\n", staticdata::entries.at(i));
            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;
}