diff --git a/compiler/CMakeLists.txt b/compiler/CMakeLists.txt index 69a56fc4f..19e10e494 100644 --- a/compiler/CMakeLists.txt +++ b/compiler/CMakeLists.txt @@ -58,11 +58,17 @@ else() message(STATUS "ZamaLang Python bindings are disabled.") endif() +#------------------------------------------------------------------------------- +# Unit tests +#------------------------------------------------------------------------------- + +option(ZAMALANG_UNIT_TESTS "Enables the build of unittests" ON) add_subdirectory(include) add_subdirectory(lib) add_subdirectory(src) +add_subdirectory(tests) if (ZAMALANG_BINDINGS_PYTHON_ENABLED) add_subdirectory(python) diff --git a/compiler/tests/CMakeLists.txt b/compiler/tests/CMakeLists.txt new file mode 100644 index 000000000..7266ea592 --- /dev/null +++ b/compiler/tests/CMakeLists.txt @@ -0,0 +1,3 @@ +if (ZAMALANG_UNIT_TESTS) + add_subdirectory(unittest) +endif() \ No newline at end of file diff --git a/compiler/tests/unittest/CMakeLists.txt b/compiler/tests/unittest/CMakeLists.txt new file mode 100644 index 000000000..2aeff5bad --- /dev/null +++ b/compiler/tests/unittest/CMakeLists.txt @@ -0,0 +1,14 @@ +enable_testing() + +add_executable( + hello_test + hello_test.cc +) +target_link_libraries( + hello_test + gtest_main +) + +include(GoogleTest) +gtest_discover_tests(hello_test) + diff --git a/compiler/tests/unittest/hello_test.cc b/compiler/tests/unittest/hello_test.cc new file mode 100644 index 000000000..5a57e138f --- /dev/null +++ b/compiler/tests/unittest/hello_test.cc @@ -0,0 +1,9 @@ +#include + +// Demonstrate some basic assertions. +TEST(HelloTest, BasicAssertions) { + // Expect two strings not to be equal. + EXPECT_STRNE("hello", "world"); + // Expect equality. + EXPECT_EQ(7 * 6, 42); +}