Tougher tests, and test the tests.
This commit is contained in:
parent
2b8fa6047d
commit
498a78cd9f
@ -5,7 +5,7 @@
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#define TT_FAIL(error, ...) dprintf(tt_pipe[1], "\"%s\" Line %d: %s >> " error "\n", tt_current->filename, __LINE__, tt_current->name, __VA_ARGS__);
|
||||
#define TT_FAIL(error, ...) dprintf(tt_pipe[1], "\"%s\" Line %d: %s >> " error "\n", tt_current->filename, __LINE__, tt_current->name, ##__VA_ARGS__);
|
||||
|
||||
|
||||
#define ASSERT_EQUAL(type, pf, lhs, rhs) do { \
|
||||
@ -33,7 +33,7 @@
|
||||
char *tt_rhs = (char *)(rhs); \
|
||||
if(!tt_lhs || !tt_rhs) \
|
||||
{ \
|
||||
TT_FAIL("Expected string, got null pointer", 0); \
|
||||
TT_FAIL("Expected string, got null pointer"); \
|
||||
return 1; \
|
||||
} \
|
||||
size_t tt_n = (size_t)(n); \
|
||||
@ -90,7 +90,7 @@ int tt_verbose = 0;
|
||||
int tt_silent = 0;
|
||||
struct tt_test *tt_tests;
|
||||
struct tt_test *tt_current;
|
||||
int tt_max_name_len = 0;
|
||||
unsigned int tt_max_name_len = 0;
|
||||
int tt_test_count = 0;
|
||||
|
||||
void tt_register(char *name, int (*fn)(void), char *filename)
|
||||
|
48
toolchain/ttest.tt
Normal file
48
toolchain/ttest.tt
Normal file
@ -0,0 +1,48 @@
|
||||
// vim: ft=c
|
||||
#include <ttest.h>
|
||||
|
||||
|
||||
TEST(two_equal_ints)
|
||||
{
|
||||
ASSERT_EQ_INT(1, 1);
|
||||
}
|
||||
TEST(FAIL_two_equal_ints)
|
||||
{
|
||||
ASSERT_EQ_INT(2, 3);
|
||||
}
|
||||
|
||||
TEST(two_different_ints)
|
||||
{
|
||||
ASSERT_NEQ_INT(2, 3);
|
||||
}
|
||||
TEST(FAIL_two_different_ints)
|
||||
{
|
||||
ASSERT_NEQ_INT(1, 1);
|
||||
}
|
||||
|
||||
TEST(two_equal_chars)
|
||||
{
|
||||
ASSERT_EQ_CHR('a', 'a');
|
||||
}
|
||||
TEST(FAIL_two_equal_chars)
|
||||
{
|
||||
ASSERT_EQ_CHR('b', 'c');
|
||||
}
|
||||
|
||||
TEST(two_different_chars)
|
||||
{
|
||||
ASSERT_NEQ_CHR('b', 'c');
|
||||
}
|
||||
TEST(FAIL_two_different_chars)
|
||||
{
|
||||
ASSERT_NEQ_CHR('a', 'a');
|
||||
}
|
||||
|
||||
TEST(two_equal_strings)
|
||||
{
|
||||
ASSERT_EQ_STR("Hello", "Hello", 5);
|
||||
}
|
||||
TEST(FAIL_two_equal_strings)
|
||||
{
|
||||
ASSERT_EQ_STR("Hello", "World", 5);
|
||||
}
|
4
ttest
4
ttest
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
dirs=src/kernel
|
||||
dirs="toolchain src/kernel"
|
||||
|
||||
main()
|
||||
{
|
||||
@ -10,7 +10,7 @@ main()
|
||||
for suite in $files; do
|
||||
|
||||
test_exec="${suite}est"
|
||||
compiler_output=`cc -x c $suite -o $test_exec -I $dir/include -I toolchain -DTTEST 2>&1`
|
||||
compiler_output=`cc -x c $suite -o $test_exec -Wall -Wextra -Werror -I $dir/include -I toolchain -DTTEST 2>&1`
|
||||
compiler_status=$?
|
||||
|
||||
if [[ "$compiler_status" -eq "0" ]]; then
|
||||
|
Loading…
x
Reference in New Issue
Block a user