Testing utility functions.
More...
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>
#include <time.h>
#include <check.h>
#include "p1-lexer.h"
#include "p2-parser.h"
#include "p3-analysis.h"
#include "p4-codegen.h"
Go to the source code of this file.
|
#define | ERROR_RETURN_CODE (-9999) |
| Return value indicating an error.
|
|
#define | TEST_PROGRAM(NAME, RVAL, TEXT) |
| Define a test case with an entire program.
|
|
#define | TEST_MAIN(NAME, RVAL, TEXT) |
| Define a test case with only a 'main' function.
|
|
#define | TEST_EXPRESSION(NAME, RVAL, TEXT) |
| Define a test case with a single integer expression.
|
|
#define | TEST_BOOL_EXPRESSION(NAME, RVAL, TEXT) |
| Define a test case with a single boolean expression.
|
|
#define | TEST(NAME) tcase_add_test (tc, NAME) |
| Add a test to the test suite.
|
|
|
int | run_program (char *text) |
| Run lexer, parser, analysis, and code generation on given program.
|
|
int | run_main (char *text) |
| Run lexer, parser, analysis, and code generation on given 'main' function.
|
|
int | run_expression (char *text) |
| Run lexer, parser, analysis, and code generation on given integer expression.
|
|
int | run_bool_expression (char *text) |
| Run lexer, parser, analysis, and code generation on given boolean expression.
|
|
Testing utility functions.
◆ TEST_BOOL_EXPRESSION
#define TEST_BOOL_EXPRESSION |
( |
|
NAME, |
|
|
|
RVAL, |
|
|
|
TEXT |
|
) |
| |
Value:START_TEST (NAME) \
END_TEST
int run_bool_expression(char *text)
Run lexer, parser, analysis, and code generation on given boolean expression.
Definition testsuite.c:47
Define a test case with a single boolean expression.
◆ TEST_EXPRESSION
#define TEST_EXPRESSION |
( |
|
NAME, |
|
|
|
RVAL, |
|
|
|
TEXT |
|
) |
| |
Value:START_TEST (NAME) \
END_TEST
int run_expression(char *text)
Run lexer, parser, analysis, and code generation on given integer expression.
Definition testsuite.c:40
Define a test case with a single integer expression.
◆ TEST_MAIN
#define TEST_MAIN |
( |
|
NAME, |
|
|
|
RVAL, |
|
|
|
TEXT |
|
) |
| |
Value:START_TEST (NAME) \
{ ck_assert_int_eq (
run_main(TEXT), RVAL); } \
END_TEST
int run_main(char *text)
Run lexer, parser, analysis, and code generation on given 'main' function.
Definition testsuite.c:33
Define a test case with only a 'main' function.
◆ TEST_PROGRAM
#define TEST_PROGRAM |
( |
|
NAME, |
|
|
|
RVAL, |
|
|
|
TEXT |
|
) |
| |
Value:START_TEST (NAME) \
END_TEST
int run_program(char *text)
Run lexer, parser, analysis, and code generation on given program.
Definition testsuite.c:10
Define a test case with an entire program.
◆ run_bool_expression()
int run_bool_expression |
( |
char * |
text | ) |
|
Run lexer, parser, analysis, and code generation on given boolean expression.
- Parameters
-
text | Expression to lex, parse, analyze, and generate |
- Returns
- Return value or
ERROR_RETURN_CODE
if there was an error
◆ run_expression()
int run_expression |
( |
char * |
text | ) |
|
Run lexer, parser, analysis, and code generation on given integer expression.
- Parameters
-
text | Expression to lex, parse, analyze, and generate |
- Returns
- Return value or
ERROR_RETURN_CODE
if there was an error
◆ run_main()
int run_main |
( |
char * |
text | ) |
|
Run lexer, parser, analysis, and code generation on given 'main' function.
- Parameters
-
text | Function code to lex, parse, analyze, and generate |
- Returns
- Return value or
ERROR_RETURN_CODE
if there was an error
◆ run_program()
int run_program |
( |
char * |
text | ) |
|
Run lexer, parser, analysis, and code generation on given program.
- Parameters
-
text | Code to lex, parse, analyze, and generate |
- Returns
- Return value or
ERROR_RETURN_CODE
if there was an error