From b89cdad053ff45e7759a1561fced30b9d175527e Mon Sep 17 00:00:00 2001
From: florian <f.spreckelsen@inidscale.com>
Date: Tue, 10 Aug 2021 15:20:54 +0200
Subject: [PATCH] ENH: Finish primitive entity setters and getters

---
 src/ccaosdb.cpp       | 17 ++++++++++++++++-
 test/test_ccaosdb.cpp | 26 ++++++++++++++++++++++++--
 2 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/src/ccaosdb.cpp b/src/ccaosdb.cpp
index 8797474..c47562a 100644
--- a/src/ccaosdb.cpp
+++ b/src/ccaosdb.cpp
@@ -437,7 +437,22 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
                   })
 
 CAOSDB_ENTITY_GET(id, strcpy(out, wrapped_entity->GetId().c_str());)
+CAOSDB_ENTITY_GET(role, strcpy(out, wrapped_entity->GetRole().c_str());)
 CAOSDB_ENTITY_GET(name, strcpy(out, wrapped_entity->GetName().c_str());)
-
+CAOSDB_ENTITY_GET(description,
+                  strcpy(out, wrapped_entity->GetDescription().c_str());)
+CAOSDB_ENTITY_GET(datatype, strcpy(out, wrapped_entity->GetDatatype().c_str());)
+CAOSDB_ENTITY_GET(value, strcpy(out, wrapped_entity->GetValue().c_str());)
+CAOSDB_ENTITY_GET(unit, strcpy(out, wrapped_entity->GetUnit().c_str());)
+CAOSDB_ENTITY_GET(version_id,
+                  strcpy(out, wrapped_entity->GetVersionId().c_str());)
+
+CAOSDB_ENTITY_SET(role, role, wrapped_entity->SetRole(std::string(role));)
 CAOSDB_ENTITY_SET(name, name, wrapped_entity->SetName(std::string(name));)
+CAOSDB_ENTITY_SET(description, description,
+                  wrapped_entity->SetDescription(std::string(description));)
+CAOSDB_ENTITY_SET(datatype, datatype,
+                  wrapped_entity->SetDatatype(std::string(datatype));)
+CAOSDB_ENTITY_SET(unit, unit, wrapped_entity->SetUnit(std::string(unit));)
+CAOSDB_ENTITY_SET(value, value, wrapped_entity->SetValue(std::string(value));)
 }
diff --git a/test/test_ccaosdb.cpp b/test/test_ccaosdb.cpp
index 6043261..d9a49cb 100644
--- a/test/test_ccaosdb.cpp
+++ b/test/test_ccaosdb.cpp
@@ -146,12 +146,34 @@ TEST_F(test_ccaosdb, test_entity) {
   int return_code(caosdb_entity_create_entity(&entity));
   EXPECT_EQ(return_code, 0);
 
-  return_code = caosdb_entity_entity_set_name(&entity, "some_name");
+  // In-depth check for one pair of setter and getter, just compare
+  // the strings for the rest
+  return_code = caosdb_entity_entity_set_name(&entity, "length");
   EXPECT_EQ(return_code, 0);
   char out[255] = {"a"}; // NOLINT
   return_code = caosdb_entity_entity_get_name(&entity, out);
   EXPECT_EQ(return_code, 0);
-  EXPECT_EQ(strcmp(out, "some_name"), 0);
+  EXPECT_EQ(strcmp(out, "length"), 0);
+
+  caosdb_entity_entity_set_role(&entity, "Property");
+  caosdb_entity_entity_get_role(&entity, out);
+  EXPECT_EQ(strcmp(out, "Property"), 0);
+
+  caosdb_entity_entity_set_description(&entity, "The length of an object");
+  caosdb_entity_entity_get_description(&entity, out);
+  EXPECT_EQ(strcmp(out, "The length of an object"), 0);
+
+  caosdb_entity_entity_set_datatype(&entity, "DOUBLE");
+  caosdb_entity_entity_get_datatype(&entity, out);
+  EXPECT_EQ(strcmp(out, "DOUBLE"), 0);
+
+  caosdb_entity_entity_set_unit(&entity, "m");
+  caosdb_entity_entity_get_unit(&entity, out);
+  EXPECT_EQ(strcmp(out, "m"), 0);
+
+  caosdb_entity_entity_set_value(&entity, "5.0");
+  caosdb_entity_entity_get_value(&entity, out);
+  EXPECT_EQ(strcmp(out, "5.0"), 0);
 
   return_code = caosdb_entity_delete_entity(&entity);
   EXPECT_EQ(return_code, 0);
-- 
GitLab