summaryrefslogtreecommitdiff
path: root/src/tests/util
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-05-21 08:10:47 +0200
committerskal <pascal.massimino@gmail.com>2026-05-21 08:10:47 +0200
commitd806027dcaeadcdd8d2febd88bc46b2fd2c465de (patch)
tree30bc1ef9f40ccab7c00e31ee20e62bb86755fa26 /src/tests/util
parent680042a18c11ad5e58757e45b260745c2f52417f (diff)
style: apply clang-formatHEADmain
Diffstat (limited to 'src/tests/util')
-rw-r--r--src/tests/util/test_ans.cc24
-rw-r--r--src/tests/util/test_procedural.cc10
2 files changed, 21 insertions, 13 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();
diff --git a/src/tests/util/test_procedural.cc b/src/tests/util/test_procedural.cc
index c6616ad..355f70c 100644
--- a/src/tests/util/test_procedural.cc
+++ b/src/tests/util/test_procedural.cc
@@ -165,7 +165,10 @@ void test_voronoi() {
bool nonzero = false;
for (size_t i = 0; i < buffer.size(); i += 4) {
- if (buffer[i] > 0) { nonzero = true; break; }
+ if (buffer[i] > 0) {
+ nonzero = true;
+ break;
+ }
}
assert(nonzero);
@@ -204,7 +207,10 @@ void test_normalmap() {
// (non-flat normals expected)
bool has_normal_variation = false;
for (size_t i = 0; i < buffer.size(); i += 4) {
- if (buffer[i] != 128) { has_normal_variation = true; break; }
+ if (buffer[i] != 128) {
+ has_normal_variation = true;
+ break;
+ }
}
assert(has_normal_variation);