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

Function TEST

tests/visualization/glyph_atlas_test.cpp:34–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32#include <gtest/gtest.h>
33
34TEST(GlyphAtlas, FinalizeComputesPow2AndTables) {
35 // Strip 6x4: one fake glyph 'A' of advance 6; rows 0 and 3 empty,
36 // rows 1-2 filled. Scan semantics: the first empty row (y=0) sets
37 // real_descent=0; a later empty row after filled rows (y=3) sets
38 // real_ascent=3 -> cropped height = 3 - 0 = 3.
39 std::vector<std::uint8_t> strip(6 * 4, 0);
40 for (int x = 0; x < 6; ++x) {
41 strip[6 * 1 + x] = 255;
42 strip[6 * 2 + x] = 200;
43 }
44 std::array<int, 256> adv{};
45 adv['A'] = 6;
46 // kGlyphText drives table fill; for the test call a charset-parameterized
47 // overload finalize_strip_atlas(strip, w, h, adv, "A"):
48 const auto atlas = oid::finalize_strip_atlas(strip.data(), 6, 4, adv, "A");
49 EXPECT_EQ(atlas.texture_width, 8.0f); // pow2 of 6
50 EXPECT_EQ(atlas.texture_height, 4.0f); // pow2 of 4
51 EXPECT_EQ(atlas.pixels.size(), 8u * 4u);
52 EXPECT_EQ(atlas.pixels[8 * 1 + 0], 255); // packed row content preserved
53 EXPECT_EQ(atlas.advances['A'][0], 6);
54 EXPECT_EQ(atlas.offsets['A'][0], 0);
55 EXPECT_EQ(atlas.offsets['A'][1], 0); // real_descent baseline
56 EXPECT_EQ(atlas.sizes['A'][1], 3); // cropped height = real_ascent-descent
57}
58
59TEST(GlyphAtlas, DeterministicAcrossTwoCalls) {
60 std::vector<std::uint8_t> strip(4 * 2, 7);

Callers

nothing calls this directly

Calls 3

finalize_strip_atlasFunction · 0.85
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected