MCPcopy Create free account
hub / github.com/PDAL/PDAL / TEST

Function TEST

test/unit/ZstdTest.cpp:43–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41using namespace pdal;
42
43TEST(Compression, zstd)
44{
45 std::default_random_engine generator;
46 std::uniform_int_distribution<int> dist((std::numeric_limits<int>::min)());
47
48 // Choosing a size that isn't a multiple of the internal buffer.
49 // Trying to make something that compresses reasonably well.
50 std::vector<int> orig(1000357);
51 int val = dist(generator);
52 for (size_t i = 0; i < orig.size(); ++i)
53 {
54 orig[i] = val++;
55 if (i % 100 == 0)
56 val = dist(generator);
57 }
58
59 std::vector<char> compressed;
60 auto cb = [&compressed](char *buf, size_t bufsize)
61 {
62 compressed.insert(compressed.end(), buf, buf + bufsize);
63 };
64
65 size_t s = orig.size() * sizeof(int);
66 char *sp = reinterpret_cast<char *>(orig.data());
67 ZstdCompressor compressor(cb);
68 compressor.compress(sp, s);
69 compressor.done();
70
71 auto verifier = [&sp](char *buf, size_t bufsize)
72 {
73 EXPECT_EQ(memcmp(buf, sp, bufsize), 0);
74 sp += bufsize;
75 };
76
77 ZstdDecompressor decompressor(verifier);
78 decompressor.decompress(compressed.data(), compressed.size());
79 decompressor.done();
80}
81

Callers

nothing calls this directly

Calls 8

distFunction · 0.85
sizeMethod · 0.45
insertMethod · 0.45
endMethod · 0.45
dataMethod · 0.45
compressMethod · 0.45
doneMethod · 0.45
decompressMethod · 0.45

Tested by

no test coverage detected