diff options
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | compat/LooseQuadtree-impl.h | 32 | ||||
-rw-r--r-- | compat/LooseQuadtree.h | 10 | ||||
-rw-r--r-- | test/LooseQuadtreeTest.cpp | 35 | ||||
-rw-r--r-- | test/app.hpp | 1 | ||||
-rw-r--r-- | test/main.cpp | 1 |
6 files changed, 55 insertions, 25 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ea236ce..b1f95fb6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -123,6 +123,7 @@ if(MSVC) -wd4458 # warning C4458: declaration of 'keys' hides class member -wd4127 # warning C4127: conditional expression is constant -wd4554 # warning C4554: '<<': check operator precedence for possible error; use parentheses to clarify precedence + -wd4146 # warning C4146: unary minus operator applied to unsigned type, result still unsigned ) add_definitions(-utf-8) if(CMAKE_SIZEOF_VOID_P GREATER_EQUAL 8) diff --git a/compat/LooseQuadtree-impl.h b/compat/LooseQuadtree-impl.h index a8791a46..470377c8 100644 --- a/compat/LooseQuadtree-impl.h +++ b/compat/LooseQuadtree-impl.h @@ -2,9 +2,11 @@ #define LOOSEQUADTREE_LOOSEQUADTREE_IMPL_H #include "LooseQuadtree.h" +#include "compat/assert.hpp" +#undef assert +#define assert fm_assert #include <array> -#include <cassert> #include <cstddef> #include <deque> #include <forward_list> @@ -15,6 +17,15 @@ #include <type_traits> #include <vector> +#if defined __clang__ || defined __CLION_IDE__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wundefined-reinterpret-cast" +#endif +#ifdef __GNUG__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wfloat-equal" +#endif + namespace loose_quadtree { namespace detail { @@ -25,9 +36,9 @@ namespace detail { class BlocksAllocator { public: - const static std::size_t kBlockAlign = alignof(long double); - const static std::size_t kBlockSize = 16384; - const static std::size_t kMaxAllowedAlloc = sizeof(void*) * 8; + static constexpr std::size_t kBlockAlign = alignof(long double); + static constexpr std::size_t kBlockSize = 16384; + static constexpr std::size_t kMaxAllowedAlloc = sizeof(void*) * 8; BlocksAllocator(); ~BlocksAllocator(); @@ -1480,14 +1491,14 @@ template <typename NumberT, typename ObjectT, typename BoundingBoxExtractorT> template <typename NumberT, typename ObjectT, typename BoundingBoxExtractorT> LooseQuadtree<NumberT, ObjectT, BoundingBoxExtractorT>::Query:: -Query(Query&& other) : pimpl_(other.pimpl_) { +Query(Query&& other) noexcept : pimpl_(other.pimpl_) { other.pimpl_ = nullptr; } template <typename NumberT, typename ObjectT, typename BoundingBoxExtractorT> auto LooseQuadtree<NumberT, ObjectT, BoundingBoxExtractorT>::Query:: -operator=(Query&& other) -> Query& { +operator=(Query&& other) noexcept -> Query& { this->~Query(); pimpl_ = other.pimpl_; other.pimpl_ = nullptr; @@ -1520,4 +1531,13 @@ Next() { } //loose_quadtree +#ifdef __GNUG__ +#pragma GCC diagnostic pop +#endif +#if defined __clang__ || defined __CLION_IDE__ +#pragma clang diagnostic pop +#endif + +#undef assert + #endif //LOOSEQUADTREE_LOOSEQUADTREE_IMPL_H diff --git a/compat/LooseQuadtree.h b/compat/LooseQuadtree.h index a27c482d..90ad0aee 100644 --- a/compat/LooseQuadtree.h +++ b/compat/LooseQuadtree.h @@ -71,8 +71,8 @@ public: Query() = delete; Query(const Query&) = delete; Query& operator=(const Query&) = delete; - Query(Query&&); - Query& operator=(Query&&); + Query(Query&&) noexcept; + Query& operator=(Query&&) noexcept; bool EndOfQuery() const; Object* GetCurrent() const; @@ -85,8 +85,8 @@ public: Impl* pimpl_; }; - LooseQuadtree() {} - ~LooseQuadtree() {} + LooseQuadtree() = default; + ~LooseQuadtree() = default; LooseQuadtree(const LooseQuadtree&) = delete; LooseQuadtree& operator=(const LooseQuadtree&) = delete; @@ -113,6 +113,4 @@ private: } //loose_quadtree -#include "LooseQuadtree-impl.h" - #endif //LOOSEQUADTREE_LOOSEQUADTREE_H diff --git a/test/LooseQuadtreeTest.cpp b/test/LooseQuadtreeTest.cpp index ca1e935d..3e19891b 100644 --- a/test/LooseQuadtreeTest.cpp +++ b/test/LooseQuadtreeTest.cpp @@ -1,20 +1,24 @@ -#include "LooseQuadtree.h" +#if defined __GNUG__ || defined __CLION_IDE__ +#pragma GCC diagnostic ignored "-Wfloat-equal" +#endif +#ifdef _MSC_VER +#pragma warning(disable : 4244) +#endif +#define ASSERT fm_assert + +#include "compat/LooseQuadtree.h" +#include "compat/LooseQuadtree-impl.h" +#include "compat/assert.hpp" +#include "test/app.hpp" #include <chrono> -#include <cstdlib> #include <cstdio> #include <random> #include <vector> using namespace loose_quadtree; - - -#define ASSERT(CONDITION) if (!(CONDITION)) {\ - printf("Assertion failure %s:%d ASSERT(%s)\n", __FILE__, __LINE__, #CONDITION);\ - abort();\ - } - +namespace { template <typename NumberT> class TrivialBBExtractor { @@ -696,7 +700,8 @@ void StressTest() { template <typename NumberT> void RunTests(const char* type_str) { - printf("***** Running tests for %s (%lu-bit)... ", type_str, sizeof(NumberT) * 8); + printf("quadtree test %s (%zu-bit)... ", type_str, sizeof(NumberT) * 8); + fflush(stdout); auto start = std::chrono::high_resolution_clock::now(); TestBoundingBox<NumberT>(); TestTraversals<NumberT>(); @@ -706,13 +711,17 @@ void RunTests(const char* type_str) { auto end = std::chrono::high_resolution_clock::now(); std::chrono::duration<double> time = end - start; printf("took %f seconds\n", time.count()); + fflush(stdout); } +} // namespace +namespace floormat { -int main(int, char*[]) { +void test_app::test_quadtree() +{ puts("***** Testing is about to start *****"); - printf("***** This system is %lu-bit\n", sizeof(void*) * 8); + printf("***** This system is %zu-bit\n", sizeof(void*) * 8); RunTests<float>("float"); RunTests<double>("double"); RunTests<long double>("long double"); @@ -724,6 +733,6 @@ int main(int, char*[]) { RunTests<unsigned short>("unsigned short"); RunTests<long long>("long long"); puts("***** Testing is successfully finished *****"); - return 0; } +} // namespace floormat diff --git a/test/app.hpp b/test/app.hpp index 7365e093..94b6e506 100644 --- a/test/app.hpp +++ b/test/app.hpp @@ -24,5 +24,6 @@ struct test_app final : private FM_APPLICATION static void test_const_math(); static void test_serializer(); static void test_entity(); + static void test_quadtree(); }; } // namespace floormat diff --git a/test/main.cpp b/test/main.cpp index 72f21555..15654ad2 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -24,6 +24,7 @@ int test_app::exec() test_const_math(); test_serializer(); test_entity(); + test_quadtree(); return 0; } |