From 19b190479303ebaf546d61cbd6a35332ab87679d Mon Sep 17 00:00:00 2001 From: Jenessy Lustre Date: Thu, 7 Nov 2024 11:35:33 -0800 Subject: [PATCH] lab4 boolean & quadratic test --- lab-4/main_test.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/lab-4/main_test.c b/lab-4/main_test.c index 057bed9..de1f347 100644 --- a/lab-4/main_test.c +++ b/lab-4/main_test.c @@ -82,4 +82,31 @@ UTEST(parser, branching) { // Assert the result to test correctness ASSERT_EQ(result, 0); -} \ No newline at end of file +} + +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); +}