Skip to content

Commit

Permalink
test: few last changes to please the linter
Browse files Browse the repository at this point in the history
  • Loading branch information
skypjack committed Oct 18, 2024
1 parent 59061ec commit 4a2d1a8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
10 changes: 5 additions & 5 deletions test/entt/meta/meta_func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct function {
}

[[nodiscard]] int f(int iv) const {
return iv * iv;
return value * iv;
}

void g(int iv) {
Expand Down Expand Up @@ -248,7 +248,7 @@ TEST_F(MetaFunc, Const) {
using namespace entt::literals;

auto func = entt::resolve<function>().func("f1"_hs);
function instance{};
function instance{2};

ASSERT_TRUE(func);
ASSERT_EQ(func.arity(), 1u);
Expand All @@ -264,7 +264,7 @@ TEST_F(MetaFunc, Const) {
ASSERT_FALSE(empty);
ASSERT_TRUE(any);
ASSERT_EQ(any.type(), entt::resolve<int>());
ASSERT_EQ(any.cast<int>(), 16);
ASSERT_EQ(any.cast<int>(), 8);

for(auto curr: func.prop()) {
ASSERT_EQ(curr.first, "true"_hs);
Expand Down Expand Up @@ -462,7 +462,7 @@ TEST_F(MetaFunc, NonClassTypeMember) {
TEST_F(MetaFunc, MetaAnyArgs) {
using namespace entt::literals;

function instance;
function instance{3};
auto any = entt::resolve<function>().func("f1"_hs).invoke(instance, 3);

ASSERT_TRUE(any);
Expand Down Expand Up @@ -535,7 +535,7 @@ TEST_F(MetaFunc, ArgsByConstRef) {
TEST_F(MetaFunc, ConstInstance) {
using namespace entt::literals;

function instance{};
function instance{2};
auto any = entt::resolve<function>().func("f1"_hs).invoke(std::as_const(instance), 2);

ASSERT_FALSE(entt::resolve<function>().func("g"_hs).invoke(std::as_const(instance), 1));
Expand Down
8 changes: 4 additions & 4 deletions test/entt/meta/meta_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ struct overloaded_func {
}

[[nodiscard]] int f(int val) const {
return val * val;
return val * value;
}

[[nodiscard]] float f(int first, const float second) {
Expand Down Expand Up @@ -472,14 +472,14 @@ TEST_F(MetaType, OverloadedFunc) {
ASSERT_TRUE(res);
ASSERT_EQ(instance.value, 3);
ASSERT_NE(res.try_cast<int>(), nullptr);
ASSERT_EQ(res.cast<int>(), 8);
ASSERT_EQ(res.cast<int>(), 12);

res = type.invoke("f"_hs, std::as_const(instance), 2);

ASSERT_TRUE(res);
ASSERT_EQ(instance.value, 3);
ASSERT_NE(res.try_cast<int>(), nullptr);
ASSERT_EQ(res.cast<int>(), 4);
ASSERT_EQ(res.cast<int>(), 6);

res = type.invoke("f"_hs, instance, 0, 1.f);

Expand Down Expand Up @@ -576,7 +576,7 @@ TEST_F(MetaType, ConstructCastAndConvert) {
}

TEST_F(MetaType, ConstructArithmeticConversion) {
auto any = entt::resolve<clazz>().construct(derived{}, clazz{derived{}, true});
auto any = entt::resolve<clazz>().construct(derived{}, true);

ASSERT_TRUE(any);
ASSERT_EQ(any.cast<clazz>().value, 1);
Expand Down
22 changes: 11 additions & 11 deletions test/entt/signal/delegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ struct delegate_functor {
return iv + iv;
}

[[nodiscard]] int identity(int iv) const {
return iv;
[[nodiscard]] int mul(int iv) const {
return iv * data_member;
}

static const int static_value = 3;
Expand Down Expand Up @@ -73,15 +73,15 @@ TEST(Delegate, Functionalities) {

ff_del.connect<&power_of_two>();
mf_del.connect<&delegate_functor::operator()>(functor);
lf_del.connect([](const void *ptr, int value) { return static_cast<const delegate_functor *>(ptr)->identity(value); }, &functor);
lf_del.connect([](const void *ptr, int value) { return static_cast<const delegate_functor *>(ptr)->mul(value); }, &functor);

ASSERT_TRUE(ff_del);
ASSERT_TRUE(mf_del);
ASSERT_TRUE(lf_del);

ASSERT_EQ(ff_del(3), 9);
ASSERT_EQ(mf_del(3), 6);
ASSERT_EQ(lf_del(3), 3);
ASSERT_EQ(lf_del(3), 12);

ff_del.reset();

Expand Down Expand Up @@ -206,7 +206,7 @@ TEST(Delegate, Comparison) {
ASSERT_FALSE(lhs == rhs);
ASSERT_NE(lhs, rhs);

lhs.connect([](const void *ptr, int val) { return static_cast<const delegate_functor *>(ptr)->identity(val) * val; }, &functor);
lhs.connect([](const void *ptr, int val) { return static_cast<const delegate_functor *>(ptr)->mul(val) * val; }, &functor);

ASSERT_NE(lhs, (entt::delegate<int(int)>{[](const void *, int val) { return val + val; }, &functor}));
ASSERT_NE(lhs.target(), rhs.target());
Expand All @@ -215,7 +215,7 @@ TEST(Delegate, Comparison) {
ASSERT_FALSE(lhs == rhs);
ASSERT_NE(lhs, rhs);

rhs.connect([](const void *ptr, int val) { return static_cast<const delegate_functor *>(ptr)->identity(val) + val; }, &functor);
rhs.connect([](const void *ptr, int val) { return static_cast<const delegate_functor *>(ptr)->mul(val) + val; }, &functor);

ASSERT_NE(rhs, (entt::delegate<int(int)>{[](const void *, int val) { return val * val; }, &functor}));
ASSERT_TRUE(lhs != rhs);
Expand Down Expand Up @@ -315,10 +315,10 @@ TEST(Delegate, ConstInstance) {

ASSERT_FALSE(delegate);

delegate.connect<&delegate_functor::identity>(functor);
delegate.connect<&delegate_functor::mul>(functor);

ASSERT_TRUE(delegate);
ASSERT_EQ(delegate(3), 3);
ASSERT_EQ(delegate(3), 12);

delegate.reset();

Expand Down Expand Up @@ -416,7 +416,7 @@ TEST(Delegate, VoidVsNonVoidReturnType) {

const entt::delegate<void(int)> func{entt::connect_arg<&power_of_two>};
const entt::delegate<void(int)> member{entt::connect_arg<&delegate_functor::operator()>, &functor};
const entt::delegate<void(int)> cmember{entt::connect_arg<&delegate_functor::identity>, &std::as_const(functor)};
const entt::delegate<void(int)> cmember{entt::connect_arg<&delegate_functor::mul>, &std::as_const(functor)};

ASSERT_TRUE(func);
ASSERT_TRUE(member);
Expand Down Expand Up @@ -455,9 +455,9 @@ TEST(Delegate, TheLessTheBetter) {
ASSERT_EQ(bound(3, 'c'), 6);

// int delegate_functor::operator()(int);
bound.connect<&delegate_functor::identity>(&functor);
bound.connect<&delegate_functor::mul>(&functor);

ASSERT_EQ(bound(3, 'c'), 3);
ASSERT_EQ(bound(3, 'c'), 12);

// int delegate_functor::operator()(int);
unbound.connect<&delegate_functor::operator()>();
Expand Down

0 comments on commit 4a2d1a8

Please sign in to comment.