53 lines
1.7 KiB
C
53 lines
1.7 KiB
C
// Kyler Olsen
|
|
// YREA SLS
|
|
// Extra Tests
|
|
// November 2025
|
|
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <stdint.h>
|
|
|
|
#include "sls/string.h"
|
|
#include "sls/lexer.h"
|
|
#include "sls/errors.h"
|
|
#include "tests/lexer_test_helpers.h"
|
|
#include "tests/tests.h"
|
|
|
|
static const size_t NUM_EXTRA_TESTS = 2;
|
|
|
|
static TestResult test_Identifier_Addition() {
|
|
LexerTest test = start_up_test(SLS_STR("Identifier Addition"), SLS_STR("+"));
|
|
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
size_t i = 0;
|
|
if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("+")})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Identifier_Division() {
|
|
LexerTest test = start_up_test(SLS_STR("Identifier Division"), SLS_STR("/"));
|
|
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
size_t i = 0;
|
|
if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("/")})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
// Run all extra tests
|
|
TestsReport run_extra_tests()
|
|
{
|
|
TestsReport report = {
|
|
.section = SLS_STR("extra_tests"),
|
|
.count = NUM_EXTRA_TESTS,
|
|
.tests = malloc(sizeof(TestResult) * NUM_EXTRA_TESTS)};
|
|
|
|
size_t i = 0;
|
|
(void)i;
|
|
report.tests[i++] = test_Identifier_Addition();
|
|
report.tests[i++] = test_Identifier_Division();
|
|
return report;
|
|
}
|