diff --git a/Makefile.am b/Makefile.am index e3019d9a..eaf9a287 100644 --- a/Makefile.am +++ b/Makefile.am @@ -327,6 +327,7 @@ TEST_BIN = \ test/hmac \ test/hotp \ test/hton \ + test/image \ test/introspection \ test/ip \ test/json_types \ diff --git a/test/image.cpp b/test/image.cpp new file mode 100644 index 00000000..75e70792 --- /dev/null +++ b/test/image.cpp @@ -0,0 +1,33 @@ +#include "image.hpp" +#include "tap.hpp" + +#include + +int +main (void) +{ + util::TAP::logger tap; + + constexpr size_t W = 64; + constexpr size_t H = 128; + util::image::buffer img (W, H); + + if (!img.is_packed ()) + tap.skip ("linear position probe requires packed image allocation"); + else { + // write out sequential values at each pixel, row-major + size_t i = 0; + for (size_t y = 0; y < H; ++y) + for (size_t x = 0; x < W; ++x) + img[{x,y}] = i++; + + // check pixel values are sequential in row-major order + bool success = true; + for (size_t j = 0; j < i; ++j) + success = success && img[j] == j; + + tap.expect (success, "linear position probe"); + } + + return tap.status (); +}