11#pragma once
2- #include < type_traits>
32#include < vector>
43#include < initializer_list>
54#include < meta>
1110#include " _testing_impl/util.hpp"
1211#include " _testing_impl/paramset.hpp"
1312
14- namespace rsl ::testing {
1513
14+ namespace rsl ::testing {
1615using _testing_impl::ParamSet;
1716
1817namespace annotations {
1918struct FixtureTag {};
2019
2120// test kinds
2221struct TestTag {};
23- struct PropertyTag : TestTag {};
2422struct FuzzTag : TestTag {};
2523
2624// flags
@@ -98,7 +96,6 @@ struct Params {
9896constexpr inline annotations::FixtureTag fixture;
9997
10098constexpr inline annotations::TestTag test;
101- constexpr inline annotations::PropertyTag property_test;
10299constexpr inline annotations::FuzzTag fuzz;
103100
104101constexpr inline annotations::ExpectFailureTag expect_failure;
@@ -108,4 +105,48 @@ constexpr inline annotations::Rename rename;
108105
109106using tparams = annotations::TParams;
110107using params = annotations::Params;
111- } // namespace rsl::testing
108+
109+ namespace _testing_impl {
110+ struct Annotations { // consteval-only
111+ rsl::span<ParamSet const > targets;
112+ rsl::span<annotations::Params const > params;
113+
114+ bool expect_failure = false ;
115+ bool (*skip)() = nullptr ; // this is a function to support conditional skipping
116+ rsl::string_view name; // custom base name
117+ bool is_fuzz_test = false ;
118+
119+ consteval explicit Annotations (std::meta::info fnc) {
120+ std::vector<ParamSet> tp_sets;
121+ std::vector<annotations::Params> p;
122+
123+ for (auto annotation : annotations_of (fnc)) {
124+ auto type = remove_cvref (type_of (annotation));
125+ if (type == ^^annotations::TParams) {
126+ tp_sets.append_range (extract<annotations::TParams>(constant_of (annotation)).value );
127+ } else if (type == ^^annotations::Params) {
128+ p.push_back (extract<annotations::Params>(constant_of (annotation)));
129+ } else if (type == ^^annotations::ExpectFailureTag) {
130+ constexpr_assert (!expect_failure, " Cannot annotate with expect_failure more than once." );
131+ expect_failure = true ;
132+ } else if (type == ^^annotations::Skip) {
133+ // constexpr_assert(skip == nullptr, "Cannot have more than one skip annotation.");
134+ skip = extract<annotations::Skip>(constant_of (annotation)).value ;
135+ } else if (type == ^^annotations::Rename) {
136+ constexpr_assert (name.empty (), " Cannot rename more than once." );
137+ name = extract<annotations::Rename>(constant_of (annotation)).value ;
138+ } else if (type == ^^annotations::FuzzTag) {
139+ is_fuzz_test = true ;
140+ }
141+ }
142+
143+ targets = define_static_array (tp_sets);
144+ params = define_static_array (p);
145+
146+ if (skip == nullptr ) {
147+ skip = &constant_predicate<false >;
148+ }
149+ }
150+ };
151+ } // namespace rsl::testing::_testing_impl
152+ }
0 commit comments