summaryrefslogtreecommitdiff
path: root/source/test
diff options
context:
space:
mode:
Diffstat (limited to 'source/test')
-rw-r--r--source/test/CMakeLists.txt1
-rw-r--r--source/test/programs/CMakeLists.txt21
-rw-r--r--source/test/programs/too_many_assertions.c12
-rw-r--r--source/test/programs/too_many_tests.c13
-rw-r--r--source/test/unittests/CMakeLists.txt4
-rw-r--r--source/test/unittests/test_duration.test.c18
6 files changed, 67 insertions, 2 deletions
diff --git a/source/test/CMakeLists.txt b/source/test/CMakeLists.txt
index 740981e..4435be1 100644
--- a/source/test/CMakeLists.txt
+++ b/source/test/CMakeLists.txt
@@ -1 +1,2 @@
add_subdirectory(unittests)
+add_subdirectory(programs)
diff --git a/source/test/programs/CMakeLists.txt b/source/test/programs/CMakeLists.txt
new file mode 100644
index 0000000..4fd3660
--- /dev/null
+++ b/source/test/programs/CMakeLists.txt
@@ -0,0 +1,21 @@
+if(KIT_ENABLE_TESTING)
+ add_executable(too_many_tests too_many_tests.c)
+ target_link_libraries(too_many_tests ${KIT_TEST_LIBRARY})
+ add_test(
+ NAME too_many_tests_test
+ COMMAND too_many_tests)
+ set_tests_properties(
+ too_many_tests_test
+ PROPERTIES
+ TIMEOUT "30")
+
+ add_executable(too_many_assertions too_many_assertions.c)
+ target_link_libraries(too_many_assertions ${KIT_TEST_LIBRARY})
+ add_test(
+ NAME too_many_assertions_test
+ COMMAND too_many_assertions)
+ set_tests_properties(
+ too_many_assertions_test
+ PROPERTIES
+ TIMEOUT "30")
+endif()
diff --git a/source/test/programs/too_many_assertions.c b/source/test/programs/too_many_assertions.c
new file mode 100644
index 0000000..846970f
--- /dev/null
+++ b/source/test/programs/too_many_assertions.c
@@ -0,0 +1,12 @@
+#include "../../kit_test/test.h"
+
+TEST("foo") {
+ for (int i = 0; i <= KIT_TEST_ASSERTIONS_LIMIT; i++) REQUIRE(1);
+}
+
+int main(int argc, char **argv) {
+ if (run_tests(argc, argv) != 1)
+ return 1;
+
+ return 0;
+}
diff --git a/source/test/programs/too_many_tests.c b/source/test/programs/too_many_tests.c
new file mode 100644
index 0000000..9893e84
--- /dev/null
+++ b/source/test/programs/too_many_tests.c
@@ -0,0 +1,13 @@
+#include "../../kit_test/test.h"
+
+void bar(int index, kit_test_report_fn report) { }
+
+int main(int argc, char **argv) {
+ for (int i = 0; i <= KIT_TESTS_SIZE_LIMIT; i++)
+ test_register("foo", bar);
+
+ if (run_tests(argc, argv) != 1)
+ return 1;
+
+ return 0;
+}
diff --git a/source/test/unittests/CMakeLists.txt b/source/test/unittests/CMakeLists.txt
index 37f7dbb..674f442 100644
--- a/source/test/unittests/CMakeLists.txt
+++ b/source/test/unittests/CMakeLists.txt
@@ -1,6 +1,6 @@
target_sources(
${KIT_TEST_SUITE}
PRIVATE
- async_function.test.c main.test.c string_ref.test.c
- array_ref.test.c input_stream.test.c lower_bound.test.c
+ async_function.test.c test_duration.test.c main.test.c
+ string_ref.test.c array_ref.test.c input_stream.test.c lower_bound.test.c
input_buffer.test.c dynamic_array.test.c)
diff --git a/source/test/unittests/test_duration.test.c b/source/test/unittests/test_duration.test.c
new file mode 100644
index 0000000..6de6c2e
--- /dev/null
+++ b/source/test/unittests/test_duration.test.c
@@ -0,0 +1,18 @@
+#define KIT_TEST_FILE test_duration
+#include "../../kit_test/test.h"
+
+#ifdef _WIN32
+# include <synchapi.h>
+static void kit_sleep(int ms) {
+ Sleep(ms);
+}
+#else
+# include <unistd.h>
+static void kit_sleep(int ms) {
+ usleep(ms * 1000);
+}
+#endif
+
+TEST("test duration") {
+ kit_sleep(100);
+}