summaryrefslogtreecommitdiff
path: root/src/tests/util/test_ans.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/util/test_ans.cc')
-rw-r--r--src/tests/util/test_ans.cc24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/tests/util/test_ans.cc b/src/tests/util/test_ans.cc
index 108c46d..d8cc85c 100644
--- a/src/tests/util/test_ans.cc
+++ b/src/tests/util/test_ans.cc
@@ -15,8 +15,7 @@
namespace {
bool RoundtripCheck(const std::vector<uint8_t>& input,
- const uint32_t* initial_counts,
- const char* label) {
+ const uint32_t* initial_counts, const char* label) {
std::vector<uint8_t> compressed;
if (!ans::Encode(input.data(), input.size(), &compressed, initial_counts)) {
fprintf(stderr, "[%s] Encode failed\n", label);
@@ -47,7 +46,8 @@ bool RoundtripCheck(const std::vector<uint8_t>& input,
void TestRoundtripVariants() {
std::mt19937 rng_uniform(12345);
std::vector<uint8_t> random_uniform(64 * 1024);
- for (auto& b : random_uniform) b = (uint8_t)(rng_uniform() & 0xff);
+ for (auto& b : random_uniform)
+ b = (uint8_t)(rng_uniform() & 0xff);
std::mt19937 rng_skewed(67890);
std::vector<uint8_t> random_skewed(32 * 1024);
@@ -66,7 +66,7 @@ void TestRoundtripVariants() {
" return textureSample(tex, smplr, uv);\n"
"}\n";
std::vector<uint8_t> ascii_block;
- for (int i = 0; i < 50; ++i) { // cross chunk boundary
+ for (int i = 0; i < 50; ++i) { // cross chunk boundary
ascii_block.insert(ascii_block.end(), ascii, ascii + std::strlen(ascii));
}
@@ -124,7 +124,8 @@ void TestRejection() {
// 1) Mismatched models.
{
std::vector<uint8_t> v(4096);
- for (auto& b : v) b = (uint8_t)('a' + (rng() % 26));
+ for (auto& b : v)
+ b = (uint8_t)('a' + (rng() % 26));
uint32_t hist[256] = {};
ans::Histogram(v.data(), v.size(), hist);
@@ -141,10 +142,11 @@ void TestRejection() {
// 2) Corruption.
{
std::vector<uint8_t> v(2048);
- for (auto& b : v) b = (uint8_t)(rng() & 0xff);
+ for (auto& b : v)
+ b = (uint8_t)(rng() & 0xff);
std::vector<uint8_t> encoded;
assert(ans::Encode(v.data(), v.size(), &encoded, nullptr));
- encoded[encoded.size() / 2] ^= 0x55; // flip a payload byte
+ encoded[encoded.size() / 2] ^= 0x55; // flip a payload byte
std::vector<uint8_t> decoded(v.size());
size_t decoded_size = 0;
@@ -156,7 +158,8 @@ void TestRejection() {
// 3) Truncation.
{
std::vector<uint8_t> v(4096);
- for (size_t i = 0; i < v.size(); ++i) v[i] = (uint8_t)i;
+ for (size_t i = 0; i < v.size(); ++i)
+ v[i] = (uint8_t)i;
std::vector<uint8_t> encoded;
assert(ans::Encode(v.data(), v.size(), &encoded, nullptr));
encoded.resize(encoded.size() - 8);
@@ -173,11 +176,10 @@ void TestPeekSize() {
std::vector<uint8_t> v(1234, 'Q');
std::vector<uint8_t> encoded;
assert(ans::Encode(v.data(), v.size(), &encoded, nullptr));
- assert(ans::PeekUncompressedSize(encoded.data(), encoded.size()) ==
- v.size());
+ assert(ans::PeekUncompressedSize(encoded.data(), encoded.size()) == v.size());
}
-} // namespace
+} // namespace
int main() {
TestRoundtripVariants();