MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / Verify

Function Verify

test/browser/test_sdl2_gl_read.c:127–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125}
126
127void Verify() {
128 unsigned char *data = malloc(width*height*4 + 16);
129 int *last = (int*)(data + width*height*4 - 4);
130 int *after = (int*)(data + width*height*4);
131 *last = 0xdeadbeef;
132 *after = 0x12345678;
133 glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
134 assert(*last != 0xdeadbeef); // should overwrite the buffer to the end
135 assert(*after == 0x12345678); // nothing should be written afterwards!
136 // Should see some blue, and nothing else
137 int seen = 0;
138 int ok = 1;
139 for (int x = 0; x < width*height; x++) {
140 seen = seen || data[x*4+2] != 0;
141 ok = ok && (data[x*4+0] == 0);
142 ok = ok && (data[x*4+1] == 0);
143 }
144 assert(seen);
145 assert(ok);
146}
147
148int main(int argc, char *argv[])
149{

Callers 1

mainFunction · 0.70

Calls 2

mallocFunction · 0.50
assertFunction · 0.50

Tested by

no test coverage detected