lab4 boolean & quadratic test
This commit is contained in:
parent
82a7e11dba
commit
19b1904793
|
|
@ -83,3 +83,30 @@ UTEST(parser, branching) {
|
|||
// Assert the result to test correctness
|
||||
ASSERT_EQ(result, 0);
|
||||
}
|
||||
|
||||
UTEST(parser, quadratic) {
|
||||
// Read sample file as input
|
||||
yyin = fopen("samples/quadratic-snippet.cbl", "r");
|
||||
yyrestart(yyin);
|
||||
ASSERT_TRUE(yyin);
|
||||
|
||||
yylineno = 1;
|
||||
int result = yyparse();
|
||||
|
||||
// Assert the result to test correctness
|
||||
ASSERT_EQ(result, 0);
|
||||
}
|
||||
|
||||
UTEST(parser, boolean) {
|
||||
// Must include the null character to terminate input
|
||||
char string[] = "IF A > B THEN Var = TRUE ELSE Var = FALSE\0";
|
||||
YY_BUFFER_STATE buffer = yy_scan_buffer(string, sizeof(string));
|
||||
|
||||
yylineno = 1;
|
||||
int result = yyparse();
|
||||
|
||||
yy_delete_buffer(buffer);
|
||||
|
||||
// Assert the result to test correctness
|
||||
ASSERT_EQ(result, 0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue