diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/CMakeLists.txt | 18 | ||||
-rw-r--r-- | test/bmMenuNew.c | 29 |
2 files changed, 45 insertions, 2 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8da6d4a..f9d13a5 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,5 +1,19 @@ -INCLUDE(CTest) +SET(TESTS + "bmMenuNew" + ) -# TODO: write test CMakeLists +INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/../lib") +FOREACH (test ${TESTS}) + ADD_EXECUTABLE(${test}_test ${test}.c) + TARGET_LINK_LIBRARIES(${test}_test bemenu) + + IF (WIN32) + ADD_TEST(${test}_test ${test}_test.exe) + ELSE () + ADD_TEST(${test}_test ${test}_test) + ENDIF () +ENDFOREACH (test) + +MESSAGE("-!- Use 'make test' to run tests") # vim: set ts=8 sw=4 tw=0 : diff --git a/test/bmMenuNew.c b/test/bmMenuNew.c new file mode 100644 index 0000000..ebab314 --- /dev/null +++ b/test/bmMenuNew.c @@ -0,0 +1,29 @@ +#include <stdlib.h> +#include <unistd.h> +#include <stdio.h> +#include <assert.h> +#include <bemenu.h> + +int main(int argc, char **argv) +{ + (void)argc, (void)argv; + + // TEST: Instance bmMenu with all possible draw modes. + { + bmDrawMode i; + for (i = 0; i < BM_DRAW_MODE_LAST; ++i) { + if (i == BM_DRAW_MODE_CURSES && !isatty(STDIN_FILENO)) { + printf("Skipping test for mode BM_DRAW_MODE_CURSES, as not running on terminal.\n"); + continue; + } + bmMenu *menu = bmMenuNew(i); + assert(menu); + bmMenuRender(menu); + bmMenuFree(menu); + } + } + + return EXIT_SUCCESS; +} + +/* vim: set ts=8 sw=4 tw=0 :*/ |