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

Function TEST

test/unit/DeflateTest.cpp:43–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41using namespace pdal;
42
43TEST(Compression, deflate)
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 std::vector<int> orig(1000357);
50 // Trying to make something that compresses reasonably well.
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 DeflateCompressor compressor(cb);
66
67 size_t s = orig.size() * sizeof(int);
68 char *sp = reinterpret_cast<char *>(orig.data());
69 compressor.compress(sp, s);
70 compressor.done();
71
72 auto verifier = [&sp](char *buf, size_t bufsize)
73 {
74 EXPECT_EQ(memcmp(buf, sp, bufsize), 0);
75 sp += bufsize;
76 };
77
78 DeflateDecompressor decompressor(verifier);
79 decompressor.decompress(compressed.data(), compressed.size());
80 decompressor.done();
81}
82

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