| 35 | #include <gtest/gtest.h> |
| 36 | |
| 37 | TEST(ImguiExporter, PngRoundTrip) { |
| 38 | oid::BufferExporter::RgbaImage img; |
| 39 | img.width = 2; |
| 40 | img.height = 2; |
| 41 | // clang-format off |
| 42 | img.pixels = {255, 0, 0, 255, |
| 43 | 0, 255, 0, 255, |
| 44 | 0, 0, 255, 255, |
| 45 | 9, 8, 7, 255}; |
| 46 | // clang-format on |
| 47 | const auto p = oid::test::scratch_dir() / "oid_p5_rt.png"; |
| 48 | std::filesystem::remove(p); |
| 49 | ASSERT_TRUE(oid::host::export_rgba_png(img, p.string())); |
| 50 | int w{}; |
| 51 | int h{}; |
| 52 | int n{}; |
| 53 | unsigned char* data = stbi_load(p.string().c_str(), &w, &h, &n, 4); |
| 54 | ASSERT_NE(data, nullptr); |
| 55 | EXPECT_EQ(w, 2); |
| 56 | EXPECT_EQ(h, 2); |
| 57 | EXPECT_TRUE(std::equal(img.pixels.begin(), img.pixels.end(), data)); |
| 58 | stbi_image_free(data); |
| 59 | } |
| 60 | |
| 61 | TEST(ImguiExporter, PngFailsOnBadPath) { |
| 62 | oid::BufferExporter::RgbaImage img; |
nothing calls this directly
no test coverage detected