Fix clang-tidy and clang-format for tests and examples/src/constexpr_check.cpp
This commit is contained in:
parent
e5b4a231fc
commit
f7ecbd6d20
4 changed files with 58 additions and 85 deletions
|
@ -1,17 +1,15 @@
|
|||
#include <cserver/components/loggable_component_base.hpp>
|
||||
|
||||
|
||||
struct SomeComponent {
|
||||
static constexpr utempl::ConstexprString kName = "component";
|
||||
|
||||
constexpr SomeComponent(auto&) {};
|
||||
explicit constexpr SomeComponent(auto&) {};
|
||||
};
|
||||
|
||||
|
||||
struct SomeComponent2 {
|
||||
static constexpr utempl::ConstexprString kName = "component2";
|
||||
|
||||
constexpr SomeComponent2(auto&) {};
|
||||
explicit constexpr SomeComponent2(auto&) {};
|
||||
};
|
||||
|
||||
struct OtherComponent {
|
||||
|
@ -22,13 +20,14 @@ struct OtherComponent {
|
|||
// Compile time error with new check(check via loopholes)
|
||||
};
|
||||
|
||||
constexpr OtherComponent(auto& context) {
|
||||
explicit constexpr OtherComponent(auto& context) {
|
||||
context.template FindComponent<"component">();
|
||||
Foo(context);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
// clang-format off
|
||||
// NOLINTBEGIN
|
||||
auto main() -> int {
|
||||
cserver::ServiceContextBuilder{}
|
||||
.AppendConfigParam<"threads", 8>()
|
||||
|
@ -38,3 +37,4 @@ auto main() -> int {
|
|||
.Sort()
|
||||
.Run();
|
||||
};
|
||||
// NOLINTEND
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
#include <cserver/engine/components.hpp>
|
||||
#include <nameof.hpp>
|
||||
|
||||
COMPONENT_REQUIRES(Some, requires(T t){{t.f()} -> std::same_as<void>;});
|
||||
COMPONENT_REQUIRES(
|
||||
Some, requires(T t) {
|
||||
{ t.f() } -> std::same_as<void>;
|
||||
});
|
||||
|
||||
struct SomeComponent {
|
||||
static constexpr utempl::ConstexprString kName = "some";
|
||||
constexpr SomeComponent(auto& context) {
|
||||
explicit constexpr SomeComponent(auto& context) {
|
||||
context.template FindAllComponents<SomeM>();
|
||||
};
|
||||
};
|
||||
|
@ -14,18 +18,15 @@ struct SomeComponent {
|
|||
struct OtherComponent {
|
||||
static constexpr utempl::ConstexprString kName = "other";
|
||||
auto f() -> void {};
|
||||
constexpr OtherComponent(auto& context) {};
|
||||
explicit constexpr OtherComponent(auto& context) {};
|
||||
};
|
||||
|
||||
struct OtherComponent2 {
|
||||
static constexpr utempl::ConstexprString kName = "other2";
|
||||
auto f() -> void {};
|
||||
constexpr OtherComponent2(auto& context) {};
|
||||
explicit constexpr OtherComponent2(auto& context) {};
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
TEST(Meta, AllDependencies) {
|
||||
constexpr auto builder = cserver::ServiceContextBuilder{}
|
||||
.Append<SomeComponent>()
|
||||
|
@ -36,26 +37,15 @@ TEST(Meta, AllDependencies) {
|
|||
|
||||
constexpr auto dependencies = builder.GetDependencyGraph();
|
||||
using Need = utempl::Tuple<OtherComponent&, OtherComponent2&>;
|
||||
using R = decltype(
|
||||
builder
|
||||
.GetServiceContext()
|
||||
.GetContextFor<cserver::ComponentConfig<"some", SomeComponent, {}>>()
|
||||
.FindAllComponents<SomeM>());
|
||||
using R =
|
||||
decltype(builder.GetServiceContext().GetContextFor<cserver::ComponentConfig<"some", SomeComponent, {}>>().FindAllComponents<SomeM>());
|
||||
|
||||
EXPECT_EQ(NAMEOF_TYPE(R),
|
||||
NAMEOF_TYPE(Need));
|
||||
EXPECT_EQ(NAMEOF_TYPE(R), NAMEOF_TYPE(Need));
|
||||
|
||||
using DependenciesNeed = const cserver::DependencyGraph<
|
||||
cserver::DependencyGraphElement<
|
||||
"other",
|
||||
{}>,
|
||||
cserver::DependencyGraphElement<
|
||||
"other2",
|
||||
{}>,
|
||||
cserver::DependencyGraphElement<
|
||||
"some",
|
||||
{utempl::ConstexprString{"other"}, utempl::ConstexprString{"other2"}}>>;
|
||||
cserver::DependencyGraphElement<"other", {}>,
|
||||
cserver::DependencyGraphElement<"other2", {}>,
|
||||
cserver::DependencyGraphElement<"some", {utempl::ConstexprString{"other"}, utempl::ConstexprString{"other2"}}>>;
|
||||
|
||||
EXPECT_EQ(NAMEOF_TYPE(decltype(dependencies)),
|
||||
NAMEOF_TYPE(DependenciesNeed));
|
||||
EXPECT_EQ(NAMEOF_TYPE(decltype(dependencies)), NAMEOF_TYPE(DependenciesNeed));
|
||||
};
|
||||
|
|
|
@ -1,21 +1,19 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
#include <cserver/engine/components.hpp>
|
||||
#include <nameof.hpp>
|
||||
|
||||
struct SomeComponent {
|
||||
static constexpr utempl::ConstexprString kName = "some";
|
||||
constexpr SomeComponent(auto&) {};
|
||||
explicit constexpr SomeComponent(auto&) {};
|
||||
};
|
||||
|
||||
|
||||
struct SomeOtherComponent {
|
||||
SomeComponent& component;
|
||||
static constexpr utempl::ConstexprString kName = "other";
|
||||
constexpr SomeOtherComponent(auto& context) : component(context.template FindComponent<"some">()) {
|
||||
};
|
||||
explicit constexpr SomeOtherComponent(auto& context) : component(context.template FindComponent<"some">()) {};
|
||||
};
|
||||
|
||||
|
||||
TEST(Dependencies, Get) {
|
||||
constexpr auto dependencies = cserver::ServiceContextBuilder{}
|
||||
.Append<SomeOtherComponent>()
|
||||
|
@ -23,13 +21,7 @@ TEST(Dependencies, Get) {
|
|||
.AppendConfigParam<"threads", 8>()
|
||||
.Sort()
|
||||
.GetDependencyGraph();
|
||||
using Need = const cserver::DependencyGraph<
|
||||
cserver::DependencyGraphElement<
|
||||
"some",
|
||||
{}>,
|
||||
cserver::DependencyGraphElement<
|
||||
"other",
|
||||
{utempl::ConstexprString{"some"}}>>;
|
||||
EXPECT_EQ(NAMEOF_TYPE(decltype(dependencies)),
|
||||
NAMEOF_TYPE(Need));
|
||||
using Need = const cserver::DependencyGraph<cserver::DependencyGraphElement<"some", {}>,
|
||||
cserver::DependencyGraphElement<"other", {utempl::ConstexprString{"some"}}>>;
|
||||
EXPECT_EQ(NAMEOF_TYPE(decltype(dependencies)), NAMEOF_TYPE(Need));
|
||||
};
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
#include <cserver/engine/components.hpp>
|
||||
#include <nameof.hpp>
|
||||
|
||||
COMPONENT_REQUIRES(Some, requires(T t){{t.f()} -> std::same_as<void>;});
|
||||
COMPONENT_REQUIRES(
|
||||
Some, requires(T t) {
|
||||
{ t.f() } -> std::same_as<void>;
|
||||
});
|
||||
|
||||
struct SomeComponent {
|
||||
static constexpr utempl::ConstexprString kName = "some";
|
||||
constexpr SomeComponent(auto& context) {
|
||||
explicit constexpr SomeComponent(auto& context) {
|
||||
context.template FindComponent<SomeM>();
|
||||
};
|
||||
};
|
||||
|
@ -14,16 +18,15 @@ struct SomeComponent {
|
|||
struct OtherComponent {
|
||||
static constexpr utempl::ConstexprString kName = "other";
|
||||
auto f() -> void {};
|
||||
constexpr OtherComponent(auto& context) {};
|
||||
explicit constexpr OtherComponent(auto& context) {};
|
||||
};
|
||||
|
||||
struct OtherComponent2 {
|
||||
static constexpr utempl::ConstexprString kName = "other2";
|
||||
auto f() -> void {};
|
||||
constexpr OtherComponent2(auto& context) {};
|
||||
explicit constexpr OtherComponent2(auto& context) {};
|
||||
};
|
||||
|
||||
|
||||
TEST(Meta, OneDependency) {
|
||||
constexpr auto builder = cserver::ServiceContextBuilder{}
|
||||
.Append<SomeComponent>()
|
||||
|
@ -32,19 +35,11 @@ TEST(Meta, OneDependency) {
|
|||
.AppendConfigParam<"threads", 8>()
|
||||
.Sort();
|
||||
constexpr auto dependencies = builder.GetDependencyGraph();
|
||||
using Need = const cserver::DependencyGraph<
|
||||
cserver::DependencyGraphElement<
|
||||
"other",
|
||||
{}>,
|
||||
cserver::DependencyGraphElement<
|
||||
"some",
|
||||
{utempl::ConstexprString{"other"}}>,
|
||||
cserver::DependencyGraphElement<
|
||||
"other2",
|
||||
{}>>;
|
||||
using Need = const cserver::DependencyGraph<cserver::DependencyGraphElement<"other", {}>,
|
||||
cserver::DependencyGraphElement<"some", {utempl::ConstexprString{"other"}}>,
|
||||
cserver::DependencyGraphElement<"other2", {}>>;
|
||||
|
||||
EXPECT_EQ(NAMEOF_TYPE(decltype(dependencies)),
|
||||
NAMEOF_TYPE(Need));
|
||||
EXPECT_EQ(NAMEOF_TYPE(decltype(dependencies)), NAMEOF_TYPE(Need));
|
||||
};
|
||||
|
||||
struct SomeStruct2 {
|
||||
|
@ -52,7 +47,3 @@ struct SomeStruct2 {
|
|||
context.template FindAllComponents<SomeM>();
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue