test: minor changes (code coverage)

This commit is contained in:
Michele Caini
2021-01-22 19:30:35 +01:00
parent 80a0e47f1a
commit a5fdf917df
4 changed files with 18 additions and 13 deletions

View File

@@ -5,11 +5,13 @@
#include <entt/meta/resolve.hpp>
struct clazz_t {
clazz_t(): value{0} {}
void member(int i) { value = i; }
static void func() { c = 'd'; }
static inline char c = 'c';
int value = 0;
int value;
};
struct empty_t {
@@ -22,18 +24,18 @@ struct empty_t {
};
struct fat_t: empty_t {
fat_t() = default;
fat_t(): foo{}, bar{}, gnam{} {}
fat_t(int *value)
: foo{value}, bar{value}
: foo{value}, bar{value}, gnam{}
{}
bool operator==(const fat_t &other) const {
return foo == other.foo && bar == other.bar;
}
int *foo{nullptr};
int *bar{nullptr};
int *foo;
int *bar;
double gnam[4];
};

View File

@@ -6,8 +6,8 @@
#include <entt/meta/meta.hpp>
#include <entt/meta/resolve.hpp>
struct base_t { char value{}; };
struct derived_t: base_t {};
struct base_t { base_t(): value{'c'} {} char value; };
struct derived_t: base_t { derived_t(): base_t{} {} };
struct clazz_t {
clazz_t(const base_t &other, int iv)
@@ -131,7 +131,7 @@ TEST_F(MetaCtor, InvalidArgs) {
}
TEST_F(MetaCtor, CastAndConvert) {
auto any = entt::resolve<clazz_t>().ctor<const base_t &, int>().invoke(derived_t{{'c'}}, 42.);
auto any = entt::resolve<clazz_t>().ctor<const base_t &, int>().invoke(derived_t{}, 42.);
ASSERT_TRUE(any);
ASSERT_EQ(any.cast<clazz_t>().i, 42);
@@ -163,7 +163,7 @@ TEST_F(MetaCtor, FuncInvalidArgs) {
}
TEST_F(MetaCtor, FuncCastAndConvert) {
auto any = entt::resolve<clazz_t>().ctor<base_t, int, int>().invoke(derived_t{{'c'}}, 3., 3);
auto any = entt::resolve<clazz_t>().ctor<base_t, int, int>().invoke(derived_t{}, 3., 3);
ASSERT_TRUE(any);
ASSERT_EQ(any.cast<clazz_t>().i, 9);

View File

@@ -25,6 +25,8 @@ struct clazz_t {
};
struct setter_getter_t {
setter_getter_t(): value{0} {}
int setter(int val) {
return value = val;
}
@@ -49,7 +51,7 @@ struct setter_getter_t {
return type.value;
}
int value{};
int value;
};
struct array_t {

View File

@@ -19,16 +19,17 @@ Type get(Type &prop) {
return prop;
}
struct base_t { char value{'c'}; };
struct derived_t: base_t {};
struct base_t { base_t(): value{'c'} {}; char value; };
struct derived_t: base_t { derived_t(): base_t{} {} };
struct abstract_t {
virtual ~abstract_t() = default;
virtual void func(int) = 0;
virtual void func(int) {}
};
struct concrete_t: base_t, abstract_t {
void func(int v) override {
abstract_t::func(v);
value = v;
}