Sfoglia il codice sorgente

*: another handful of changes to please clang-format

Michele Caini 4 anni fa
parent
commit
be5ad379b6

+ 4 - 12
test/benchmark/benchmark.cpp

@@ -1260,9 +1260,7 @@ TEST(Benchmark, SortSingle) {
 
     timer timer;
 
-    registry.sort<position>([](const auto &lhs, const auto &rhs) {
-        return lhs.x < rhs.x && lhs.y < rhs.y;
-    });
+    registry.sort<position>([](const auto &lhs, const auto &rhs) { return lhs.x < rhs.x && lhs.y < rhs.y; });
 
     timer.elapsed();
 }
@@ -1278,9 +1276,7 @@ TEST(Benchmark, SortMulti) {
         registry.emplace<velocity>(entity, i, i);
     }
 
-    registry.sort<position>([](const auto &lhs, const auto &rhs) {
-        return lhs.x < rhs.x && lhs.y < rhs.y;
-    });
+    registry.sort<position>([](const auto &lhs, const auto &rhs) { return lhs.x < rhs.x && lhs.y < rhs.y; });
 
     timer timer;
 
@@ -1312,9 +1308,7 @@ TEST(Benchmark, AlmostSortedStdSort) {
 
     timer timer;
 
-    registry.sort<position>([](const auto &lhs, const auto &rhs) {
-        return lhs.x > rhs.x && lhs.y > rhs.y;
-    });
+    registry.sort<position>([](const auto &lhs, const auto &rhs) { return lhs.x > rhs.x && lhs.y > rhs.y; });
 
     timer.elapsed();
 }
@@ -1342,9 +1336,7 @@ TEST(Benchmark, AlmostSortedInsertionSort) {
 
     timer timer;
 
-    registry.sort<position>([](const auto &lhs, const auto &rhs) {
-        return lhs.x > rhs.x && lhs.y > rhs.y;
-    }, entt::insertion_sort{});
+    registry.sort<position>([](const auto &lhs, const auto &rhs) { return lhs.x > rhs.x && lhs.y > rhs.y; }, entt::insertion_sort{});
 
     timer.elapsed();
 }

+ 2 - 0
test/entt/core/any.cpp

@@ -8,6 +8,7 @@
 
 struct empty {
     ~empty() { ++counter; }
+
     inline static int counter = 0;
 };
 
