summaryrefslogtreecommitdiff
path: root/asl
diff options
context:
space:
mode:
authorSteven Le Rouzic <steven.lerouzic@gmail.com>2024-10-16 22:54:34 +0200
committerSteven Le Rouzic <steven.lerouzic@gmail.com>2024-12-20 15:35:58 +0100
commit8c95db33be58a545dd2e030428bded0bd958c4b6 (patch)
treeb78809fae2cec5eb2b9513b4960bfbbd697f3871 /asl
parent7193114b152d3a5b714a22f54ed89950c0ba9aba (diff)
Start work on the testing framework
Diffstat (limited to 'asl')
-rw-r--r--asl/BUILD.bazel5
-rw-r--r--asl/testing/BUILD.bazel13
-rw-r--r--asl/testing/testing.cpp14
-rw-r--r--asl/testing/testing.hpp15
-rw-r--r--asl/tests/format_tests.cpp (renamed from asl/format_tests.cpp)2
-rw-r--r--asl/tests/integers_tests.cpp (renamed from asl/integers_tests.cpp)2
-rw-r--r--asl/tests/maybe_uninit_tests.cpp (renamed from asl/maybe_uninit_tests.cpp)6
-rw-r--r--asl/tests/meta_tests.cpp (renamed from asl/meta_tests.cpp)4
-rw-r--r--asl/tests/option_tests.cpp (renamed from asl/option_tests.cpp)7
-rw-r--r--asl/tests/test_types.hpp (renamed from asl/test_types.hpp)0
-rw-r--r--asl/tests/utility_tests.cpp1
-rw-r--r--asl/utility_tests.cpp3
12 files changed, 52 insertions, 20 deletions
diff --git a/asl/BUILD.bazel b/asl/BUILD.bazel
index f0d4c27..f7dddd1 100644
--- a/asl/BUILD.bazel
+++ b/asl/BUILD.bazel
@@ -24,11 +24,12 @@ cc_library(
[cc_test(
name = "%s_tests" % name,
srcs = [
- "%s_tests.cpp" % name,
- "test_types.hpp",
+ "tests/%s_tests.cpp" % name,
+ "tests/test_types.hpp",
],
deps = [
":asl",
+ "//asl/testing",
],
) for name in [
"format",
diff --git a/asl/testing/BUILD.bazel b/asl/testing/BUILD.bazel
new file mode 100644
index 0000000..2942073
--- /dev/null
+++ b/asl/testing/BUILD.bazel
@@ -0,0 +1,13 @@
+cc_library(
+ name = "testing",
+ hdrs = [
+ "testing.hpp",
+ ],
+ srcs = [
+ "testing.cpp",
+ ],
+ deps = [
+ "//asl",
+ ],
+ visibility = ["//visibility:public"],
+)
diff --git a/asl/testing/testing.cpp b/asl/testing/testing.cpp
new file mode 100644
index 0000000..a2fe152
--- /dev/null
+++ b/asl/testing/testing.cpp
@@ -0,0 +1,14 @@
+#include "asl/testing/testing.hpp"
+
+int asl::testing::register_test(
+ const char* suite_name,
+ const char* case_name,
+ TestFunction* fn)
+{
+ return 0;
+}
+
+int main(int argc, char* argv[])
+{
+ return 0;
+}
diff --git a/asl/testing/testing.hpp b/asl/testing/testing.hpp
new file mode 100644
index 0000000..a489d61
--- /dev/null
+++ b/asl/testing/testing.hpp
@@ -0,0 +1,15 @@
+#pragma once
+
+namespace asl::testing
+{
+
+using TestFunction = void();
+int register_test(const char* suite_name, const char* case_name, TestFunction* fn);
+
+} // namespace asl::testing
+
+#define ASL_TEST(SUITE, CASE) \
+ static void asl_test_fn_##SUITE##_##CASE(); \
+ static const int asl_test_##SUITE##_##CASE = ::asl::testing::register_test( \
+ #SUITE, #CASE, asl_test_fn_##SUITE##_##CASE); \
+ void asl_test_fn_##SUITE##_##CASE()
diff --git a/asl/format_tests.cpp b/asl/tests/format_tests.cpp
index 818773b..6e2430d 100644
--- a/asl/format_tests.cpp
+++ b/asl/tests/format_tests.cpp
@@ -33,7 +33,7 @@ public:
}
};
-int main()
+int main2()
{
StringSink sink;
diff --git a/asl/integers_tests.cpp b/asl/tests/integers_tests.cpp
index 0393a3c..d15168e 100644
--- a/asl/integers_tests.cpp
+++ b/asl/tests/integers_tests.cpp
@@ -9,5 +9,3 @@ static_assert(sizeof(uint8_t) == 1);
static_assert(sizeof(uint16_t) == 2);
static_assert(sizeof(uint32_t) == 4);
static_assert(sizeof(uint64_t) == 8);
-
-int main() { return 0; }
diff --git a/asl/maybe_uninit_tests.cpp b/asl/tests/maybe_uninit_tests.cpp
index 7584eea..3f60558 100644
--- a/asl/maybe_uninit_tests.cpp
+++ b/asl/tests/maybe_uninit_tests.cpp
@@ -1,5 +1,5 @@
#include "asl/maybe_uninit.hpp"
-#include "asl/test_types.hpp"
+#include "asl/tests/test_types.hpp"
static_assert(asl::layout::of<int>() == asl::layout::of<asl::maybe_uninit<int>>());
static_assert(asl::size_of<int> == asl::size_of<asl::maybe_uninit<int>>);
@@ -8,7 +8,3 @@ static_assert(asl::align_of<int> == asl::align_of<asl::maybe_uninit<int>>);
static_assert(asl::trivially_destructible<asl::maybe_uninit<TriviallyDestructible>>);
static_assert(!asl::trivially_destructible<asl::maybe_uninit<HasDestructor>>);
-int main()
-{
- return 0;
-}
diff --git a/asl/meta_tests.cpp b/asl/tests/meta_tests.cpp
index 2bebb01..5de4f8d 100644
--- a/asl/meta_tests.cpp
+++ b/asl/tests/meta_tests.cpp
@@ -1,5 +1,5 @@
#include "asl/meta.hpp"
-#include "asl/test_types.hpp"
+#include "asl/tests/test_types.hpp"
struct Struct {};
union Union {};
@@ -168,5 +168,3 @@ static_assert(!asl::trivially_copyable<HasDestructor>);
static_assert(!asl::trivially_copyable<CopyAssignable>);
static_assert(asl::trivially_copyable<DefaultConstructible>);
static_assert(asl::trivially_copyable<TriviallyDefaultConstructible>);
-
-int main() { return 0; }
diff --git a/asl/option_tests.cpp b/asl/tests/option_tests.cpp
index 38bce2e..7de1f9c 100644
--- a/asl/option_tests.cpp
+++ b/asl/tests/option_tests.cpp
@@ -1,5 +1,6 @@
#include "asl/option.hpp"
-#include "asl/test_types.hpp"
+#include "asl/tests/test_types.hpp"
+#include <asl/testing/testing.hpp>
static_assert(asl::trivially_destructible<asl::option<TriviallyDestructible>>);
static_assert(!asl::trivially_destructible<asl::option<HasDestructor>>);
@@ -23,12 +24,10 @@ static_assert(asl::move_assignable<asl::option<int>>);
static_assert(asl::move_assignable<asl::option<CopyAssignable>>);
static_assert(!asl::move_assignable<asl::option<NonMoveAssignable>>);
-int main()
+ASL_TEST(Option, cheese)
{
asl::option<int> a;
asl::option<int> b;
a = ASL_MOVE(b);
-
- return 0;
}
diff --git a/asl/test_types.hpp b/asl/tests/test_types.hpp
index da1faa6..da1faa6 100644
--- a/asl/test_types.hpp
+++ b/asl/tests/test_types.hpp
diff --git a/asl/tests/utility_tests.cpp b/asl/tests/utility_tests.cpp
new file mode 100644
index 0000000..4acded7
--- /dev/null
+++ b/asl/tests/utility_tests.cpp
@@ -0,0 +1 @@
+#include "asl/utility.hpp"
diff --git a/asl/utility_tests.cpp b/asl/utility_tests.cpp
deleted file mode 100644
index 5802cec..0000000
--- a/asl/utility_tests.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "asl/utility.hpp"
-
-int main() { return 0; }