Browse Source

test: drop a bunch of NOLINT

Michele Caini 2 years ago
parent
commit
11d609314c

+ 2 - 2
test/entt/core/compressed_pair.cpp

@@ -47,14 +47,14 @@ TEST(CompressedPair, ConstructCopyMove) {
     entt::compressed_pair<test::empty, std::unique_ptr<int>> movable{test::empty{}, std::make_unique<int>(1)};
     entt::compressed_pair<test::empty, std::unique_ptr<int>> movable{test::empty{}, std::make_unique<int>(1)};
     auto by_move{std::move(movable)};
     auto by_move{std::move(movable)};
 
 
+    ASSERT_TRUE(by_move.second());
     ASSERT_EQ(*by_move.second(), 1);
     ASSERT_EQ(*by_move.second(), 1);
-    ASSERT_EQ(movable.second(), nullptr); // NOLINT
 
 
     *by_move.second() = 3;
     *by_move.second() = 3;
     movable = std::move(by_move);
     movable = std::move(by_move);
 
 
+    ASSERT_TRUE(movable.second());
     ASSERT_EQ(*movable.second(), 3);
     ASSERT_EQ(*movable.second(), 3);
-    ASSERT_EQ(by_move.second(), nullptr); // NOLINT
 }
 }
 
 
 TEST(CompressedPair, PiecewiseConstruct) {
 TEST(CompressedPair, PiecewiseConstruct) {

+ 7 - 4
test/entt/core/memory.cpp

@@ -1,3 +1,4 @@
+#include <array>
 #include <cmath>
 #include <cmath>
 #include <cstddef>
 #include <cstddef>
 #include <limits>
 #include <limits>
@@ -214,10 +215,11 @@ TEST(MakeObjUsingAllocator, Functionalities) {
 }
 }
 
 
 TEST(UninitializedConstructUsingAllocator, NoUsesAllocatorConstruction) {
 TEST(UninitializedConstructUsingAllocator, NoUsesAllocatorConstruction) {
-    alignas(int) std::byte storage[sizeof(int)]; // NOLINT
+    alignas(int) std::array<std::byte, sizeof(int)> storage{};
     const std::allocator<int> allocator{};
     const std::allocator<int> allocator{};
 
 
-    int *value = entt::uninitialized_construct_using_allocator(reinterpret_cast<int *>(&storage), allocator, 1); // NOLINT
+    // NOLINTNEXTLINE(*-reinterpret-cast)
+    int *value = entt::uninitialized_construct_using_allocator(reinterpret_cast<int *>(storage.data()), allocator, 1);
 
 
     ASSERT_EQ(*value, 1);
     ASSERT_EQ(*value, 1);
 }
 }
@@ -230,9 +232,10 @@ TEST(UninitializedConstructUsingAllocator, UsesAllocatorConstruction) {
 
 
     test::tracked_memory_resource memory_resource{};
     test::tracked_memory_resource memory_resource{};
     const std::pmr::polymorphic_allocator<string_type> allocator{&memory_resource};
     const std::pmr::polymorphic_allocator<string_type> allocator{&memory_resource};
-    alignas(string_type) std::byte storage[sizeof(string_type)]; // NOLINT
+    alignas(string_type) std::array<std::byte, sizeof(string_type)> storage{};
 
 
-    string_type *value = entt::uninitialized_construct_using_allocator(reinterpret_cast<string_type *>(&storage), allocator, test::tracked_memory_resource::default_value); // NOLINT
+    // NOLINTNEXTLINE(*-reinterpret-cast)
+    string_type *value = entt::uninitialized_construct_using_allocator(reinterpret_cast<string_type *>(storage.data()), allocator, test::tracked_memory_resource::default_value);
 
 
     ASSERT_GT(memory_resource.do_allocate_counter(), 0u);
     ASSERT_GT(memory_resource.do_allocate_counter(), 0u);
     ASSERT_EQ(memory_resource.do_deallocate_counter(), 0u);
     ASSERT_EQ(memory_resource.do_deallocate_counter(), 0u);

+ 6 - 3
test/entt/core/type_traits.cpp

@@ -60,8 +60,10 @@ struct UnpackAsValue: ::testing::Test {
 TEST(SizeOf, Functionalities) {
 TEST(SizeOf, Functionalities) {
     ASSERT_EQ(entt::size_of_v<void>, 0u);
     ASSERT_EQ(entt::size_of_v<void>, 0u);
     ASSERT_EQ(entt::size_of_v<char>, sizeof(char));
     ASSERT_EQ(entt::size_of_v<char>, sizeof(char));
-    ASSERT_EQ(entt::size_of_v<int[]>, 0u);              // NOLINT
-    ASSERT_EQ(entt::size_of_v<int[3]>, sizeof(int[3])); // NOLINT
+    // NOLINTBEGIN(*-avoid-c-arrays)
+    ASSERT_EQ(entt::size_of_v<int[]>, 0u);
+    ASSERT_EQ(entt::size_of_v<int[3]>, sizeof(int[3]));
+    // NOLINTEND(*-avoid-c-arrays)
 }
 }
 
 
 TEST_F(UnpackAsType, Functionalities) {
 TEST_F(UnpackAsType, Functionalities) {
@@ -223,7 +225,8 @@ TEST(IsEqualityComparable, Functionalities) {
     ASSERT_TRUE((entt::is_equality_comparable_v<std::optional<int>>));
     ASSERT_TRUE((entt::is_equality_comparable_v<std::optional<int>>));
     ASSERT_TRUE(entt::is_equality_comparable_v<nlohmann_json_like>);
     ASSERT_TRUE(entt::is_equality_comparable_v<nlohmann_json_like>);
 
 
-    ASSERT_FALSE(entt::is_equality_comparable_v<int[3u]>); // NOLINT
+    // NOLINTNEXTLINE(*-avoid-c-arrays)
+    ASSERT_FALSE(entt::is_equality_comparable_v<int[3u]>);
     ASSERT_FALSE(entt::is_equality_comparable_v<test::non_comparable>);
     ASSERT_FALSE(entt::is_equality_comparable_v<test::non_comparable>);
     ASSERT_FALSE(entt::is_equality_comparable_v<const test::non_comparable>);
     ASSERT_FALSE(entt::is_equality_comparable_v<const test::non_comparable>);
     ASSERT_FALSE(entt::is_equality_comparable_v<std::vector<test::non_comparable>>);
     ASSERT_FALSE(entt::is_equality_comparable_v<std::vector<test::non_comparable>>);

+ 2 - 1
test/entt/core/utility.cpp

@@ -27,7 +27,8 @@ TEST(Overload, Functionalities) {
     ASSERT_EQ(entt::overload<void(int)>(&functions::bar), static_cast<void (functions::*)(int)>(&functions::bar));
     ASSERT_EQ(entt::overload<void(int)>(&functions::bar), static_cast<void (functions::*)(int)>(&functions::bar));
     ASSERT_EQ(entt::overload<void()>(&functions::bar), static_cast<void (functions::*)()>(&functions::bar));
     ASSERT_EQ(entt::overload<void()>(&functions::bar), static_cast<void (functions::*)()>(&functions::bar));
 
 
-    functions instance; // NOLINT
+    functions instance;
+    instance.bar(0); // makes the linter happy
 
 
     ASSERT_NO_THROW(entt::overload<void(int)>(&functions::foo)(0));
     ASSERT_NO_THROW(entt::overload<void(int)>(&functions::foo)(0));
     ASSERT_NO_THROW(entt::overload<void()>(&functions::foo)());
     ASSERT_NO_THROW(entt::overload<void()>(&functions::foo)());