@@ -1144,6 +1145,7 @@ TEST_F(Any, Alignment) {
 
 TEST_F(Any, AggregatesMustWork) {
     struct aggregate_type { int value; };
+
     // the goal of this test is to enforce the requirements for aggregate types
     entt::any{std::in_place_type<aggregate_type>, 42}.emplace<aggregate_type>(42);
 }

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

@@ -8,6 +8,7 @@ struct empty_type {};
 
 struct move_only_type {
     move_only_type(): value{new int{99}} {}
+
     move_only_type(int v): value{new int{v}} {}
 
     ~move_only_type() { delete value; }
@@ -30,6 +31,7 @@ struct move_only_type {
 
 struct non_default_constructible {
     non_default_constructible(int v): value{v} {}
+
     int value;
 };
 

+ 11 - 4
test/entt/core/type_traits.cpp

@@ -14,6 +14,7 @@ struct not_comparable {
 
 struct nlohmann_json_like {
     using value_type = nlohmann_json_like;
+
     bool operator==(const nlohmann_json_like &) const { return true; }
 };
 
@@ -25,17 +26,21 @@ TEST(TypeTraits, SizeOf) {
 }
 
 TEST(TypeTraits, UnpackAsType) {
-    ASSERT_EQ([](auto &&... args) {
+    auto test = [](auto &&...args) {
         return [](entt::unpack_as_t<int, decltype(args)>... value) {
             return (value + ... + 0);
         };
-    }('c', 42., true)(1, 2, 3), 6);
+    };
+
+    ASSERT_EQ(test('c', 42., true)(1, 2, 3), 6);
 }
 
 TEST(TypeTraits, UnpackAsValue) {
-    ASSERT_EQ([](auto &&... args) {
+    auto test = [](auto &&...args) {
         return (entt::unpack_as_v<2, decltype(args)> + ... + 0);
-    }('c', 42., true), 6);
+    };
+
+    ASSERT_EQ(test('c', 42., true), 6);
 }
 
 TEST(TypeTraits, IntegralConstant) {
@@ -156,7 +161,9 @@ TEST(TypeTraits, ConstnessAs) {
 TEST(TypeTraits, MemberClass) {
     struct clazz {
         char foo(int) { return {}; }
+
         int bar(double, float) const { return {}; }
+
         bool quux;
     };
 

+ 1 - 0
test/entt/entity/group.cpp

@@ -7,6 +7,7 @@
 #include <entt/entity/group.hpp>
 
 struct empty_type {};
+
 struct boxed_int { int value; };
 
 bool operator==(const boxed_int &lhs, const boxed_int &rhs) {

+ 1 - 0
test/entt/entity/helper.cpp

@@ -7,6 +7,7 @@
 
 struct clazz {
     void func(entt::registry &, entt::entity curr) { entt = curr; }
+
     entt::entity entt{entt::null};
 };
 

+ 10 - 6
test/entt/entity/observer.cpp

@@ -37,7 +37,8 @@ TEST(Observer, Functionalities) {
 }
 
 TEST(Observer, AllOf) {
-    constexpr auto collector =  entt::collector
+    constexpr auto collector =
+        entt::collector
             .group<int, char>(entt::exclude<float>)
             .group<int, double>();
 
@@ -85,7 +86,8 @@ TEST(Observer, AllOf) {
 }
 
 TEST(Observer, AllOfFiltered) {
-    constexpr auto collector =  entt::collector
+    constexpr auto collector =
+        entt::collector
             .group<int>().where<char>(entt::exclude<double>);
 
     entt::registry registry;
@@ -164,7 +166,8 @@ TEST(Observer, Observe) {
 }
 
 TEST(Observer, ObserveFiltered) {
-    constexpr auto collector =  entt::collector
+    constexpr auto collector =
+        entt::collector
             .update<int>().where<char>(entt::exclude<double>);
 
     entt::registry registry;
@@ -282,7 +285,8 @@ TEST(Observer, Each) {
 }
 
 TEST(Observer, MultipleFilters) {
-    constexpr auto collector =  entt::collector
+    constexpr auto collector =
+        entt::collector
             .update<int>().where<char>()
             .update<double>().where<float>();
 
@@ -338,8 +342,8 @@ TEST(Observer, MultipleFilters) {
 }
 
 TEST(Observer, GroupCornerCase) {
-    constexpr auto add_collector =  entt::collector.group<int>(entt::exclude<char>);
-    constexpr auto remove_collector =  entt::collector.group<int, char>();
+    constexpr auto add_collector = entt::collector.group<int>(entt::exclude<char>);
+    constexpr auto remove_collector = entt::collector.group<int, char>();
 
     entt::registry registry;
     entt::observer add_observer{registry, add_collector};

+ 11 - 9
test/entt/entity/poly_storage.cpp

@@ -8,15 +8,17 @@ template<typename... Type>
 entt::type_list<Type...> as_type_list(const entt::type_list<Type...> &);
 
 template<typename Entity>
-struct PolyStorage: entt::type_list_cat_t<
-    decltype(as_type_list(std::declval<entt::Storage<Entity>>())),
-    entt::type_list<
-        void(const Entity *, const Entity *, void *),
-        void(entt::basic_registry<Entity> &, const Entity, const void *),
-        const void *(const Entity) const,
-        void(entt::basic_registry<Entity> &) const
-    >
-> {
+struct PolyStorage
+    : entt::type_list_cat_t<
+          decltype(as_type_list(std::declval<entt::Storage<Entity>>())),
+          entt::type_list<
+              void(const Entity *, const Entity *, void *),
+              void(entt::basic_registry<Entity> &, const Entity, const void *),
+              const void *(const Entity) const,
+              void(entt::basic_registry<Entity> &) const
+          >
+      >
+{
     using entity_type = Entity;
     using size_type = std::size_t;
 

+ 2 - 0
test/entt/entity/registry.cpp

@@ -11,6 +11,7 @@
 #include <entt/entity/registry.hpp>
 
 struct empty_type {};
+
 struct stable_type { int value; };
 
 template<>
@@ -20,6 +21,7 @@ struct entt::component_traits<stable_type>: basic_component_traits {
 
 struct non_default_constructible {
     non_default_constructible(int v): value{v} {}
+
     int value;
 };
 

+ 2 - 0
test/entt/entity/sigh_storage_mixin.cpp

@@ -10,7 +10,9 @@ struct stable_type { int value; };
 
 struct non_default_constructible {
     non_default_constructible() = delete;
+
     non_default_constructible(int v): value{v} {}
+
     int value;
 };
 

+ 1 - 0
test/entt/entity/sparse_set.cpp

@@ -10,6 +10,7 @@
 #include "throwing_allocator.hpp"
 
 struct empty_type {};
+
 struct boxed_int { int value; };
 
 TEST(SparseSet, Functionalities) {

+ 5 - 0
test/entt/entity/storage.cpp

@@ -11,12 +11,16 @@
 #include "throwing_component.hpp"
 
 struct empty_type {};
+
 struct boxed_int { int value; };
+
 struct stable_type { int value; };
 
 struct non_default_constructible {
     non_default_constructible() = delete;
+
     non_default_constructible(int v): value{v} {}
+
     int value;
 };
 
@@ -716,6 +720,7 @@ TEST(Storage, ShrinkToFit) {
 
 TEST(Storage, AggregatesMustWork) {
     struct aggregate_type { int value; };
+
     // the goal of this test is to enforce the requirements for aggregate types
     entt::storage<aggregate_type>{}.emplace(entt::entity{0}, 42);
 }

+ 1 - 0
test/entt/entity/view.cpp

@@ -8,6 +8,7 @@
 #include <entt/entity/view.hpp>
 
 struct empty_type {};
+
 struct stable_type { int value; };
 
 template<>

+ 1 - 0
test/entt/locator/locator.cpp

@@ -11,6 +11,7 @@ struct another_service {
 
 struct derived_service: another_service {
     derived_service(int): another_service{} {}
+
     void f(bool b) override { check = b; }
 };
 

+ 2 - 0
test/entt/meta/meta_any.cpp

@@ -10,7 +10,9 @@ struct clazz_t {
     clazz_t(): value{0} {}
 
     void member(int i) { value = i; }
+
     static void func() { c = 'd'; }
+
     operator int() const { return value; }
 
     static inline char c = 'c';

+ 2 - 0
test/entt/meta/meta_conv.cpp

@@ -7,7 +7,9 @@
 
 struct clazz_t {
     clazz_t() = default;
+
     operator int() const { return value; }
+
     int value;
 };
 

+ 1 - 0
test/entt/meta/meta_ctor.cpp

@@ -8,6 +8,7 @@
 
 struct base_t {
     base_t(): value{'c'} {}
+
     char value;
 };
 

+ 3 - 0
test/entt/meta/meta_handle.cpp

@@ -6,8 +6,11 @@
 
 struct clazz_t {
     clazz_t(): value{} {}
+
     void incr() { ++value; }
+
     void decr() { --value; }
+
     int value;
 };
 

+ 7 - 0
test/entt/meta/meta_pointer.cpp

@@ -9,6 +9,7 @@
 template<typename Type>
 struct wrapped_shared_ptr {
     wrapped_shared_ptr(Type init): ptr{new Type {init}} {}
+
     Type & deref() const { return *ptr; }
 
 private:
@@ -17,15 +18,21 @@ private:
 
 struct self_ptr {
     using element_type = self_ptr;
+
     self_ptr(int v): value{v} {}
+
     const self_ptr & operator*() const { return *this; }
+
     int value;
 };
 
 struct proxy_ptr {
     using element_type = proxy_ptr;
+
     proxy_ptr(int &v): value{&v} {}
+
     proxy_ptr operator*() const { return *this; }
+
     int *value;
 };
 

+ 11 - 2
test/entt/meta/meta_type.cpp

@@ -21,11 +21,19 @@ Type get(Type &prop) {
     return prop;
 }
 
-struct base_t { base_t(): value{'c'} {}; char value; };
-struct derived_t: base_t { 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) {}
 };
 
@@ -47,6 +55,7 @@ struct clazz_t {
 
     void member() {}
     static void func() {}
+
     operator int() const { return value; }
 
     int value;

+ 15 - 1
test/entt/poly/poly_deduced.cpp

@@ -4,19 +4,26 @@
 #include <entt/core/type_traits.hpp>
 #include <entt/poly/poly.hpp>
 
-struct Deduced: entt::type_list<> {
+struct Deduced
+    : entt::type_list<>
+{
     template<typename Base>
     struct type: Base {
         void incr() { entt::poly_call<0>(*this); }
+
         void set(int v) { entt::poly_call<1>(*this, v); }
+
         int get() const { return entt::poly_call<2>(*this); }
+
         void decr() { entt::poly_call<3>(*this); }
+
         int mul(int v) const { return static_cast<int>(entt::poly_call<4>(*this, v)); }
     };
 
     template<typename Type>
     struct members {
         static void decr(Type &self) { self.set(self.get()-1); }
+
         static double mul(const Type &self, double v) { return v * self.get(); }
     };
 
@@ -32,12 +39,19 @@ struct Deduced: entt::type_list<> {
 
 struct impl {
     impl() = default;
+
     impl(int v): value{v} {}
+
     void incr() { ++value; }
+
     void set(int v) { value = v; }
+
     int get() const { return value; }
+
     void decrement() { --value; }
+
     double multiply(double v) const { return v * value; }
+
     int value{};
 };
 

+ 21 - 7
test/entt/poly/poly_defined.cpp

@@ -4,25 +4,32 @@
 #include <entt/core/type_traits.hpp>
 #include <entt/poly/poly.hpp>
 
-struct Defined: entt::type_list<
-    void(),
-    void(int),
-    int() const,
-    void(),
-    int(int) const
-> {
+struct Defined
+    : entt::type_list<
+        void(),
+        void(int),
+        int() const,
+        void(),
+        int(int) const
+      >
+{
     template<typename Base>
     struct type: Base {
         void incr() { entt::poly_call<0>(*this); }
+
         void set(int v) { entt::poly_call<1>(*this, v); }
+
         int get() const { return entt::poly_call<2>(*this); }
+
         void decr() { entt::poly_call<3>(*this); }
+
         int mul(int v) const { return entt::poly_call<4>(*this, v); }
     };
 
     template<typename Type>
     struct members {
         static void decr(Type &self) { self.decrement(); }
+
         static double mul(const Type &self, double v) { return self.multiply(v); }
     };
 
@@ -38,12 +45,19 @@ struct Defined: entt::type_list<
 
 struct impl {
     impl() = default;
+
     impl(int v): value{v} {}
+
     void incr() { ++value; }
+
     void set(int v) { value = v; }
+
     int get() const { return value; }
+
     void decrement() { --value; }
+
     double multiply(double v) const { return v * value; }
+
     int value{};
 };
 

+ 6 - 0
test/entt/process/process.cpp

@@ -18,13 +18,19 @@ struct fake_process: entt::process<fake_process<Delta>, Delta> {
     {}
 
     void succeed() noexcept { process_type::succeed(); }
+
     void fail() noexcept { process_type::fail(); }
+
     void pause() noexcept { process_type::pause(); }
+
     void unpause() noexcept { process_type::unpause(); }
 
     void init() { init_invoked = true; }
+
     void succeeded() { succeeded_invoked = true; }
+
     void failed() { failed_invoked = true; }
+
     void aborted() { aborted_invoked = true; }
 
     void update(typename entt::process<fake_process<Delta>, Delta>::delta_type, void *data) {

+ 10 - 3
test/entt/process/scheduler.cpp

@@ -9,6 +9,7 @@ struct foo_process: entt::process<foo_process, int> {
     {}
 
     void update(delta_type, void *) { on_update(); }
+
     void aborted() { on_aborted(); }
 
     std::function<void()> on_update;
@@ -103,15 +104,21 @@ TEST(Scheduler, Functor) {
     bool first_functor = false;
     bool second_functor = false;
 
-    scheduler.attach([&first_functor](auto, void *, auto resolve, auto){
+    auto attach = [&first_functor](auto, void *, auto resolve, auto) {
         ASSERT_FALSE(first_functor);
         first_functor = true;
         resolve();
-    }).then([&second_functor](auto, void *, auto, auto reject){
+    };
+
+    auto then = [&second_functor](auto, void *, auto, auto reject) {
         ASSERT_FALSE(second_functor);
         second_functor = true;
         reject();
-    }).then([](auto...){ FAIL(); });
+    };
+
+    auto fail = [](auto...) { FAIL(); };
+
+    scheduler.attach(std::move(attach)).then(std::move(then)).then(std::move(fail));
 
     for(auto i = 0; i < 8; ++i) {
         scheduler.update(0);

+ 1 - 0
test/entt/resource/resource.cpp

@@ -4,6 +4,7 @@
 #include <entt/resource/cache.hpp>
 
 struct resource { int value; };
+
 struct derived_resource: resource {};
 
 template<typename Resource>

+ 5 - 3
test/entt/signal/delegate.cpp

@@ -37,9 +37,13 @@ struct delegate_functor {
 
 struct const_nonconst_noexcept {
     void f() { ++cnt; }
+
     void g() noexcept { ++cnt; }
+
     void h() const { ++cnt; }
+
     void i() const noexcept { ++cnt; }
+
     int u{};
     const int v{};
     mutable int cnt{0};
@@ -60,9 +64,7 @@ TEST(Delegate, Functionalities) {
 
     ff_del.connect<&delegate_function>();
     mf_del.connect<&delegate_functor::operator()>(functor);
-    lf_del.connect([](const void *ptr, int value) {
-        return static_cast<const delegate_functor *>(ptr)->identity(value);
-    }, &functor);
+    lf_del.connect([](const void *ptr, int value) { return static_cast<const delegate_functor *>(ptr)->identity(value); }, &functor);
 
     ASSERT_TRUE(ff_del);
     ASSERT_TRUE(mf_del);

+ 3 - 0
test/entt/signal/dispatcher.cpp

@@ -5,6 +5,7 @@
 
 struct an_event {};
 struct another_event {};
+
 // makes the type non-aggregate
 struct one_more_event { one_more_event(int) {} };
 
@@ -14,7 +15,9 @@ struct receiver {
     }
 
     void receive(const an_event &) { ++cnt; }
+
     void reset() { cnt = 0; }
+
     int cnt{0};
 };
 

+ 1 - 0
test/entt/signal/emitter.cpp

@@ -5,6 +5,7 @@
 struct test_emitter: entt::emitter<test_emitter> {};
 
 struct foo_event { int i; char c; };
+
 struct bar_event {};
 struct quux_event {};
 

+ 23 - 9
test/entt/signal/sigh.cpp

@@ -7,9 +7,11 @@ struct sigh_listener {
     static void f(int &v) { v = 42; }
 
     bool g(int) { k = !k; return true; }
+
     bool h(const int &) { return k; }
 
     void i() {}
+
     // useless definition just because msvc does weird things if both are empty
     void l() { k = true && k; }
 
@@ -18,9 +20,11 @@ struct sigh_listener {
 
 struct before_after {
     void add(int v) { value += v; }
+
     void mul(int v) { value *= v; }
 
     static void static_add(int v) { before_after::value += v; }
+
     static void static_mul(before_after &instance, int v) { instance.value *= v; }
 
     static inline int value{};
@@ -34,9 +38,13 @@ struct SigH: ::testing::Test {
 
 struct const_nonconst_noexcept {
     void f() { ++cnt; }
+
     void g() noexcept { ++cnt; }
+
     void h() const { ++cnt; }
+
     void i() const noexcept { ++cnt; }
+
     mutable int cnt{0};
 };
 
@@ -191,23 +199,27 @@ TEST_F(SigH, Collector) {
     sink.connect<&sigh_listener::g>(&listener);
     sink.connect<&sigh_listener::h>(listener);
 
-    listener.k = true;
-    sigh.collect([&listener, &cnt](bool value) {
+    auto test_1 = [&listener, &cnt](bool value) {
         ASSERT_TRUE(value);
         listener.k = true;
         ++cnt;
-    }, 42);
+    };
+
+    listener.k = true;
+    sigh.collect(std::move(test_1), 42);
 
     ASSERT_FALSE(sigh.empty());
     ASSERT_EQ(cnt, 2);
 
-    cnt = 0;
-    sigh.collect([&cnt](bool value) {
+    auto test_2 = [&cnt](bool value) {
         // gtest and its macro hell are sometimes really annoying...
         [](auto v) { ASSERT_TRUE(v); }(value);
         ++cnt;
         return true;
-    }, 42);
+    };
+
+    cnt = 0;
+    sigh.collect(std::move(test_1), 42);
 
     ASSERT_EQ(cnt, 1);
 }
@@ -225,11 +237,13 @@ TEST_F(SigH, CollectorVoid) {
     ASSERT_FALSE(sigh.empty());
     ASSERT_EQ(cnt, 2);
 
-    cnt = 0;
-    sigh.collect([&cnt]() {
+    auto test = [&cnt]() {
         ++cnt;
         return true;
-    }, 42);
+    };
+
+    cnt = 0;
+    sigh.collect(std::move(test), 42);
 
     ASSERT_EQ(cnt, 1);
 }

+ 1 - 0
test/lib/dispatcher/main.cpp

@@ -8,6 +8,7 @@ ENTT_API void trigger(entt::dispatcher &);
 
 struct listener {
     void on(message msg) { value = msg.payload; }
+
     int value{};
 };