test: drop a bunch of NOLINT

This commit is contained in:
Michele Caini
2024-01-26 08:15:59 +01:00
parent ece46d4aa3
commit 79d72bd568
2 changed files with 89 additions and 76 deletions

View File

@@ -13,6 +13,7 @@
#include <entt/core/memory.hpp>
#include <entt/core/utility.hpp>
#include "../common/config.h"
#include "../common/linter.hpp"
#include "../common/throwing_allocator.hpp"
#include "../common/tracked_memory_resource.hpp"
#include "../common/transparent_equal_to.h"
@@ -113,66 +114,71 @@ TEST(DenseMap, Constructors) {
TEST(DenseMap, Copy) {
entt::dense_map<std::size_t, std::size_t, entt::identity> map;
map.max_load_factor(map.max_load_factor() - .05f);
map.emplace(3u, 42u); // NOLINT
const auto max_load_factor = map.max_load_factor() - .05f;
map.max_load_factor(max_load_factor);
map.emplace(3u, 1u);
entt::dense_map<std::size_t, std::size_t, entt::identity> other{map};
ASSERT_TRUE(map.contains(3u));
ASSERT_TRUE(other.contains(3u));
ASSERT_EQ(map.max_load_factor(), other.max_load_factor());
ASSERT_EQ(other.max_load_factor(), max_load_factor);
map.emplace(1u, 99u); // NOLINT
map.emplace(11u, 77u); // NOLINT
other.emplace(0u, 0u);
map.emplace(0u, 2u);
map.emplace(8u, 3u);
other.emplace(1u, 0u);
other = map;
ASSERT_TRUE(other.contains(3u));
ASSERT_TRUE(other.contains(1u));
ASSERT_TRUE(other.contains(11u));
ASSERT_FALSE(other.contains(0u));
ASSERT_TRUE(other.contains(0u));
ASSERT_TRUE(other.contains(8u));
ASSERT_FALSE(other.contains(1u));
ASSERT_EQ(other[3u], 42u);
ASSERT_EQ(other[1u], 99u);
ASSERT_EQ(other[11u], 77u);
ASSERT_EQ(other[3u], 1u);
ASSERT_EQ(other[0u], 2u);
ASSERT_EQ(other[8u], 3u);
ASSERT_EQ(other.bucket(3u), map.bucket(11u));
ASSERT_EQ(other.bucket(3u), other.bucket(11u));
ASSERT_EQ(*other.begin(3u), *map.begin(3u));
ASSERT_EQ(other.begin(3u)->first, 11u);
ASSERT_EQ((++other.begin(3u))->first, 3u);
ASSERT_EQ(other.bucket(0u), map.bucket(8u));
ASSERT_EQ(other.bucket(0u), other.bucket(8u));
ASSERT_EQ(*other.begin(0u), *map.begin(0u));
ASSERT_EQ(other.begin(0u)->first, 8u);
ASSERT_EQ((++other.begin(0u))->first, 0u);
}
TEST(DenseMap, Move) {
entt::dense_map<std::size_t, std::size_t, entt::identity> map;
map.max_load_factor(map.max_load_factor() - .05f);
map.emplace(3u, 42u); // NOLINT
const auto max_load_factor = map.max_load_factor() - .05f;
map.max_load_factor(max_load_factor);
map.emplace(3u, 1u);
entt::dense_map<std::size_t, std::size_t, entt::identity> other{std::move(map)};
ASSERT_EQ(map.size(), 0u); // NOLINT
test::is_initialized(map);
ASSERT_TRUE(map.empty());
ASSERT_TRUE(other.contains(3u));
ASSERT_EQ(map.max_load_factor(), other.max_load_factor());
ASSERT_EQ(other.max_load_factor(), max_load_factor);
map = other;
map.emplace(1u, 99u); // NOLINT
map.emplace(11u, 77u); // NOLINT
other.emplace(0u, 0u);
map.emplace(0u, 2u);
map.emplace(8u, 3u);
other.emplace(1u, 0u);
other = std::move(map);
test::is_initialized(map);
ASSERT_EQ(map.size(), 0u); // NOLINT
ASSERT_TRUE(map.empty());
ASSERT_TRUE(other.contains(3u));
ASSERT_TRUE(other.contains(1u));
ASSERT_TRUE(other.contains(11u));
ASSERT_FALSE(other.contains(0u));
ASSERT_TRUE(other.contains(0u));
ASSERT_TRUE(other.contains(8u));
ASSERT_FALSE(other.contains(1u));
ASSERT_EQ(other[3u], 42u);
ASSERT_EQ(other[1u], 99u);
ASSERT_EQ(other[11u], 77u);
ASSERT_EQ(other[3u], 1u);
ASSERT_EQ(other[0u], 2u);
ASSERT_EQ(other[8u], 3u);
ASSERT_EQ(other.bucket(3u), other.bucket(11u));
ASSERT_EQ(other.begin(3u)->first, 11u);
ASSERT_EQ((++other.begin(3u))->first, 3u);
ASSERT_EQ(other.bucket(0u), other.bucket(8u));
ASSERT_EQ(other.begin(0u)->first, 8u);
ASSERT_EQ((++other.begin(0u))->first, 0u);
}
TEST(DenseMap, Iterator) {
@@ -1057,33 +1063,33 @@ TEST(DenseMap, LocalIteratorConversion) {
TEST(DenseMap, Rehash) {
constexpr std::size_t minimum_bucket_count = 8u;
entt::dense_map<std::size_t, std::size_t, entt::identity> map;
map[32u] = 99u; // NOLINT
map[32u] = 2u;
ASSERT_EQ(map.bucket_count(), minimum_bucket_count);
ASSERT_TRUE(map.contains(32u));
ASSERT_EQ(map.bucket(32u), 0u);
ASSERT_EQ(map[32u], 99u);
ASSERT_EQ(map[32u], 2u);
map.rehash(12u); // NOLINT
map.rehash(minimum_bucket_count + 1u);
ASSERT_EQ(map.bucket_count(), 2u * minimum_bucket_count);
ASSERT_TRUE(map.contains(32u));
ASSERT_EQ(map.bucket(32u), 0u);
ASSERT_EQ(map[32u], 99u);
ASSERT_EQ(map[32u], 2u);
map.rehash(44u); // NOLINT
map.rehash(4u * minimum_bucket_count + 1u);
ASSERT_EQ(map.bucket_count(), 8u * minimum_bucket_count);
ASSERT_TRUE(map.contains(32u));
ASSERT_EQ(map.bucket(32u), 32u);
ASSERT_EQ(map[32u], 99u);
ASSERT_EQ(map[32u], 2u);
map.rehash(0u);
ASSERT_EQ(map.bucket_count(), minimum_bucket_count);
ASSERT_TRUE(map.contains(32u));
ASSERT_EQ(map.bucket(32u), 0u);
ASSERT_EQ(map[32u], 99u);
ASSERT_EQ(map[32u], 2u);
for(std::size_t next{}; next < minimum_bucket_count; ++next) {
map.emplace(next, next);
@@ -1097,7 +1103,7 @@ TEST(DenseMap, Rehash) {
ASSERT_EQ(map.bucket_count(), 2u * minimum_bucket_count);
ASSERT_TRUE(map.contains(32u));
map.rehash(55u); // NOLINT
map.rehash(4u * minimum_bucket_count + 4u);
ASSERT_EQ(map.bucket_count(), 8u * minimum_bucket_count);
ASSERT_TRUE(map.contains(32u));
@@ -1107,7 +1113,7 @@ TEST(DenseMap, Rehash) {
ASSERT_EQ(map.bucket_count(), 2u * minimum_bucket_count);
ASSERT_TRUE(map.contains(32u));
ASSERT_EQ(map.bucket(32u), 0u);
ASSERT_EQ(map[32u], 99u);
ASSERT_EQ(map[32u], 2u);
for(std::size_t next{}; next < minimum_bucket_count; ++next) {
ASSERT_TRUE(map.contains(next));
@@ -1121,7 +1127,7 @@ TEST(DenseMap, Rehash) {
ASSERT_EQ(map.begin(0u)->first, 0u);
ASSERT_EQ(map.begin(0u)->second, 0u);
ASSERT_EQ((++map.begin(0u))->first, 32u);
ASSERT_EQ((++map.begin(0u))->second, 99u);
ASSERT_EQ((++map.begin(0u))->second, 2u);
map.clear();
map.rehash(2u);

View File

@@ -1,3 +1,4 @@
#include <array>
#include <cmath>
#include <cstddef>
#include <functional>
@@ -11,6 +12,7 @@
#include <entt/container/dense_set.hpp>
#include <entt/core/memory.hpp>
#include <entt/core/utility.hpp>
#include "../common/linter.hpp"
#include "../common/throwing_allocator.hpp"
#include "../common/tracked_memory_resource.hpp"
#include "../common/transparent_equal_to.h"
@@ -111,58 +113,63 @@ TEST(DenseSet, Constructors) {
TEST(DenseSet, Copy) {
entt::dense_set<std::size_t, entt::identity> set;
set.max_load_factor(set.max_load_factor() - .05f);
const auto max_load_factor = set.max_load_factor() - .05f;
set.max_load_factor(max_load_factor);
set.emplace(3u);
entt::dense_set<std::size_t, entt::identity> other{set};
ASSERT_TRUE(set.contains(3u));
ASSERT_TRUE(other.contains(3u));
ASSERT_EQ(set.max_load_factor(), other.max_load_factor());
ASSERT_EQ(other.max_load_factor(), max_load_factor);
set.emplace(1u);
set.emplace(11u); // NOLINT
other.emplace(0u);
set.emplace(0u);
set.emplace(8u);
other.emplace(1u);
other = set;
ASSERT_TRUE(other.contains(3u));
ASSERT_TRUE(other.contains(1u));
ASSERT_TRUE(other.contains(11u));
ASSERT_FALSE(other.contains(0u));
ASSERT_TRUE(other.contains(0u));
ASSERT_TRUE(other.contains(8u));
ASSERT_FALSE(other.contains(1u));
ASSERT_EQ(other.bucket(3u), set.bucket(11u));
ASSERT_EQ(other.bucket(3u), other.bucket(11u));
ASSERT_EQ(*other.begin(3u), *set.begin(3u));
ASSERT_EQ(*other.begin(3u), 11u);
ASSERT_EQ((*++other.begin(3u)), 3u);
ASSERT_EQ(other.bucket(0u), set.bucket(8u));
ASSERT_EQ(other.bucket(0u), other.bucket(8u));
ASSERT_EQ(*other.begin(0u), *set.begin(0u));
ASSERT_EQ(*other.begin(0u), 8u);
ASSERT_EQ((*++other.begin(0u)), 0u);
}
TEST(DenseSet, Move) {
entt::dense_set<std::size_t, entt::identity> set;
set.max_load_factor(set.max_load_factor() - .05f);
const auto max_load_factor = set.max_load_factor() - .05f;
set.max_load_factor(max_load_factor);
set.emplace(3u);
entt::dense_set<std::size_t, entt::identity> other{std::move(set)};
ASSERT_EQ(set.size(), 0u); // NOLINT
test::is_initialized(set);
ASSERT_TRUE(set.empty());
ASSERT_TRUE(other.contains(3u));
ASSERT_EQ(set.max_load_factor(), other.max_load_factor());
ASSERT_EQ(other.max_load_factor(), max_load_factor);
set = other;
set.emplace(1u);
set.emplace(11u); // NOLINT
other.emplace(0u);
set.emplace(0u);
set.emplace(8u);
other.emplace(1u);
other = std::move(set);
test::is_initialized(set);
ASSERT_EQ(set.size(), 0u); // NOLINT
ASSERT_TRUE(set.empty());
ASSERT_TRUE(other.contains(3u));
ASSERT_TRUE(other.contains(1u));
ASSERT_TRUE(other.contains(11u));
ASSERT_FALSE(other.contains(0u));
ASSERT_TRUE(other.contains(0u));
ASSERT_TRUE(other.contains(8u));
ASSERT_FALSE(other.contains(1u));
ASSERT_EQ(other.bucket(3u), other.bucket(11u));
ASSERT_EQ(*other.begin(3u), 11u);
ASSERT_EQ(*++other.begin(3u), 3u);
ASSERT_EQ(other.bucket(0u), other.bucket(8u));
ASSERT_EQ(*other.begin(0u), 8u);
ASSERT_EQ(*++other.begin(0u), 0u);
}
TEST(DenseSet, Iterator) {
@@ -445,12 +452,12 @@ TEST(DenseSet, Insert) {
ASSERT_EQ(it, --set.end());
ASSERT_EQ(*it, 3);
int range[2u]{7, 9}; // NOLINT
std::array range{2, 4};
set.insert(std::begin(range), std::end(range));
ASSERT_EQ(set.size(), 4u);
ASSERT_TRUE(set.contains(7));
ASSERT_NE(set.find(9), set.end());
ASSERT_TRUE(set.contains(2));
ASSERT_NE(set.find(4), set.end());
}
TEST(DenseSet, InsertRehash) {
@@ -895,13 +902,13 @@ TEST(DenseSet, Rehash) {
ASSERT_TRUE(set.contains(32u));
ASSERT_EQ(set.bucket(32u), 0u);
set.rehash(12u); // NOLINT
set.rehash(minimum_bucket_count + 1u);
ASSERT_EQ(set.bucket_count(), 2u * minimum_bucket_count);
ASSERT_TRUE(set.contains(32u));
ASSERT_EQ(set.bucket(32u), 0u);
set.rehash(44u); // NOLINT
set.rehash(4u * minimum_bucket_count + 1u);
ASSERT_EQ(set.bucket_count(), 8u * minimum_bucket_count);
ASSERT_TRUE(set.contains(32u));
@@ -925,7 +932,7 @@ TEST(DenseSet, Rehash) {
ASSERT_EQ(set.bucket_count(), 2u * minimum_bucket_count);
ASSERT_TRUE(set.contains(32u));
set.rehash(55u); // NOLINT
set.rehash(4u * minimum_bucket_count + 4u);
ASSERT_EQ(set.bucket_count(), 8u * minimum_bucket_count);
ASSERT_TRUE(set.contains(32u));