blob: a2fb28d7b2c519c7c61fb75b6082d720c68ff74c [file] [log] [blame]
#include "pw_unit_test/framework.h"
#include "samples/risp4ml/common/image.h"
#include "samples/risp4ml/common/test_utils.h"
class ImageTest : public ::testing::Test {
protected:
void SetUp() override {
img_ = image_new(3, 32, 64);
FillImage(img_);
}
void TearDown() override { image_delete(img_); }
Image* img_;
};
TEST_F(ImageTest, PixelAccess) {
for (uint16_t c = 0; c < img_->num_channels; ++c) {
for (uint16_t y = 0; y < img_->height; ++y) {
for (uint16_t x = 0; x < img_->width; ++x) {
ASSERT_EQ(image_pixel_val(img_, c, y, x), Pattern(c, y, x));
}
}
}
}
TEST_F(ImageTest, RowAccess) {
pixel_type_t* row_4 = image_row(img_, 1, 4);
for (uint16_t i = 0; i < 16; ++i) {
ASSERT_EQ(row_4[i], Pattern(1, 4, i));
}
}