54 lines
1.2 KiB
C
54 lines
1.2 KiB
C
// Kyler Olsen
|
|
// YREA SLS
|
|
// Lexer Tests
|
|
// October 2025
|
|
|
|
#include <stdlib.h>
|
|
#include <stdint.h>
|
|
|
|
#include "sls/sls_errors.h"
|
|
#include "sls/lexer.h"
|
|
#include "tests/tests.h"
|
|
|
|
static const size_t NUM_OF_TESTS = 1;
|
|
|
|
static LexerInfo start_up_test(const char *code) {
|
|
LexerInfo lexer_info;
|
|
lexer_init(&lexer_info, TEST_FILE_NAME, code);
|
|
return lexer_info;
|
|
}
|
|
|
|
static void clean_up_test(LexerResult result) {
|
|
if (result.type == SLS_RESULT)
|
|
clean_token_result(result.result);
|
|
}
|
|
|
|
static TestResult test_add_statement() {
|
|
TestResult test_result = (TestResult){ .name = "test_add_statement", .success = 0 };
|
|
LexerInfo lexer_info = start_up_test("3 4 +");
|
|
|
|
LexerResult result = lexical_analysis(&lexer_info);
|
|
|
|
if (result.type == SLS_ERROR) {
|
|
clean_up_test(result);
|
|
return test_result;
|
|
}
|
|
// TODO: Finish Test
|
|
|
|
clean_up_test(result);
|
|
test_result.success = 1;
|
|
return test_result;
|
|
}
|
|
|
|
TestsReport run_lexer_tests() {
|
|
TestsReport test_report = (TestsReport){
|
|
.section = "lexer_tests",
|
|
.count = NUM_OF_TESTS,
|
|
.tests = malloc(sizeof(TestResult) * NUM_OF_TESTS),
|
|
};
|
|
|
|
test_report.tests[0] = test_add_statement();
|
|
|
|
return test_report;
|
|
}
|