diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2025-08-04 12:07:12 +0200 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2026-09-04 11:06:05 +0200 |
| commit | 711cd23163ef2b593f5c6df64c30f33ae356fe77 (patch) | |
| tree | f52576285b080542d2cd87e3ba5a5774be8d0761 /gunit_tests/drawTestBase.cpp | |
| parent | db328d2a861f5aedec900e44fbe1fd542b307afb (diff) | |
clang-format + debug samples
Diffstat (limited to 'gunit_tests/drawTestBase.cpp')
| -rw-r--r-- | gunit_tests/drawTestBase.cpp | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/gunit_tests/drawTestBase.cpp b/gunit_tests/drawTestBase.cpp index 018132d..61ffea3 100644 --- a/gunit_tests/drawTestBase.cpp +++ b/gunit_tests/drawTestBase.cpp @@ -1,8 +1,8 @@ #include "drawTestBase.h" -//#define STB_IMAGE_IMPLEMENTATION +// #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" -//#define STB_IMAGE_WRITE_IMPLEMENTATION +// #define STB_IMAGE_WRITE_IMPLEMENTATION #include "stb_image_write.h" DrawTestBase::DrawTestBase() { @@ -15,44 +15,39 @@ DrawTestBase::DrawTestBase() { vkvg_device_create_info_t info{}; info.samples = VK_SAMPLE_COUNT_4_BIT; - dev = vkvg_device_create(&info); + dev = vkvg_device_create(&info); } -DrawTestBase::~DrawTestBase() { - vkvg_device_destroy(dev); -} +DrawTestBase::~DrawTestBase() { vkvg_device_destroy(dev); } -void DrawTestBase::SetUp() { - surf = vkvg_surface_create(dev, 256, 256); -} +void DrawTestBase::SetUp() { surf = vkvg_surface_create(dev, 256, 256); } -void DrawTestBase::TearDown() { - vkvg_surface_destroy(surf); -} +void DrawTestBase::TearDown() { vkvg_surface_destroy(surf); } void DrawTestBase::compareWithRefImage() { fs::path targetPath = targetDir / ::testing::UnitTest::GetInstance()->current_test_info()->name(); targetPath.replace_extension(".png"); if (fs::exists(targetPath)) { - int w = 0, h = 0, channels = 0; - unsigned char *refImg = stbi_load((char*)targetPath.c_str(), &w, &h, &channels, 4); // force 4 components per pixel + int w = 0, h = 0, channels = 0; + unsigned char* refImg = + stbi_load((char*)targetPath.c_str(), &w, &h, &channels, 4); // force 4 components per pixel EXPECT_TRUE(refImg != nullptr) << "Could not load image from " << targetPath << stbi_failure_reason(); - EXPECT_EQ(vkvg_surface_get_width(surf),w); - EXPECT_EQ(vkvg_surface_get_height(surf),h); + EXPECT_EQ(vkvg_surface_get_width(surf), w); + EXPECT_EQ(vkvg_surface_get_height(surf), h); - unsigned char *img = (unsigned char*)malloc(w*h*4); - unsigned char *diffImg = (unsigned char*)malloc(w*h*4); + unsigned char* img = (unsigned char*)malloc(w * h * 4); + unsigned char* diffImg = (unsigned char*)malloc(w * h * 4); vkvg_status_t result = vkvg_surface_write_to_memory(surf, img); EXPECT_EQ(result, VKVG_STATUS_SUCCESS); uint32_t totDiff = 0; - for(int y = 0; y < h; y++) { - for(int x = 0; x < w; x++) { - unsigned char* refPix = refImg + (y * w + x) * 4; - unsigned char* pix = img + (y * w + x) * 4; + for (int y = 0; y < h; y++) { + for (int x = 0; x < w; x++) { + unsigned char* refPix = refImg + (y * w + x) * 4; + unsigned char* pix = img + (y * w + x) * 4; unsigned char* diffPix = diffImg + (y * w + x) * 4; if (*refPix < *pix) *diffPix = *pix - *refPix; @@ -79,5 +74,3 @@ void DrawTestBase::compareWithRefImage() { GTEST_SKIP() << "Updating reference image: " << targetPath; } } - - |