Skip to content

Commit

Permalink
Move make_suite functions up to simplify forward-declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
jimporter committed Jul 30, 2024
1 parent 0e3f6c1 commit 2954a6f
Showing 1 changed file with 104 additions and 111 deletions.
215 changes: 104 additions & 111 deletions include/mettle/suite/make_suite.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,116 @@ namespace mettle {

} // namespace detail

template<typename Factory, typename ParentFixture,
typename Fixture = detail::no_fixture_t>
class suite_builder;

template<typename Exception, typename ...Fixture, typename ...Args>
inline auto
make_basic_suite(const std::string &name, const attributes &attrs,
Args &&...args) {
return detail::do_build<suite_builder, std::tuple<>, Fixture...>(
name, attrs, std::forward<Args>(args)..., detail::wrap_test<Exception>{}
);
}

template<typename Exception, typename ...Fixture, typename ...Args>
inline auto
make_basic_suite(const std::string &name, Args &&...args) {
return detail::do_build<suite_builder, std::tuple<>, Fixture...>(
name, {}, std::forward<Args>(args)..., detail::wrap_test<Exception>{}
);
}

template<typename Exception, typename ...Fixture, typename ...Args>
inline auto
make_basic_suites(const std::string &name, const attributes &attrs,
Args &&...args) {
return detail::do_builds<suite_builder, std::tuple<>, Fixture...>(
name, attrs, std::forward<Args>(args)..., detail::wrap_test<Exception>{}
);
}

template<typename Exception, typename ...Fixture, typename ...Args>
inline auto
make_basic_suites(const std::string &name, Args &&...args) {
return detail::do_builds<suite_builder, std::tuple<>, Fixture...>(
name, {}, std::forward<Args>(args)..., detail::wrap_test<Exception>{}
);
}


template<typename ParentFixture, typename ...Fixture, typename ...Args>
inline compiled_suite<detail::to_func<ParentFixture>>
make_subsuite(const std::string &name, const attributes &attrs,
Args &&...args) {
return detail::do_build<suite_builder, ParentFixture, Fixture...>(
name, attrs, std::forward<Args>(args)..., detail::identity{}
);
}

template<typename ParentFixture, typename ...Fixture, typename ...Args>
inline compiled_suite<detail::to_func<ParentFixture>>
make_subsuite(const std::string &name, Args &&...args) {
return detail::do_build<suite_builder, ParentFixture, Fixture...>(
name, {}, std::forward<Args>(args)..., detail::identity{}
);
}

template<typename ParentFixture, typename ...Fixture, typename ...Args>
inline std::array<compiled_suite<detail::to_func<ParentFixture>>,
std::max(sizeof...(Fixture), std::size_t(1))>
make_subsuites(const std::string &name, const attributes &attrs,
Args &&...args);
Args &&...args) {
return detail::do_builds<suite_builder, ParentFixture, Fixture...>(
name, attrs, std::forward<Args>(args)..., detail::identity{}
);
}

template<typename ParentFixture, typename ...Fixture, typename ...Args>
inline std::array<compiled_suite<detail::to_func<ParentFixture>>,
std::max(sizeof...(Fixture), std::size_t(1))>
make_subsuites(const std::string &name, Args &&...args);
std::max(sizeof...(Fixture), std::size_t(1))>
make_subsuites(const std::string &name, Args &&...args) {
return detail::do_builds<suite_builder, ParentFixture, Fixture...>(
name, {}, std::forward<Args>(args)..., detail::identity{}
);
}


template<typename ...Fixture, typename Parent, typename ...Args>
inline auto
make_subsuite(const Parent &, const std::string &name,
const attributes &attrs, Args &&...args) {
return make_subsuite<typename Parent::tuple_type, Fixture...>(
name, attrs, std::forward<Args>(args)...
);
}

template<typename ...Fixture, typename Parent, typename ...Args>
inline auto
make_subsuite(const Parent &, const std::string &name, Args &&...args) {
return make_subsuite<typename Parent::tuple_type, Fixture...>(
name, std::forward<Args>(args)...
);
}

template<typename ...Fixture, typename Parent, typename ...Args>
inline auto
make_subsuites(const Parent &, const std::string &name,
const attributes &attrs, Args &&...args) {
return make_subsuites<typename Parent::tuple_type, Fixture...>(
name, attrs, std::forward<Args>(args)...
);
}

template<typename ...Fixture, typename Parent, typename ...Args>
inline auto
make_subsuites(const Parent &, const std::string &name, Args &&...args) {
return make_subsuites<typename Parent::tuple_type, Fixture...>(
name, std::forward<Args>(args)...
);
}


