Add tests for chunk line numbers.

Which happen to find errors :P
This commit is contained in:
Bill Currie 2013-02-26 19:50:23 +09:00
parent d912970cd3
commit d1848a93c8

View file

@ -43,6 +43,19 @@ struct {
};
#define num_seg_tests (sizeof (seg_tests) / sizeof (seg_tests[0]))
struct {
const char *tag;
int expect;
} line_tests[] = {
{"Vertex", 3},
{"Geometry", 5},
{"Fragment.Erosion", 7},
{"Fragment.Grassfire", 9},
{"TessControl", 11},
{"TessEvaluation", 13}, // final chunk doesn't have \n
};
#define num_line_tests (sizeof (line_tests) / sizeof (line_tests[0]))
int
main (int argc, const char **argv)
{
@ -61,5 +74,14 @@ main (int argc, const char **argv)
res = 1;
}
}
for (i = 0; i < num_line_tests; i++) {
const segchunk_t *chunk = Segtext_FindChunk (st, line_tests[i].tag);
if (!chunk || chunk->start_line != line_tests[i].expect) {
fprintf (stderr, "FAIL: (%zd) \"%s\" -> %d, got %d\n", i,
line_tests[i].tag, line_tests[i].expect,
chunk->start_line);
res = 1;
}
}
return res;
}