2 posts tagged “c”
celtic@sohma:~/code/linux/rubyex/translator$ ./test
test: "identifier": failure: Assertion failed on line 53: p.expressions.size() == 0
1 test(s) run, 0 test(s) succeeded.
celtic@sohma:~/code/linux/rubyex/translator$
これでテストコードがある:
And here we have the test code:
void _identifier()
{
Program p = parse_code("abc");
ASSERT(p.expressions.size() == 0);
}
The next question, of course, is of the best way to test parsers written in bison. I could just put all the parsing code in a separate library and have it compile two programs instead of the one big thing (i.e. one the parser, one the testing parser which just asserts all the output). I have no idea about test frameworks for C or C++, so I'll have a look now, I think.