template<typename ...T>
class suite_builder_base {
Expand Down Expand Up @@ -228,7 +328,7 @@ namespace mettle {
>::type;

template<typename Factory, typename ParentFixture,
typename Fixture = detail::no_fixture_t>
typename Fixture /* = detail::no_fixture_t */>
class suite_builder
: public suite_builder_base_t<Factory, ParentFixture, Fixture> {
using base = suite_builder_base_t<Factory, ParentFixture, Fixture>;
Expand All @@ -251,113 +351,6 @@ namespace mettle {
};


template<typename Exception, typename ...Fixture, typename ...Args>
inline auto
make_basic_suite(const std::string &name, const attributes &attrs,
Args &&...args) {
return detail::do_build<suite_builder, std::tuple<>, Fixture...>(
name, attrs, std::forward<Args>(args)..., detail::wrap_test<Exception>{}
);
}

template<typename Exception, typename ...Fixture, typename ...Args>
inline auto
make_basic_suite(const std::string &name, Args &&...args) {
return detail::do_build<suite_builder, std::tuple<>, Fixture...>(
name, {}, std::forward<Args>(args)..., detail::wrap_test<Exception>{}
);
}

template<typename Exception, typename ...Fixture, typename ...Args>
inline auto
make_basic_suites(const std::string &name, const attributes &attrs,
Args &&...args) {
return detail::do_builds<suite_builder, std::tuple<>, Fixture...>(
name, attrs, std::forward<Args>(args)..., detail::wrap_test<Exception>{}
);
}

template<typename Exception, typename ...Fixture, typename ...Args>
inline auto
make_basic_suites(const std::string &name, Args &&...args) {
return detail::do_builds<suite_builder, std::tuple<>, Fixture...>(
name, {}, std::forward<Args>(args)..., detail::wrap_test<Exception>{}
);
}


template<typename ParentFixture, typename ...Fixture, typename ...Args>
inline compiled_suite<detail::to_func<ParentFixture>>
make_subsuite(const std::string &name, const attributes &attrs,
Args &&...args) {
return detail::do_build<suite_builder, ParentFixture, Fixture...>(
name, attrs, std::forward<Args>(args)..., detail::identity{}
);
}

template<typename ParentFixture, typename ...Fixture, typename ...Args>
inline compiled_suite<detail::to_func<ParentFixture>>
make_subsuite(const std::string &name, Args &&...args) {
return detail::do_build<suite_builder, ParentFixture, Fixture...>(
name, {}, std::forward<Args>(args)..., detail::identity{}
);
}

template<typename ParentFixture, typename ...Fixture, typename ...Args>
inline std::array<compiled_suite<detail::to_func<ParentFixture>>,
std::max(sizeof...(Fixture), std::size_t(1))>
make_subsuites(const std::string &name, const attributes &attrs,
Args &&...args) {
return detail::do_builds<suite_builder, ParentFixture, Fixture...>(
name, attrs, std::forward<Args>(args)..., detail::identity{}
);
}

template<typename ParentFixture, typename ...Fixture, typename ...Args>
inline std::array<compiled_suite<detail::to_func<ParentFixture>>,
std::max(sizeof...(Fixture), std::size_t(1))>
make_subsuites(const std::string &name, Args &&...args) {
return detail::do_builds<suite_builder, ParentFixture, Fixture...>(
name, {}, std::forward<Args>(args)..., detail::identity{}
);
}


template<typename ...Fixture, typename Parent, typename ...Args>
inline auto
make_subsuite(const Parent &, const std::string &name,
const attributes &attrs, Args &&...args) {
return make_subsuite<typename Parent::tuple_type, Fixture...>(
name, attrs, std::forward<Args>(args)...
);
}

template<typename ...Fixture, typename Parent, typename ...Args>
inline auto
make_subsuite(const Parent &, const std::string &name, Args &&...args) {
return make_subsuite<typename Parent::tuple_type, Fixture...>(
name, std::forward<Args>(args)...
);
}

template<typename ...Fixture, typename Parent, typename ...Args>
inline auto
make_subsuites(const Parent &, const std::string &name,
const attributes &attrs, Args &&...args) {
return make_subsuites<typename Parent::tuple_type, Fixture...>(
name, attrs, std::forward<Args>(args)...
);
}

template<typename ...Fixture, typename Parent, typename ...Args>
inline auto
make_subsuites(const Parent &, const std::string &name, Args &&...args) {
return make_subsuites<typename Parent::tuple_type, Fixture...>(
name, std::forward<Args>(args)...
);
}


template<typename ...Fixture, typename Parent, typename ...Args>
inline void
subsuite(Parent &p, const std::string &name, const attributes &attrs,
Expand Down

0 comments on commit 2954a6f

Please sign in to comment.