MCPcopy Create free account
hub / github.com/OpenImageDebugger/OpenImageDebugger / TEST

Function TEST

tests/host/io/imgui_buffer_exporter_test.cpp:37–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35#include <gtest/gtest.h>
36
37TEST(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
61TEST(ImguiExporter, PngFailsOnBadPath) {
62 oid::BufferExporter::RgbaImage img;

Callers

nothing calls this directly

Calls 4

scratch_dirFunction · 0.85
export_rgba_pngFunction · 0.85
beginMethod · 0.80
endMethod · 0.80

Tested by

no test coverage detected