2673 lines
136 KiB
C
2673 lines
136 KiB
C
// Kyler Olsen
|
|
// YREA SLS
|
|
// Lexer Tests
|
|
// October 2025
|
|
|
|
#include <stdlib.h>
|
|
#include <stdint.h>
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
#include <math.h>
|
|
|
|
#include "sls/errors.h"
|
|
#include "sls/lexer.h"
|
|
#include "sls/string.h"
|
|
#include "tests/lexer_test_helpers.h"
|
|
#include "tests/tests.h"
|
|
|
|
|
|
static const size_t NUM_OF_TESTS = 243;
|
|
|
|
static TestResult test_Empty_Statement() {
|
|
LexerTest test = start_up_test(SLS_STR("Empty_Statement"), 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_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_Default_Decimal_0() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer Default Decimal 0"), SLS_STR("0"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 0})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_Default_Decimal_1() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer Default Decimal -1"), SLS_STR("-1"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, -1})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_Default_Decimal_42() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer Default Decimal 42"), SLS_STR("42"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 42})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_Default_Decimal_Leading_Zeros() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer Default Decimal Leading Zeros"), SLS_STR("00042"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 42})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_Default_Hex_0xFF() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer Default Hex 0xFF"), SLS_STR("0xFF"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 255})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_Default_Hex_0xdeadbeef() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer Default Hex 0xdeadbeef"), SLS_STR("0xdeadbeef"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 3735928559})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_Default_Hex_Max() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer Default Hex Max"), SLS_STR("0x7FFFFFFFFFFFFFFF"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 9223372036854775807})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_Default_Binary_0b1010() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer Default Binary 0b1010"), SLS_STR("0b1010"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 10})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_Default_Binary_All_Ones() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer Default Binary All Ones"), SLS_STR("0b1111111111111111"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 65535})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_Default_Octal_0o755() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer Default Octal 0o755"), SLS_STR("0o755"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 493})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_Default_Octal_Max_Three_Digits() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer Default Octal Max Three Digits"), SLS_STR("0o777"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 511})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_Default_Decimal_Max_i64() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer Default Decimal Max i64"), SLS_STR("9223372036854775807"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 9223372036854775807})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_Default_Decimal_Min_i64() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer Default Decimal Min i64"), SLS_STR("-9223372036854775808"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, INT64_MIN})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_Default_Decimal_with_Underscore() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer Default Decimal with Underscore"), SLS_STR("1_000_000"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 1000000})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_Default_Underscore_End() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer Default Underscore End"), SLS_STR("42_"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 42})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_Default_Underscore_Double() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer Default Underscore Double"), SLS_STR("4__2"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 42})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_Default_Whitespace() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer Default Whitespace"), SLS_STR(" 42 "));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 42})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_Default_Hex_Zero() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer Default Hex Zero"), SLS_STR("0x0"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 0})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_Default_Binary_Zero() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer Default Binary Zero"), SLS_STR("0b0"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 0})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_Default_Octal_Zero() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer Default Octal Zero"), SLS_STR("0o0"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 0})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_Default_Decimal_with_Commas_Invalid() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer Default Decimal with Commas Invalid"), SLS_STR("1,000,000"));
|
|
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_for_error(&test, result, i++, SLS_STR("Invalid decimal literal: unexpected ',' in decimal integer."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_Default_Invalid_Characters() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer Default Invalid Characters"), SLS_STR("12a3"));
|
|
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_for_error(&test, result, i++, SLS_STR("Invalid decimal literal: unexpected 'a' in decimal integer."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_Default_Invalid_Prefix() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer Default Invalid Prefix"), SLS_STR("0b2"));
|
|
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_for_error(&test, result, i++, SLS_STR("Invalid binary literal: unexpected '2' in binary integer."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i8_Decimal_Positive() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i8 Decimal Positive"), SLS_STR("42:i8"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I8, 42})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i8_Zero() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i8 Zero"), SLS_STR("0:i8"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I8, 0})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i8_Decimal_Negative() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i8 Decimal Negative"), SLS_STR("-100:i8"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I8, -100})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i8_Hex() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i8 Hex"), SLS_STR("0x7F:i8"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I8, 127})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i8_Binary() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i8 Binary"), SLS_STR("0b1111:i8"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I8, 15})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i8_Octal() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i8 Octal"), SLS_STR("0o77:i8"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I8, 63})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i8_Max_Value() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i8 Max Value"), SLS_STR("127:i8"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I8, 127})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i8_Min_Value() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i8 Min Value"), SLS_STR("-128:i8"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I8, -128})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i8_Overflow() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i8 Overflow"), SLS_STR("128:i8"));
|
|
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_for_error(&test, result, i++, SLS_STR("Integer overflow: value exceeds range for i8."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i8_Underflow() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i8 Underflow"), SLS_STR("-129:i8"));
|
|
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_for_error(&test, result, i++, SLS_STR("Integer overflow: value exceeds range for i8."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i8_Hex_Max() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i8 Hex Max"), SLS_STR("0x7F:i8"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I8, 127})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i8_Binary_Max() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i8 Binary Max"), SLS_STR("0b01111111:i8"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I8, 127})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i8_Octal_Max() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i8 Octal Max"), SLS_STR("0o177:i8"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I8, 127})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i8_Negative_Hex() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i8 Negative Hex"), SLS_STR("-0x80:i8"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I8, -128})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i16_Decimal_Positive() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i16 Decimal Positive"), SLS_STR("42:i16"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I16, 42})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i16_Zero() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i16 Zero"), SLS_STR("0:i16"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I16, 0})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i16_Decimal_Negative() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i16 Decimal Negative"), SLS_STR("-100:i16"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I16, -100})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i16_Hex() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i16 Hex"), SLS_STR("0xFF:i16"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I16, 255})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i16_Binary() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i16 Binary"), SLS_STR("0b1111:i16"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I16, 15})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i16_Octal() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i16 Octal"), SLS_STR("0o77:i16"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I16, 63})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i16_Max_Value() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i16 Max Value"), SLS_STR("32767:i16"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I16, 32767})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i16_Min_Value() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i16 Min Value"), SLS_STR("-32768:i16"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I16, -32768})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i16_Overflow() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i16 Overflow"), SLS_STR("32768:i16"));
|
|
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_for_error(&test, result, i++, SLS_STR("Integer overflow: value exceeds range for i16."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i16_Underflow() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i16 Underflow"), SLS_STR("-32769:i16"));
|
|
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_for_error(&test, result, i++, SLS_STR("Integer overflow: value exceeds range for i16."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i16_Hex_Sample() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i16 Hex Sample"), SLS_STR("0x1234:i16"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I16, 4660})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i16_Binary_Sample() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i16 Binary Sample"), SLS_STR("0b1111111100000000:i16"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I16, 65280})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i16_Octal_Sample() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i16 Octal Sample"), SLS_STR("0o1234:i16"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I16, 668})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i32_Decimal_Positive() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i32 Decimal Positive"), SLS_STR("42:i32"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I32, 42})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i32_Zero() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i32 Zero"), SLS_STR("0:i32"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I32, 0})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i32_Decimal_Negative() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i32 Decimal Negative"), SLS_STR("-100:i32"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I32, -100})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i32_Hex() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i32 Hex"), SLS_STR("0xFF:i32"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I32, 255})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i32_Binary() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i32 Binary"), SLS_STR("0b1111:i32"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I32, 15})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i32_Octal() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i32 Octal"), SLS_STR("0o77:i32"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I32, 63})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i32_Max_Value() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i32 Max Value"), SLS_STR("2147483647:i32"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I32, 2147483647})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i32_Min_Value() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i32 Min Value"), SLS_STR("-2147483648:i32"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I32, -2147483648})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i32_Overflow() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i32 Overflow"), SLS_STR("2147483648:i32"));
|
|
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_for_error(&test, result, i++, SLS_STR("Integer overflow: value exceeds range for i32."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i32_Underflow() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i32 Underflow"), SLS_STR("-2147483649:i32"));
|
|
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_for_error(&test, result, i++, SLS_STR("Integer overflow: value exceeds range for i32."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i32_With_Underscores() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i32 With Underscores"), SLS_STR("1_000_000:i32"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I32, 1000000})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i32_Hex_Sample() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i32 Hex Sample"), SLS_STR("0xABCD:i32"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I32, 43981})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i32_Binary_Sample() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i32 Binary Sample"), SLS_STR("0b11110000:i32"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I32, 240})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i64_Decimal_Positive() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i64 Decimal Positive"), SLS_STR("42:i64"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 42})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i64_Zero() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i64 Zero"), SLS_STR("0:i64"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 0})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i64_Decimal_Negative() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i64 Decimal Negative"), SLS_STR("-100:i64"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, -100})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i64_Hex() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i64 Hex"), SLS_STR("0xFF:i64"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 255})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i64_Binary() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i64 Binary"), SLS_STR("0b1111:i64"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 15})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i64_Octal() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i64 Octal"), SLS_STR("0o77:i64"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 63})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i64_Max_Value() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i64 Max Value"), SLS_STR("9223372036854775807:i64"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 9223372036854775807})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i64_Min_Value() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i64 Min Value"), SLS_STR("-9223372036854775808:i64"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, INT64_MIN})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i64_Overflow() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i64 Overflow"), SLS_STR("9223372036854775808:i64"));
|
|
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_for_error(&test, result, i++, SLS_STR("Integer overflow: value exceeds range for i64."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i64_Underflow() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i64 Underflow"), SLS_STR("-9223372036854775809:i64"));
|
|
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_for_error(&test, result, i++, SLS_STR("Integer overflow: value exceeds range for i64."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i64_With_Underscores() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i64 With Underscores"), SLS_STR("1_000_000:i64"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 1000000})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i64_Decimal_Positive_42() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i64 Decimal Positive 42"), SLS_STR("42:i64"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 42})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i64_Hex_0xFF() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i64 Hex 0xFF"), SLS_STR("0xFF:i64"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 255})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i64_Binary_0b1010() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i64 Binary 0b1010"), SLS_STR("0b1010:i64"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 10})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_i64_Octal_0o755() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer i64 Octal 0o755"), SLS_STR("0o755:i64"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 493})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u8_Decimal_Positive() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u8 Decimal Positive"), SLS_STR("42:u8"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U8, 42})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u8_Zero() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u8 Zero"), SLS_STR("0:u8"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U8, 0})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u8_Hex() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u8 Hex"), SLS_STR("0xFF:u8"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U8, 255})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u8_Binary() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u8 Binary"), SLS_STR("0b1111:u8"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U8, 15})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u8_Octal() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u8 Octal"), SLS_STR("0o77:u8"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U8, 63})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u8_Max_Value() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u8 Max Value"), SLS_STR("255:u8"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U8, 255})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u8_Min_Value() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u8 Min Value"), SLS_STR("0:u8"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U8, 0})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u8_Overflow() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u8 Overflow"), SLS_STR("256:u8"));
|
|
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_for_error(&test, result, i++, SLS_STR("Integer overflow: value exceeds range for u8."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u8_Underflow() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u8 Underflow"), SLS_STR("-1:u8"));
|
|
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_for_error(&test, result, i++, SLS_STR("Integer overflow: value exceeds range for u8."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u8_Hex_Max() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u8 Hex Max"), SLS_STR("0xFF:u8"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U8, 255})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u8_Binary_Max() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u8 Binary Max"), SLS_STR("0b11111111:u8"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U8, 255})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u8_Octal_Max() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u8 Octal Max"), SLS_STR("0o377:u8"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U8, 255})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u16_Decimal_Positive() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u16 Decimal Positive"), SLS_STR("42:u16"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U16, 42})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u16_Zero() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u16 Zero"), SLS_STR("0:u16"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U16, 0})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u16_Hex() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u16 Hex"), SLS_STR("0xFF:u16"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U16, 255})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u16_Binary() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u16 Binary"), SLS_STR("0b1111:u16"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U16, 15})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u16_Octal() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u16 Octal"), SLS_STR("0o77:u16"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U16, 63})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u16_Max_Value() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u16 Max Value"), SLS_STR("65535:u16"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U16, 65535})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u16_Min_Value() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u16 Min Value"), SLS_STR("0:u16"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U16, 0})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u16_Overflow() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u16 Overflow"), SLS_STR("65536:u16"));
|
|
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_for_error(&test, result, i++, SLS_STR("Integer overflow: value exceeds range for u16."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u16_Underflow() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u16 Underflow"), SLS_STR("-1:u16"));
|
|
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_for_error(&test, result, i++, SLS_STR("Integer overflow: value exceeds range for u16."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u16_Hex_Max() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u16 Hex Max"), SLS_STR("0xFFFF:u16"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U16, 65535})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u16_Binary_Max() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u16 Binary Max"), SLS_STR("0b1111111111111111:u16"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U16, 65535})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u16_Octal_Max() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u16 Octal Max"), SLS_STR("0o177777:u16"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U16, 65535})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u16_Decimal_Mid() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u16 Decimal Mid"), SLS_STR("50000:u16"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U16, 50000})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u32_Decimal_Positive() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u32 Decimal Positive"), SLS_STR("42:u32"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U32, 42})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u32_Zero() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u32 Zero"), SLS_STR("0:u32"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U32, 0})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u32_Hex() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u32 Hex"), SLS_STR("0xFF:u32"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U32, 255})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u32_Binary() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u32 Binary"), SLS_STR("0b1111:u32"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U32, 15})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u32_Octal() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u32 Octal"), SLS_STR("0o77:u32"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U32, 63})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u32_Max_Value() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u32 Max Value"), SLS_STR("4294967295:u32"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U32, 4294967295})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u32_Min_Value() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u32 Min Value"), SLS_STR("0:u32"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U32, 0})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u32_Overflow() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u32 Overflow"), SLS_STR("4294967296:u32"));
|
|
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_for_error(&test, result, i++, SLS_STR("Integer overflow: value exceeds range for u32."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u32_Underflow() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u32 Underflow"), SLS_STR("-1:u32"));
|
|
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_for_error(&test, result, i++, SLS_STR("Integer overflow: value exceeds range for u32."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u32_With_Underscores() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u32 With Underscores"), SLS_STR("1_000_000:u32"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U32, 1000000})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u32_Hex_Max() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u32 Hex Max"), SLS_STR("0xFFFFFFFF:u32"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U32, 4294967295})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u32_Binary_Sample() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u32 Binary Sample"), SLS_STR("0b11111111000000001111111100000000:u32"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U32, 4278255360})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u32_Octal_Max() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u32 Octal Max"), SLS_STR("0o37777777777:u32"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U32, 4294967295})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u32_Decimal_Mid() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u32 Decimal Mid"), SLS_STR("1000000:u32"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U32, 1000000})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u64_Decimal_Positive() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u64 Decimal Positive"), SLS_STR("42:u64"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U64, 42})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u64_Zero() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u64 Zero"), SLS_STR("0:u64"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U64, 0})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u64_Hex() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u64 Hex"), SLS_STR("0xFF:u64"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U64, 255})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u64_Binary() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u64 Binary"), SLS_STR("0b1111:u64"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U64, 15})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u64_Octal() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u64 Octal"), SLS_STR("0o77:u64"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U64, 63})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u64_Max_Value() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u64 Max Value"), SLS_STR("18446744073709551615:u64"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U64, UINT64_MAX})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u64_Min_Value() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u64 Min Value"), SLS_STR("0:u64"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U64, 0})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u64_Overflow() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u64 Overflow"), SLS_STR("18446744073709551616:u64"));
|
|
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_for_error(&test, result, i++, SLS_STR("Integer overflow: value exceeds range for u64."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u64_Underflow() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u64 Underflow"), SLS_STR("-1:u64"));
|
|
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_for_error(&test, result, i++, SLS_STR("Integer overflow: value exceeds range for u64."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u64_With_Underscores() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u64 With Underscores"), SLS_STR("1_000_000:u64"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U64, 1000000})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u64_Hex_Max() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u64 Hex Max"), SLS_STR("0xFFFFFFFFFFFFFFFF:u64"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U64, UINT64_MAX})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u64_Binary_Sample() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u64 Binary Sample"), SLS_STR("0b1010101010101010:u64"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U64, 43690})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u64_Octal_Sample() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u64 Octal Sample"), SLS_STR("0o7777:u64"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U64, 4095})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_u64_Decimal() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer u64 Decimal"), SLS_STR("42:u64"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_U64, 42})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_Hex_With_Underscores() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer Hex With Underscores"), SLS_STR("0xDEAD_BEEF:i64"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I64, 3735928559})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_Binary_With_Underscores() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer Binary With Underscores"), SLS_STR("0b1111_0000_1010_0101:i32"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I32, 61605})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Integer_Octal_With_Underscores() {
|
|
LexerTest test = start_up_test(SLS_STR("Integer Octal With Underscores"), SLS_STR("0o7_7_7:i16"));
|
|
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_integer_value(&test, result, i++, &(TestIntegerValue){INTEGER_I16, 511})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Default_Simple() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Default Simple"), SLS_STR("3.14"));
|
|
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_double_value(&test, result, i++, &(double){3.14})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Default_Zero() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Default Zero"), SLS_STR("0.0"));
|
|
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_double_value(&test, result, i++, &(double){0.0})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Default_Negative() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Default Negative"), SLS_STR("-2.5"));
|
|
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_double_value(&test, result, i++, &(double){-2.5})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Default_One() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Default One"), SLS_STR("1.0"));
|
|
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_double_value(&test, result, i++, &(double){1.0})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_f32_Simple() {
|
|
LexerTest test = start_up_test(SLS_STR("Float f32 Simple"), SLS_STR("3.14:f32"));
|
|
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_float_value(&test, result, i++, &(float){3.14})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_f64_Simple() {
|
|
LexerTest test = start_up_test(SLS_STR("Float f64 Simple"), SLS_STR("2.718:f64"));
|
|
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_double_value(&test, result, i++, &(double){2.718})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Default_Leading_Zeros() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Default Leading Zeros"), SLS_STR("00042.5"));
|
|
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_double_value(&test, result, i++, &(double){42.5})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Default_Leading_Zero_Decimal() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Default Leading Zero Decimal"), SLS_STR("0.5"));
|
|
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_double_value(&test, result, i++, &(double){0.5})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Default_Trailing_Zeros() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Default Trailing Zeros"), SLS_STR("3.1400"));
|
|
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_double_value(&test, result, i++, &(double){3.14})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Default_No_Leading_Digit() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Default No Leading Digit"), SLS_STR(".5"));
|
|
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_double_value(&test, result, i++, &(double){0.5})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Default_No_Leading_Digit_Negative() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Default No Leading Digit Negative"), SLS_STR("-.25"));
|
|
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_double_value(&test, result, i++, &(double){-0.25})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Default_No_Trailing_Digits() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Default No Trailing Digits"), SLS_STR("42."));
|
|
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_double_value(&test, result, i++, &(double){42.0})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Default_No_Trailing_Digits_Negative() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Default No Trailing Digits Negative"), SLS_STR("-7."));
|
|
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_double_value(&test, result, i++, &(double){-7.0})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Default_Very_Small() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Default Very Small"), SLS_STR("0.000001"));
|
|
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_double_value(&test, result, i++, &(double){1e-06})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Default_Very_Large() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Default Very Large"), SLS_STR("1000000.0"));
|
|
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_double_value(&test, result, i++, &(double){1000000.0})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Default_Underscore_Integer_Part() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Default Underscore Integer Part"), SLS_STR("1_000_000.5"));
|
|
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_double_value(&test, result, i++, &(double){1000000.5})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Default_Underscore_Decimal_Part() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Default Underscore Decimal Part"), SLS_STR("3.141_592_653"));
|
|
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_double_value(&test, result, i++, &(double){3.141592653})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Default_Underscore_Both_Parts() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Default Underscore Both Parts"), SLS_STR("1_234.567_89"));
|
|
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_double_value(&test, result, i++, &(double){1234.56789})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Default_Underscore_Trailing() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Default Underscore Trailing"), SLS_STR("42.5_"));
|
|
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_double_value(&test, result, i++, &(double){42.5})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Default_Underscore_Double() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Default Underscore Double"), SLS_STR("4__2.5"));
|
|
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_double_value(&test, result, i++, &(double){42.5})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_f32_With_Underscores() {
|
|
LexerTest test = start_up_test(SLS_STR("Float f32 With Underscores"), SLS_STR("1_234.567_89:f32"));
|
|
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_float_value(&test, result, i++, &(float){1234.56789})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_f32_Precision_Limit() {
|
|
LexerTest test = start_up_test(SLS_STR("Float f32 Precision Limit"), SLS_STR("1.2345678:f32"));
|
|
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_float_value(&test, result, i++, &(float){1.2345678})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_f32_High_Precision() {
|
|
LexerTest test = start_up_test(SLS_STR("Float f32 High Precision"), SLS_STR("3.141592653589793:f32"));
|
|
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_float_value(&test, result, i++, &(float){3.141592653589793})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_f64_Precision_Limit() {
|
|
LexerTest test = start_up_test(SLS_STR("Float f64 Precision Limit"), SLS_STR("1.234567890123456:f64"));
|
|
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_double_value(&test, result, i++, &(double){1.234567890123456})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_f64_High_Precision() {
|
|
LexerTest test = start_up_test(SLS_STR("Float f64 High Precision"), SLS_STR("3.141592653589793238:f64"));
|
|
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_double_value(&test, result, i++, &(double){3.141592653589793})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_f64_Close_Numbers_1() {
|
|
LexerTest test = start_up_test(SLS_STR("Float f64 Close Numbers 1"), SLS_STR("1.0000000000000001:f64"));
|
|
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_double_value(&test, result, i++, &(double){1.0})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_f64_Close_Numbers_2() {
|
|
LexerTest test = start_up_test(SLS_STR("Float f64 Close Numbers 2"), SLS_STR("1.0000000000000002:f64"));
|
|
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_double_value(&test, result, i++, &(double){1.0000000000000002})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Invalid_Multiple_Decimal_Points() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Invalid Multiple Decimal Points"), SLS_STR("3.14.159"));
|
|
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_for_error(&test, result, i++, SLS_STR("Invalid float literal: unexpected '.' in float."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Invalid_Characters() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Invalid Characters"), SLS_STR("3.1a4"));
|
|
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_for_error(&test, result, i++, SLS_STR("Invalid float literal: unexpected 'a' in float."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Invalid_Type_Annotation() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Invalid Type Annotation"), SLS_STR("3.14:i32"));
|
|
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_for_error(&test, result, i++, SLS_STR("Invalid float type: must be of type 'f64' or 'f32'."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Invalid_Type_Name() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Invalid Type Name"), SLS_STR("3.14:f16"));
|
|
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_for_error(&test, result, i++, SLS_STR("Invalid float type: must be of type 'f64' or 'f32'."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Invalid_Comma_Separator() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Invalid Comma Separator"), SLS_STR("1,234.56"));
|
|
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_for_error(&test, result, i++, SLS_STR("Invalid float literal: unexpected ',' in float."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Default_Leading_Whitespace() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Default Leading Whitespace"), SLS_STR(" 3.14"));
|
|
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_double_value(&test, result, i++, &(double){3.14})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Default_Trailing_Whitespace() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Default Trailing Whitespace"), SLS_STR("3.14 "));
|
|
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_double_value(&test, result, i++, &(double){3.14})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Default_Both_Whitespace() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Default Both Whitespace"), SLS_STR(" 3.14 "));
|
|
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_double_value(&test, result, i++, &(double){3.14})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_f32_With_Whitespace() {
|
|
LexerTest test = start_up_test(SLS_STR("Float f32 With Whitespace"), SLS_STR(" 2.718:f32 "));
|
|
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_float_value(&test, result, i++, &(float){2.718})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Default_Pi_Approximate() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Default Pi Approximate"), SLS_STR("3.141592653589793"));
|
|
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_double_value(&test, result, i++, &(double){3.141592653589793})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_f32_Pi_Approximate() {
|
|
LexerTest test = start_up_test(SLS_STR("Float f32 Pi Approximate"), SLS_STR("3.1415927:f32"));
|
|
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_float_value(&test, result, i++, &(float){3.1415927})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Default_Euler_Approximate() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Default Euler Approximate"), SLS_STR("2.718281828459045"));
|
|
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_double_value(&test, result, i++, &(double){2.718281828459045})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_f32_Euler_Approximate() {
|
|
LexerTest test = start_up_test(SLS_STR("Float f32 Euler Approximate"), SLS_STR("2.7182817:f32"));
|
|
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_float_value(&test, result, i++, &(float){2.7182817})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Default_Golden_Ratio() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Default Golden Ratio"), SLS_STR("1.618033988749895"));
|
|
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_double_value(&test, result, i++, &(double){1.618033988749895})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Default_Sqrt2() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Default Sqrt2"), SLS_STR("1.4142135623730951"));
|
|
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_double_value(&test, result, i++, &(double){1.4142135623730951})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Default_Positive_Zero() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Default Positive Zero"), SLS_STR("0.0"));
|
|
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_double_value(&test, result, i++, &(double){0.0})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_Default_Negative_Zero() {
|
|
LexerTest test = start_up_test(SLS_STR("Float Default Negative Zero"), SLS_STR("-0.0"));
|
|
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_double_value(&test, result, i++, &(double){-0.0})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_f32_Positive_Zero() {
|
|
LexerTest test = start_up_test(SLS_STR("Float f32 Positive Zero"), SLS_STR("0.0:f32"));
|
|
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_float_value(&test, result, i++, &(float){0.0})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Float_f32_Negative_Zero() {
|
|
LexerTest test = start_up_test(SLS_STR("Float f32 Negative Zero"), SLS_STR("-0.0:f32"));
|
|
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_float_value(&test, result, i++, &(float){-0.0})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Simple_Letter_A() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Simple Letter A"), SLS_STR("'A'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){65})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Simple_Letter_a() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Simple Letter a"), SLS_STR("'a'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){97})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Simple_Letter_Z() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Simple Letter Z"), SLS_STR("'Z'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){90})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Simple_Letter_z() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Simple Letter z"), SLS_STR("'z'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){122})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Digit_0() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Digit 0"), SLS_STR("'0'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){48})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Digit_5() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Digit 5"), SLS_STR("'5'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){53})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Digit_9() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Digit 9"), SLS_STR("'9'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){57})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Space() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Space"), 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_character_value(&test, result, i++, &(uint8_t){32})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Exclamation() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Exclamation"), 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_character_value(&test, result, i++, &(uint8_t){33})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Question_Mark() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Question Mark"), 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_character_value(&test, result, i++, &(uint8_t){63})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Period() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Period"), 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_character_value(&test, result, i++, &(uint8_t){46})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Comma() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Comma"), 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_character_value(&test, result, i++, &(uint8_t){44})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Semicolon() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Semicolon"), 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_character_value(&test, result, i++, &(uint8_t){59})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Colon() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Colon"), 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_character_value(&test, result, i++, &(uint8_t){58})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Plus() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Plus"), 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_character_value(&test, result, i++, &(uint8_t){43})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Minus() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Minus"), 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_character_value(&test, result, i++, &(uint8_t){45})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Asterisk() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Asterisk"), 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_character_value(&test, result, i++, &(uint8_t){42})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Slash() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Slash"), 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_character_value(&test, result, i++, &(uint8_t){47})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Equals() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Equals"), 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_character_value(&test, result, i++, &(uint8_t){61})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Less_Than() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Less Than"), 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_character_value(&test, result, i++, &(uint8_t){60})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Greater_Than() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Greater Than"), 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_character_value(&test, result, i++, &(uint8_t){62})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Left_Paren() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Left Paren"), 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_character_value(&test, result, i++, &(uint8_t){40})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Right_Paren() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Right Paren"), 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_character_value(&test, result, i++, &(uint8_t){41})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Left_Bracket() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Left Bracket"), 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_character_value(&test, result, i++, &(uint8_t){91})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Right_Bracket() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Right Bracket"), 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_character_value(&test, result, i++, &(uint8_t){93})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Left_Brace() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Left Brace"), 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_character_value(&test, result, i++, &(uint8_t){123})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Right_Brace() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Right Brace"), 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_character_value(&test, result, i++, &(uint8_t){125})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Escape_Single_quote() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Escape Single quote"), 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_character_value(&test, result, i++, &(uint8_t){39})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Escape_Tab() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Escape Tab"), SLS_STR("'\\t'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){9})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Escape_Carriage_return() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Escape Carriage return"), SLS_STR("'\\r'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){13})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Escape_Backslash() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Escape Backslash"), 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_character_value(&test, result, i++, &(uint8_t){92})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Escape_Newline() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Escape Newline"), SLS_STR("'\\n'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){10})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Escape_Null_character() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Escape Null character"), SLS_STR("'\\0'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){0})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Hex_Lowercase_A() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Hex Lowercase A"), SLS_STR("'\\x61'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){97})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Hex_Uppercase_A() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Hex Uppercase A"), SLS_STR("'\\x41'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){65})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Hex_Space() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Hex Space"), SLS_STR("'\\x20'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){32})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Hex_Tab() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Hex Tab"), SLS_STR("'\\x09'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){9})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Hex_Newline() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Hex Newline"), SLS_STR("'\\x0A'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){10})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Hex_Max_ASCII() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Hex Max ASCII"), SLS_STR("'\\x7F'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){127})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_With_Leading_Whitespace() {
|
|
LexerTest test = start_up_test(SLS_STR("Char With Leading Whitespace"), SLS_STR(" 'A'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){65})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_With_Trailing_Whitespace() {
|
|
LexerTest test = start_up_test(SLS_STR("Char With Trailing Whitespace"), SLS_STR("'A' "));
|
|
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_character_value(&test, result, i++, &(uint8_t){65})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_With_Both_Whitespace() {
|
|
LexerTest test = start_up_test(SLS_STR("Char With Both Whitespace"), SLS_STR(" 'A' "));
|
|
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_character_value(&test, result, i++, &(uint8_t){65})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Tab_Before() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Tab Before"), SLS_STR("\t'B'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){66})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Newline_Before() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Newline Before"), SLS_STR("\n'C'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){67})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Empty_Literal() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Empty Literal"), 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_for_error(&test, result, i++, SLS_STR("Invalid character literal: empty character literal."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Multiple_Characters() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Multiple Characters"), SLS_STR("'AB'"));
|
|
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_for_error(&test, result, i++, SLS_STR("Invalid character literal: unexpected 'B' in character."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Unclosed_Quote() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Unclosed Quote"), SLS_STR("'A"));
|
|
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_for_error(&test, result, i++, SLS_STR("Invalid character literal: unclosed character literal."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Unescaped_Newline() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Unescaped Newline"), SLS_STR("'\n'"));
|
|
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_for_error(&test, result, i++, SLS_STR("Invalid character literal: unclosed character literal."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Invalid_Escape() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Invalid Escape"), SLS_STR("'\\q'"));
|
|
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_for_error(&test, result, i++, SLS_STR("Invalid character literal: unknown escape sequence '\\q'."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Hex_Escape_Too_Short() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Hex Escape Too Short"), SLS_STR("'\\x4'"));
|
|
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_for_error(&test, result, i++, SLS_STR("Invalid character literal: hexadecimal escape must have exactly 2 digits."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Hex_Escape_Too_Long() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Hex Escape Too Long"), SLS_STR("'\\x414'"));
|
|
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_for_error(&test, result, i++, SLS_STR("Invalid character literal: hexadecimal escape must have exactly 2 digits."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Hex_Invalid_Digit() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Hex Invalid Digit"), SLS_STR("'\\xGG'"));
|
|
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_for_error(&test, result, i++, SLS_STR("Invalid character literal: invalid hexadecimal digit 'G'."))) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_ASCII_Control_SOH() {
|
|
LexerTest test = start_up_test(SLS_STR("Char ASCII Control SOH"), SLS_STR("'\\x01'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){1})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_ASCII_Control_BEL() {
|
|
LexerTest test = start_up_test(SLS_STR("Char ASCII Control BEL"), SLS_STR("'\\x07'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){7})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_ASCII_Control_ESC() {
|
|
LexerTest test = start_up_test(SLS_STR("Char ASCII Control ESC"), SLS_STR("'\\x1B'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){27})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_ASCII_Control_DEL() {
|
|
LexerTest test = start_up_test(SLS_STR("Char ASCII Control DEL"), SLS_STR("'\\x7F'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){127})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Extended_ASCII_Lower() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Extended ASCII Lower"), SLS_STR("'\\x80'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){128})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Extended_ASCII_Upper() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Extended ASCII Upper"), SLS_STR("'\\xFF'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){255})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Hex_Lowercase_x() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Hex Lowercase x"), SLS_STR("'\\x41'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){65})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Hex_Digits_Uppercase() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Hex Digits Uppercase"), SLS_STR("'\\xFF'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){255})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Hex_Digits_Lowercase() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Hex Digits Lowercase"), SLS_STR("'\\xff'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){255})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
static TestResult test_Char_Hex_Digits_Mixed() {
|
|
LexerTest test = start_up_test(SLS_STR("Char Hex Digits Mixed"), SLS_STR("'\\xAb'"));
|
|
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_character_value(&test, result, i++, &(uint8_t){171})) return test.result;
|
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
return pass_test(&test, result);
|
|
}
|
|
|
|
TestsReport run_lexer_tests() {
|
|
TestsReport test_report = (TestsReport) {
|
|
.section = SLS_STR("lexer_tests"),
|
|
.count = NUM_OF_TESTS,
|
|
.tests = (TestResult *)malloc(sizeof(TestResult) * NUM_OF_TESTS),
|
|
};
|
|
|
|
size_t i = 0;
|
|
|
|
test_report.tests[i++] = test_Empty_Statement();
|
|
test_report.tests[i++] = test_Integer_Default_Decimal_0();
|
|
test_report.tests[i++] = test_Integer_Default_Decimal_1();
|
|
test_report.tests[i++] = test_Integer_Default_Decimal_42();
|
|
test_report.tests[i++] = test_Integer_Default_Decimal_Leading_Zeros();
|
|
test_report.tests[i++] = test_Integer_Default_Hex_0xFF();
|
|
test_report.tests[i++] = test_Integer_Default_Hex_0xdeadbeef();
|
|
test_report.tests[i++] = test_Integer_Default_Hex_Max();
|
|
test_report.tests[i++] = test_Integer_Default_Binary_0b1010();
|
|
test_report.tests[i++] = test_Integer_Default_Binary_All_Ones();
|
|
test_report.tests[i++] = test_Integer_Default_Octal_0o755();
|
|
test_report.tests[i++] = test_Integer_Default_Octal_Max_Three_Digits();
|
|
test_report.tests[i++] = test_Integer_Default_Decimal_Max_i64();
|
|
test_report.tests[i++] = test_Integer_Default_Decimal_Min_i64();
|
|
test_report.tests[i++] = test_Integer_Default_Decimal_with_Underscore();
|
|
test_report.tests[i++] = test_Integer_Default_Underscore_End();
|
|
test_report.tests[i++] = test_Integer_Default_Underscore_Double();
|
|
test_report.tests[i++] = test_Integer_Default_Whitespace();
|
|
test_report.tests[i++] = test_Integer_Default_Hex_Zero();
|
|
test_report.tests[i++] = test_Integer_Default_Binary_Zero();
|
|
test_report.tests[i++] = test_Integer_Default_Octal_Zero();
|
|
test_report.tests[i++] = test_Integer_Default_Decimal_with_Commas_Invalid();
|
|
test_report.tests[i++] = test_Integer_Default_Invalid_Characters();
|
|
test_report.tests[i++] = test_Integer_Default_Invalid_Prefix();
|
|
test_report.tests[i++] = test_Integer_i8_Decimal_Positive();
|
|
test_report.tests[i++] = test_Integer_i8_Zero();
|
|
test_report.tests[i++] = test_Integer_i8_Decimal_Negative();
|
|
test_report.tests[i++] = test_Integer_i8_Hex();
|
|
test_report.tests[i++] = test_Integer_i8_Binary();
|
|
test_report.tests[i++] = test_Integer_i8_Octal();
|
|
test_report.tests[i++] = test_Integer_i8_Max_Value();
|
|
test_report.tests[i++] = test_Integer_i8_Min_Value();
|
|
test_report.tests[i++] = test_Integer_i8_Overflow();
|
|
test_report.tests[i++] = test_Integer_i8_Underflow();
|
|
test_report.tests[i++] = test_Integer_i8_Hex_Max();
|
|
test_report.tests[i++] = test_Integer_i8_Binary_Max();
|
|
test_report.tests[i++] = test_Integer_i8_Octal_Max();
|
|
test_report.tests[i++] = test_Integer_i8_Negative_Hex();
|
|
test_report.tests[i++] = test_Integer_i16_Decimal_Positive();
|
|
test_report.tests[i++] = test_Integer_i16_Zero();
|
|
test_report.tests[i++] = test_Integer_i16_Decimal_Negative();
|
|
test_report.tests[i++] = test_Integer_i16_Hex();
|
|
test_report.tests[i++] = test_Integer_i16_Binary();
|
|
test_report.tests[i++] = test_Integer_i16_Octal();
|
|
test_report.tests[i++] = test_Integer_i16_Max_Value();
|
|
test_report.tests[i++] = test_Integer_i16_Min_Value();
|
|
test_report.tests[i++] = test_Integer_i16_Overflow();
|
|
test_report.tests[i++] = test_Integer_i16_Underflow();
|
|
test_report.tests[i++] = test_Integer_i16_Hex_Sample();
|
|
test_report.tests[i++] = test_Integer_i16_Binary_Sample();
|
|
test_report.tests[i++] = test_Integer_i16_Octal_Sample();
|
|
test_report.tests[i++] = test_Integer_i32_Decimal_Positive();
|
|
test_report.tests[i++] = test_Integer_i32_Zero();
|
|
test_report.tests[i++] = test_Integer_i32_Decimal_Negative();
|
|
test_report.tests[i++] = test_Integer_i32_Hex();
|
|
test_report.tests[i++] = test_Integer_i32_Binary();
|
|
test_report.tests[i++] = test_Integer_i32_Octal();
|
|
test_report.tests[i++] = test_Integer_i32_Max_Value();
|
|
test_report.tests[i++] = test_Integer_i32_Min_Value();
|
|
test_report.tests[i++] = test_Integer_i32_Overflow();
|
|
test_report.tests[i++] = test_Integer_i32_Underflow();
|
|
test_report.tests[i++] = test_Integer_i32_With_Underscores();
|
|
test_report.tests[i++] = test_Integer_i32_Hex_Sample();
|
|
test_report.tests[i++] = test_Integer_i32_Binary_Sample();
|
|
test_report.tests[i++] = test_Integer_i64_Decimal_Positive();
|
|
test_report.tests[i++] = test_Integer_i64_Zero();
|
|
test_report.tests[i++] = test_Integer_i64_Decimal_Negative();
|
|
test_report.tests[i++] = test_Integer_i64_Hex();
|
|
test_report.tests[i++] = test_Integer_i64_Binary();
|
|
test_report.tests[i++] = test_Integer_i64_Octal();
|
|
test_report.tests[i++] = test_Integer_i64_Max_Value();
|
|
test_report.tests[i++] = test_Integer_i64_Min_Value();
|
|
test_report.tests[i++] = test_Integer_i64_Overflow();
|
|
test_report.tests[i++] = test_Integer_i64_Underflow();
|
|
test_report.tests[i++] = test_Integer_i64_With_Underscores();
|
|
test_report.tests[i++] = test_Integer_i64_Decimal_Positive_42();
|
|
test_report.tests[i++] = test_Integer_i64_Hex_0xFF();
|
|
test_report.tests[i++] = test_Integer_i64_Binary_0b1010();
|
|
test_report.tests[i++] = test_Integer_i64_Octal_0o755();
|
|
test_report.tests[i++] = test_Integer_u8_Decimal_Positive();
|
|
test_report.tests[i++] = test_Integer_u8_Zero();
|
|
test_report.tests[i++] = test_Integer_u8_Hex();
|
|
test_report.tests[i++] = test_Integer_u8_Binary();
|
|
test_report.tests[i++] = test_Integer_u8_Octal();
|
|
test_report.tests[i++] = test_Integer_u8_Max_Value();
|
|
test_report.tests[i++] = test_Integer_u8_Min_Value();
|
|
test_report.tests[i++] = test_Integer_u8_Overflow();
|
|
test_report.tests[i++] = test_Integer_u8_Underflow();
|
|
test_report.tests[i++] = test_Integer_u8_Hex_Max();
|
|
test_report.tests[i++] = test_Integer_u8_Binary_Max();
|
|
test_report.tests[i++] = test_Integer_u8_Octal_Max();
|
|
test_report.tests[i++] = test_Integer_u16_Decimal_Positive();
|
|
test_report.tests[i++] = test_Integer_u16_Zero();
|
|
test_report.tests[i++] = test_Integer_u16_Hex();
|
|
test_report.tests[i++] = test_Integer_u16_Binary();
|
|
test_report.tests[i++] = test_Integer_u16_Octal();
|
|
test_report.tests[i++] = test_Integer_u16_Max_Value();
|
|
test_report.tests[i++] = test_Integer_u16_Min_Value();
|
|
test_report.tests[i++] = test_Integer_u16_Overflow();
|
|
test_report.tests[i++] = test_Integer_u16_Underflow();
|
|
test_report.tests[i++] = test_Integer_u16_Hex_Max();
|
|
test_report.tests[i++] = test_Integer_u16_Binary_Max();
|
|
test_report.tests[i++] = test_Integer_u16_Octal_Max();
|
|
test_report.tests[i++] = test_Integer_u16_Decimal_Mid();
|
|
test_report.tests[i++] = test_Integer_u32_Decimal_Positive();
|
|
test_report.tests[i++] = test_Integer_u32_Zero();
|
|
test_report.tests[i++] = test_Integer_u32_Hex();
|
|
test_report.tests[i++] = test_Integer_u32_Binary();
|
|
test_report.tests[i++] = test_Integer_u32_Octal();
|
|
test_report.tests[i++] = test_Integer_u32_Max_Value();
|
|
test_report.tests[i++] = test_Integer_u32_Min_Value();
|
|
test_report.tests[i++] = test_Integer_u32_Overflow();
|
|
test_report.tests[i++] = test_Integer_u32_Underflow();
|
|
test_report.tests[i++] = test_Integer_u32_With_Underscores();
|
|
test_report.tests[i++] = test_Integer_u32_Hex_Max();
|
|
test_report.tests[i++] = test_Integer_u32_Binary_Sample();
|
|
test_report.tests[i++] = test_Integer_u32_Octal_Max();
|
|
test_report.tests[i++] = test_Integer_u32_Decimal_Mid();
|
|
test_report.tests[i++] = test_Integer_u64_Decimal_Positive();
|
|
test_report.tests[i++] = test_Integer_u64_Zero();
|
|
test_report.tests[i++] = test_Integer_u64_Hex();
|
|
test_report.tests[i++] = test_Integer_u64_Binary();
|
|
test_report.tests[i++] = test_Integer_u64_Octal();
|
|
test_report.tests[i++] = test_Integer_u64_Max_Value();
|
|
test_report.tests[i++] = test_Integer_u64_Min_Value();
|
|
test_report.tests[i++] = test_Integer_u64_Overflow();
|
|
test_report.tests[i++] = test_Integer_u64_Underflow();
|
|
test_report.tests[i++] = test_Integer_u64_With_Underscores();
|
|
test_report.tests[i++] = test_Integer_u64_Hex_Max();
|
|
test_report.tests[i++] = test_Integer_u64_Binary_Sample();
|
|
test_report.tests[i++] = test_Integer_u64_Octal_Sample();
|
|
test_report.tests[i++] = test_Integer_u64_Decimal();
|
|
test_report.tests[i++] = test_Integer_Hex_With_Underscores();
|
|
test_report.tests[i++] = test_Integer_Binary_With_Underscores();
|
|
test_report.tests[i++] = test_Integer_Octal_With_Underscores();
|
|
test_report.tests[i++] = test_Float_Default_Simple();
|
|
test_report.tests[i++] = test_Float_Default_Zero();
|
|
test_report.tests[i++] = test_Float_Default_Negative();
|
|
test_report.tests[i++] = test_Float_Default_One();
|
|
test_report.tests[i++] = test_Float_f32_Simple();
|
|
test_report.tests[i++] = test_Float_f64_Simple();
|
|
test_report.tests[i++] = test_Float_Default_Leading_Zeros();
|
|
test_report.tests[i++] = test_Float_Default_Leading_Zero_Decimal();
|
|
test_report.tests[i++] = test_Float_Default_Trailing_Zeros();
|
|
test_report.tests[i++] = test_Float_Default_No_Leading_Digit();
|
|
test_report.tests[i++] = test_Float_Default_No_Leading_Digit_Negative();
|
|
test_report.tests[i++] = test_Float_Default_No_Trailing_Digits();
|
|
test_report.tests[i++] = test_Float_Default_No_Trailing_Digits_Negative();
|
|
test_report.tests[i++] = test_Float_Default_Very_Small();
|
|
test_report.tests[i++] = test_Float_Default_Very_Large();
|
|
test_report.tests[i++] = test_Float_Default_Underscore_Integer_Part();
|
|
test_report.tests[i++] = test_Float_Default_Underscore_Decimal_Part();
|
|
test_report.tests[i++] = test_Float_Default_Underscore_Both_Parts();
|
|
test_report.tests[i++] = test_Float_Default_Underscore_Trailing();
|
|
test_report.tests[i++] = test_Float_Default_Underscore_Double();
|
|
test_report.tests[i++] = test_Float_f32_With_Underscores();
|
|
test_report.tests[i++] = test_Float_f32_Precision_Limit();
|
|
test_report.tests[i++] = test_Float_f32_High_Precision();
|
|
test_report.tests[i++] = test_Float_f64_Precision_Limit();
|
|
test_report.tests[i++] = test_Float_f64_High_Precision();
|
|
test_report.tests[i++] = test_Float_f64_Close_Numbers_1();
|
|
test_report.tests[i++] = test_Float_f64_Close_Numbers_2();
|
|
test_report.tests[i++] = test_Float_Invalid_Multiple_Decimal_Points();
|
|
test_report.tests[i++] = test_Float_Invalid_Characters();
|
|
test_report.tests[i++] = test_Float_Invalid_Type_Annotation();
|
|
test_report.tests[i++] = test_Float_Invalid_Type_Name();
|
|
test_report.tests[i++] = test_Float_Invalid_Comma_Separator();
|
|
test_report.tests[i++] = test_Float_Default_Leading_Whitespace();
|
|
test_report.tests[i++] = test_Float_Default_Trailing_Whitespace();
|
|
test_report.tests[i++] = test_Float_Default_Both_Whitespace();
|
|
test_report.tests[i++] = test_Float_f32_With_Whitespace();
|
|
test_report.tests[i++] = test_Float_Default_Pi_Approximate();
|
|
test_report.tests[i++] = test_Float_f32_Pi_Approximate();
|
|
test_report.tests[i++] = test_Float_Default_Euler_Approximate();
|
|
test_report.tests[i++] = test_Float_f32_Euler_Approximate();
|
|
test_report.tests[i++] = test_Float_Default_Golden_Ratio();
|
|
test_report.tests[i++] = test_Float_Default_Sqrt2();
|
|
test_report.tests[i++] = test_Float_Default_Positive_Zero();
|
|
test_report.tests[i++] = test_Float_Default_Negative_Zero();
|
|
test_report.tests[i++] = test_Float_f32_Positive_Zero();
|
|
test_report.tests[i++] = test_Float_f32_Negative_Zero();
|
|
test_report.tests[i++] = test_Char_Simple_Letter_A();
|
|
test_report.tests[i++] = test_Char_Simple_Letter_a();
|
|
test_report.tests[i++] = test_Char_Simple_Letter_Z();
|
|
test_report.tests[i++] = test_Char_Simple_Letter_z();
|
|
test_report.tests[i++] = test_Char_Digit_0();
|
|
test_report.tests[i++] = test_Char_Digit_5();
|
|
test_report.tests[i++] = test_Char_Digit_9();
|
|
test_report.tests[i++] = test_Char_Space();
|
|
test_report.tests[i++] = test_Char_Exclamation();
|
|
test_report.tests[i++] = test_Char_Question_Mark();
|
|
test_report.tests[i++] = test_Char_Period();
|
|
test_report.tests[i++] = test_Char_Comma();
|
|
test_report.tests[i++] = test_Char_Semicolon();
|
|
test_report.tests[i++] = test_Char_Colon();
|
|
test_report.tests[i++] = test_Char_Plus();
|
|
test_report.tests[i++] = test_Char_Minus();
|
|
test_report.tests[i++] = test_Char_Asterisk();
|
|
test_report.tests[i++] = test_Char_Slash();
|
|
test_report.tests[i++] = test_Char_Equals();
|
|
test_report.tests[i++] = test_Char_Less_Than();
|
|
test_report.tests[i++] = test_Char_Greater_Than();
|
|
test_report.tests[i++] = test_Char_Left_Paren();
|
|
test_report.tests[i++] = test_Char_Right_Paren();
|
|
test_report.tests[i++] = test_Char_Left_Bracket();
|
|
test_report.tests[i++] = test_Char_Right_Bracket();
|
|
test_report.tests[i++] = test_Char_Left_Brace();
|
|
test_report.tests[i++] = test_Char_Right_Brace();
|
|
test_report.tests[i++] = test_Char_Escape_Single_quote();
|
|
test_report.tests[i++] = test_Char_Escape_Tab();
|
|
test_report.tests[i++] = test_Char_Escape_Carriage_return();
|
|
test_report.tests[i++] = test_Char_Escape_Backslash();
|
|
test_report.tests[i++] = test_Char_Escape_Newline();
|
|
test_report.tests[i++] = test_Char_Escape_Null_character();
|
|
test_report.tests[i++] = test_Char_Hex_Lowercase_A();
|
|
test_report.tests[i++] = test_Char_Hex_Uppercase_A();
|
|
test_report.tests[i++] = test_Char_Hex_Space();
|
|
test_report.tests[i++] = test_Char_Hex_Tab();
|
|
test_report.tests[i++] = test_Char_Hex_Newline();
|
|
test_report.tests[i++] = test_Char_Hex_Max_ASCII();
|
|
test_report.tests[i++] = test_Char_With_Leading_Whitespace();
|
|
test_report.tests[i++] = test_Char_With_Trailing_Whitespace();
|
|
test_report.tests[i++] = test_Char_With_Both_Whitespace();
|
|
test_report.tests[i++] = test_Char_Tab_Before();
|
|
test_report.tests[i++] = test_Char_Newline_Before();
|
|
test_report.tests[i++] = test_Char_Empty_Literal();
|
|
test_report.tests[i++] = test_Char_Multiple_Characters();
|
|
test_report.tests[i++] = test_Char_Unclosed_Quote();
|
|
test_report.tests[i++] = test_Char_Unescaped_Newline();
|
|
test_report.tests[i++] = test_Char_Invalid_Escape();
|
|
test_report.tests[i++] = test_Char_Hex_Escape_Too_Short();
|
|
test_report.tests[i++] = test_Char_Hex_Escape_Too_Long();
|
|
test_report.tests[i++] = test_Char_Hex_Invalid_Digit();
|
|
test_report.tests[i++] = test_Char_ASCII_Control_SOH();
|
|
test_report.tests[i++] = test_Char_ASCII_Control_BEL();
|
|
test_report.tests[i++] = test_Char_ASCII_Control_ESC();
|
|
test_report.tests[i++] = test_Char_ASCII_Control_DEL();
|
|
test_report.tests[i++] = test_Char_Extended_ASCII_Lower();
|
|
test_report.tests[i++] = test_Char_Extended_ASCII_Upper();
|
|
test_report.tests[i++] = test_Char_Hex_Lowercase_x();
|
|
test_report.tests[i++] = test_Char_Hex_Digits_Uppercase();
|
|
test_report.tests[i++] = test_Char_Hex_Digits_Lowercase();
|
|
test_report.tests[i++] = test_Char_Hex_Digits_Mixed();
|
|
|
|
return test_report;
|
|
}
|