Files
Toy/test/test_literal.c
Kayne Ruse 2e2bee4fa3 Renemed all variables to fit into a namespace
Basically, all Toy varaibles, functions, etc. are prepended with "Toy_",
and macros are prepended with "TOY_". This is to reduce namespace
pollution, which was an issue pointed out to be - blame @GyroVorbis.

I've also bumped the minor version number - theoretically I should bump
the major number, but I'm not quite ready for 1.0 yet.
2023-01-25 12:55:55 +00:00

51 lines
1016 B
C

#include "toy_literal.h"
#include "toy_memory.h"
#include "toy_console_colors.h"
#include <stdio.h>
int main() {
{
//test a single null literal
Toy_Literal literal = TOY_TO_NULL_LITERAL;
if (!TOY_IS_NULL(literal)) {
fprintf(stderr, TOY_CC_ERROR "ERROR: null literal failed\n" TOY_CC_RESET);
return -1;
}
}
{
//test boolean literals
Toy_Literal t = TOY_TO_BOOLEAN_LITERAL(true);
Toy_Literal f = TOY_TO_BOOLEAN_LITERAL(false);
if (!TOY_IS_TRUTHY(t) || TOY_IS_TRUTHY(f)) {
fprintf(stderr, TOY_CC_ERROR "ERROR: boolean literal failed\n" TOY_CC_RESET);
return -1;
}
}
{
//test string literals
char* buffer = "Hello world";
Toy_Literal literal = TOY_TO_STRING_LITERAL(Toy_createRefString(buffer));
Toy_freeLiteral(literal);
}
{
//test identifier literals
char buffer[] = "Hello world";
Toy_Literal literal = TOY_TO_IDENTIFIER_LITERAL(Toy_createRefString(buffer));
Toy_freeLiteral(literal);
}
printf(TOY_CC_NOTICE "All good\n" TOY_CC_RESET);
return 0;
}