Skip to content
Snippets Groups Projects
Commit b89cdad0 authored by florian's avatar florian
Browse files

ENH: Finish primitive entity setters and getters

parent aeccddd2
No related branches found
No related tags found
3 merge requests!12F consolidation,!9Draft: API: remove UniqueResult, lower-case at, size for ResultSet,!8ENH: Add retrieval and queries to Extern C interface
This commit is part of merge request !8. Comments created here will be created in the context of that merge request.
......@@ -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));)
}
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment