From d6f573ffbd4cfc0d6fb47e4369905991bbbfc125 Mon Sep 17 00:00:00 2001
From: Timm Fitschen <t.fitschen@indiscale.com>
Date: Mon, 4 Oct 2021 15:33:31 +0200
Subject: [PATCH] more tests for moving entities

---
 include/caosdb/data_type.h |  6 +++---
 include/caosdb/entity.h    |  9 +++++----
 test/test_entity.cpp       | 18 ++++++++++++------
 3 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/include/caosdb/data_type.h b/include/caosdb/data_type.h
index 45d82f0..c084a33 100644
--- a/include/caosdb/data_type.h
+++ b/include/caosdb/data_type.h
@@ -246,10 +246,10 @@ public:
    * Copy assignment operator.
    */
   inline auto operator=(const DataType &other) -> DataType & {
-    if(this != &other) {
+    if (this != &other) {
       this->reference_data_type.reset();
       this->list_data_type.reset();
-      if(other.wrapped != nullptr) {
+      if (other.wrapped != nullptr) {
         this->wrapped = ProtoMessageWrapper<ProtoDataType>::CopyProtoMessage(other.wrapped);
       } else {
         this->wrapped = nullptr;
@@ -262,7 +262,7 @@ public:
    * Move assignment operator.
    */
   inline auto operator=(DataType &&other) -> DataType & {
-    if(this != &other) {
+    if (this != &other) {
       this->wrapped = other.wrapped;
       other.wrapped = nullptr;
       other.reference_data_type.reset();
diff --git a/include/caosdb/entity.h b/include/caosdb/entity.h
index c261c1c..2f6e4ed 100644
--- a/include/caosdb/entity.h
+++ b/include/caosdb/entity.h
@@ -191,10 +191,11 @@ public:
    * Return true if the underlying Protobuf messages have the same
    * serialization.
    */
-  inline auto operator==(const RepeatedPtrFieldWrapper<T,P> &other) const noexcept -> bool {
+  inline auto operator==(const RepeatedPtrFieldWrapper<T, P> &other) const noexcept -> bool {
     if (this->wrapped != nullptr && other.wrapped != nullptr && this->size() == other.size()) {
-      for(int i = 0; i < this->size(); i++) {
-        if(this->wrapped->Get(i).SerializeAsString() != other.wrapped->Get(i).SerializeAsString()) {
+      for (int i = 0; i < this->size(); i++) {
+        if (this->wrapped->Get(i).SerializeAsString() !=
+            other.wrapped->Get(i).SerializeAsString()) {
           return false;
         }
       }
@@ -208,7 +209,7 @@ public:
    * Return true if the underlying Protobuf messages have a different
    * serialization.
    */
-  inline auto operator!=(const RepeatedPtrFieldWrapper<T,P> &other) const noexcept -> bool {
+  inline auto operator!=(const RepeatedPtrFieldWrapper<T, P> &other) const noexcept -> bool {
     return !(*this == other);
   }
 
diff --git a/test/test_entity.cpp b/test/test_entity.cpp
index f800d5a..2b9a8d9 100644
--- a/test/test_entity.cpp
+++ b/test/test_entity.cpp
@@ -152,16 +152,19 @@ TEST(test_entity, test_copy_constructor) {
   property.set_description("the prop-desc");
   property.set_name("the-prop-name");
   property.mutable_value()->mutable_list_values()->mutable_values()->Add()->set_double_value(25.5);
-  property.mutable_data_type()->mutable_list_data_type()->set_atomic_data_type(ProtoAtomicDataType::ATOMIC_DATA_TYPE_DOUBLE);
+  property.mutable_data_type()->mutable_list_data_type()->set_atomic_data_type(
+    ProtoAtomicDataType::ATOMIC_DATA_TYPE_DOUBLE);
   EntityResponse entity_response;
   entity_response.mutable_entity()->set_id("the-id");
   entity_response.mutable_entity()->set_name("the-name");
   entity_response.mutable_entity()->set_role(ProtoEntityRole::ENTITY_ROLE_RECORD);
   entity_response.mutable_entity()->set_description("the description");
   entity_response.mutable_entity()->set_unit("the-unit");
-  entity_response.mutable_entity()->mutable_value()->mutable_scalar_value()->set_string_value("the-value");
+  entity_response.mutable_entity()->mutable_value()->mutable_scalar_value()->set_string_value(
+    "the-value");
   entity_response.mutable_entity()->mutable_version()->set_id("version-id");
-  entity_response.mutable_entity()->mutable_data_type()->mutable_reference_data_type()->set_name("refname");
+  entity_response.mutable_entity()->mutable_data_type()->mutable_reference_data_type()->set_name(
+    "refname");
   entity_response.mutable_entity()->mutable_file_descriptor();
   entity_response.mutable_entity()->mutable_properties()->Add()->CopyFrom(property);
   entity_response.mutable_entity()->mutable_parents()->Add()->CopyFrom(parent);
@@ -204,7 +207,8 @@ TEST(test_entity, test_move_constructor) {
   property.set_description("the prop-desc");
   property.set_name("the-prop-name");
   property.mutable_value()->mutable_list_values()->mutable_values()->Add()->set_double_value(25.5);
-  property.mutable_data_type()->mutable_list_data_type()->set_atomic_data_type(ProtoAtomicDataType::ATOMIC_DATA_TYPE_DOUBLE);
+  property.mutable_data_type()->mutable_list_data_type()->set_atomic_data_type(
+    ProtoAtomicDataType::ATOMIC_DATA_TYPE_DOUBLE);
   EntityResponse entity_response;
   entity_response.mutable_errors()->Add()->set_code(25);
   entity_response.mutable_errors()->Mutable(0)->set_description("asdf");
@@ -217,9 +221,11 @@ TEST(test_entity, test_move_constructor) {
   entity_response.mutable_entity()->set_role(ProtoEntityRole::ENTITY_ROLE_RECORD);
   entity_response.mutable_entity()->set_description("the description");
   entity_response.mutable_entity()->set_unit("the-unit");
-  entity_response.mutable_entity()->mutable_value()->mutable_scalar_value()->set_string_value("the-value");
+  entity_response.mutable_entity()->mutable_value()->mutable_scalar_value()->set_string_value(
+    "the-value");
   entity_response.mutable_entity()->mutable_version()->set_id("version-id");
-  entity_response.mutable_entity()->mutable_data_type()->mutable_reference_data_type()->set_name("refname");
+  entity_response.mutable_entity()->mutable_data_type()->mutable_reference_data_type()->set_name(
+    "refname");
   entity_response.mutable_entity()->mutable_file_descriptor();
   entity_response.mutable_entity()->mutable_properties()->Add()->CopyFrom(property);
   entity_response.mutable_entity()->mutable_parents()->Add()->CopyFrom(parent);
-- 
GitLab