Set up test framework with demo test

This commit is contained in:
Daniel Thorpe
2024-06-20 15:56:30 +01:00
parent 9dd0c42ca7
commit 2a8be1c462
5 changed files with 39 additions and 4 deletions

View File

@@ -1,6 +1,9 @@
add_library(test_lib
"test_io.c"
)
target_include_directories(test_lib PUBLIC "include")
add_library(test_lib "test_io.c")
set_property(TARGET test_lib PROPERTY C_STANDARD 11)
target_include_directories(test_lib PUBLIC "include")
target_link_libraries(test_lib gemhadar_lib)
add_executable(url_tests "url_tests.c")
set_property(TARGET test_lib PROPERTY C_STANDARD 11)
target_link_libraries(url_tests gemhadar_lib test_lib)
add_test(NAME "URL tests" COMMAND url_tests)

19
test/url_tests.c Normal file
View File

@@ -0,0 +1,19 @@
#include "greatest.h"
#include "url.h"
TEST foo_returns_42(void)
{
ASSERT_EQ(42, foo());
PASS();
}
GREATEST_MAIN_DEFS();
int main(int argc, char *argv[])
{
GREATEST_MAIN_BEGIN();
RUN_TEST(foo_returns_42);
GREATEST_MAIN_END();
}