forked from fast-pack/FastPFOR
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.h
More file actions
38 lines (28 loc) · 1.06 KB
/
Copy pathutil.h
File metadata and controls
38 lines (28 loc) · 1.06 KB
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
34
35
36
37
38
#ifndef FASTPFORLIB_UTIL_H_
#define FASTPFORLIB_UTIL_H_
#include <vector>
#include "gtest/gtest.h"
namespace FastPForLib {
template <class Codec>
void verifyUnknownInputLengthDecode(Codec &codec,
const std::vector<uint32_t> &in,
std::vector<uint32_t> &decoded) {
std::vector<uint32_t> encoded(in.size() * 2, 0);
size_t encodedSize;
codec.encodeArray(in.data(), in.size(), encoded.data(), encodedSize);
encoded.resize(encodedSize);
size_t n = in.size();
const uint32_t *decodedUntil =
codec.decodeArray(encoded.data(), 0, decoded.data(), n);
decoded.resize(n);
// Check that the decoded size matches the input size.
EXPECT_EQ(n, in.size());
// Check that the returned pointer matches the end of the encoded buffer.
EXPECT_EQ(decodedUntil, encoded.data() + encodedSize);
// Check each decoded element matches its corresponding input value.
for (size_t i = 0; i < in.size(); ++i) {
EXPECT_EQ(in[i], decoded[i]);
}
}
} // namespace FastPForLib
#endif // FASTPFORLIB_UTIL_H_