image: add simple offset test
This commit is contained in:
parent
d388e6543f
commit
86b36afc49
@ -327,6 +327,7 @@ TEST_BIN = \
|
|||||||
test/hmac \
|
test/hmac \
|
||||||
test/hotp \
|
test/hotp \
|
||||||
test/hton \
|
test/hton \
|
||||||
|
test/image \
|
||||||
test/introspection \
|
test/introspection \
|
||||||
test/ip \
|
test/ip \
|
||||||
test/json_types \
|
test/json_types \
|
||||||
|
33
test/image.cpp
Normal file
33
test/image.cpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#include "image.hpp"
|
||||||
|
#include "tap.hpp"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
int
|
||||||
|
main (void)
|
||||||
|
{
|
||||||
|
util::TAP::logger tap;
|
||||||
|
|
||||||
|
constexpr size_t W = 64;
|
||||||
|
constexpr size_t H = 128;
|
||||||
|
util::image::buffer<uint16_t> 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 ();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user