test: code coverage

This commit is contained in:
Michele Caini
2021-03-26 16:05:00 +01:00
parent f874c8309f
commit 059334a861
4 changed files with 70 additions and 4 deletions

View File

@@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
compiler: [
g++-8, g++-9, g++,
g++-7, g++-8, g++-9, g++,
clang++-8, clang++-9, clang++
]

View File

@@ -13,7 +13,7 @@ jobs:
- name: Compile tests
working-directory: build
env:
CXXFLAGS: "-O0 --coverage -fno-inline -fno-inline-small-functions -fno-default-inline"
CXXFLAGS: "--coverage -O0 -fprofile-arcs -fno-inline -fno-inline-small-functions -fno-default-inline"
CXX: g++
run: |
cmake -DENTT_BUILD_TESTING=ON -DENTT_BUILD_LIB=ON -DENTT_BUILD_EXAMPLE=ON ..

View File

@@ -201,6 +201,12 @@ TEST(NonOwningGroup, Each) {
}
ASSERT_EQ(cnt, std::size_t{0});
auto it = group.each().begin();
auto rit = group.each().rbegin();
ASSERT_EQ((it++, ++it), group.each().end());
ASSERT_EQ((rit++, ++rit), group.each().rend());
}
TEST(NonOwningGroup, Sort) {
@@ -252,6 +258,22 @@ TEST(NonOwningGroup, Sort) {
ASSERT_EQ((group.get<const int, unsigned int>(e2)), (std::make_tuple(2, 2u)));
ASSERT_FALSE(group.contains(e3));
group.sort<const int, unsigned int>([](const auto lhs, const auto rhs) {
static_assert(std::is_same_v<decltype(std::get<0>(lhs)), const int &>);
static_assert(std::is_same_v<decltype(std::get<1>(rhs)), unsigned int &>);
return std::get<0>(lhs) < std::get<0>(rhs);
});
ASSERT_EQ(*(group.data() + 0u), e2);
ASSERT_EQ(*(group.data() + 1u), e1);
ASSERT_EQ(*(group.data() + 2u), e0);
ASSERT_EQ((group.get<const int, unsigned int>(e0)), (std::make_tuple(0, 0u)));
ASSERT_EQ((group.get<const int, unsigned int>(e1)), (std::make_tuple(1, 1u)));
ASSERT_EQ((group.get<const int, unsigned int>(e2)), (std::make_tuple(2, 2u)));
ASSERT_FALSE(group.contains(e3));
}
TEST(NonOwningGroup, SortAsAPool) {
@@ -583,9 +605,21 @@ TEST(NonOwningGroup, SignalRace) {
TEST(NonOwningGroup, ExtendedGet) {
using type = decltype(std::declval<entt::registry>().group(entt::get<int, empty_type, char>).get({}));
static_assert(std::tuple_size_v<type> == 2u);
static_assert(std::is_same_v<std::tuple_element_t<0, type>, int &>);
static_assert(std::is_same_v<std::tuple_element_t<1, type>, char &>);
entt::registry registry;
const auto entity = registry.create();
registry.emplace<int>(entity, 42);
registry.emplace<char>(entity, 'c');
const auto tup = registry.group(entt::get<int, char>).get(entity);
ASSERT_EQ(std::get<0>(tup), 42);
ASSERT_EQ(std::get<1>(tup), 'c');
}
TEST(OwningGroup, Functionalities) {
@@ -770,6 +804,12 @@ TEST(OwningGroup, Each) {
}
ASSERT_EQ(cnt, std::size_t{0});
auto it = group.each().begin();
auto rit = group.each().rbegin();
ASSERT_EQ((it++, ++it), group.each().end());
ASSERT_EQ((rit++, ++rit), group.each().rend());
}
TEST(OwningGroup, SortOrdered) {
@@ -891,8 +931,10 @@ TEST(OwningGroup, SortUnordered) {
registry.emplace<boxed_int>(entities[5], 4);
registry.emplace<boxed_int>(entities[6], 5);
group.sort<char>([](const auto lhs, const auto rhs) {
return lhs < rhs;
group.sort<boxed_int, char>([](const auto lhs, const auto rhs) {
static_assert(std::is_same_v<decltype(std::get<0>(lhs)), boxed_int &>);
static_assert(std::is_same_v<decltype(std::get<1>(rhs)), char &>);
return std::get<1>(lhs) < std::get<1>(rhs);
});
ASSERT_EQ(*(group.data() + 0u), entities[4]);
@@ -1304,7 +1346,19 @@ TEST(OwningGroup, SwappingValuesIsAllowed) {
TEST(OwningGroup, ExtendedGet) {
using type = decltype(std::declval<entt::registry>().group<int, empty_type>(entt::get<char>).get({}));
static_assert(std::tuple_size_v<type> == 2u);
static_assert(std::is_same_v<std::tuple_element_t<0, type>, int &>);
static_assert(std::is_same_v<std::tuple_element_t<1, type>, char &>);
entt::registry registry;
const auto entity = registry.create();
registry.emplace<int>(entity, 42);
registry.emplace<char>(entity, 'c');
const auto tup = registry.group<int>(entt::get<char>).get(entity);
ASSERT_EQ(std::get<0>(tup), 42);
ASSERT_EQ(std::get<1>(tup), 'c');
}

View File

@@ -199,6 +199,12 @@ TEST(SingleComponentView, Each) {
}
ASSERT_EQ(cnt, std::size_t{0});
auto it = view.each().begin();
auto rit = view.each().rbegin();
ASSERT_EQ((it++, ++it), view.each().end());
ASSERT_EQ((rit++, ++rit), view.each().rend());
}
TEST(SingleComponentView, ConstNonConstAndAllInBetween) {
@@ -586,6 +592,12 @@ TEST(MultiComponentView, Each) {
}
ASSERT_EQ(cnt, std::size_t{0});
auto it = view.each().begin();
auto rit = view.each().rbegin();
ASSERT_EQ((it++, ++it), view.each().end());
ASSERT_EQ((rit++, ++rit), view.each().rend());
}
TEST(MultiComponentView, EachWithSuggestedType) {