Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-cpplib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-cpplib
Commits
ec2eb3eb
Commit
ec2eb3eb
authored
3 years ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Add removal of parents and properties to Extern C
parent
aaedb0ed
No related branches found
No related tags found
3 merge requests
!12
F consolidation
,
!9
Draft: API: remove UniqueResult, lower-case at, size for ResultSet
,
!8
ENH: Add retrieval and queries to Extern C interface
Pipeline
#11854
passed
3 years ago
Stage: info
Stage: setup
Stage: test
Stage: deploy
Pipeline: caosdb-cppinttest
#11860
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/ccaosdb.h
+3
-0
3 additions, 0 deletions
include/ccaosdb.h
src/ccaosdb.cpp
+21
-0
21 additions, 0 deletions
src/ccaosdb.cpp
test/test_ccaosdb.cpp
+63
-0
63 additions, 0 deletions
test/test_ccaosdb.cpp
with
87 additions
and
0 deletions
include/ccaosdb.h
+
3
−
0
View file @
ec2eb3eb
...
...
@@ -404,8 +404,11 @@ int caosdb_entity_entity_set_value(caosdb_entity_entity *entity,
const
char
*
value
);
int
caosdb_entity_entity_append_parent
(
caosdb_entity_entity
*
entity
,
caosdb_entity_parent
*
parent
);
int
caosdb_entity_entity_remove_parent
(
caosdb_entity_entity
*
entity
,
int
index
);
int
caosdb_entity_entity_append_property
(
caosdb_entity_entity
*
entity
,
caosdb_entity_property
*
property
);
int
caosdb_entity_entity_remove_property
(
caosdb_entity_entity
*
entity
,
int
index
);
int
caosdb_entity_property_set_id
(
caosdb_entity_property
*
property
,
const
char
*
id
);
...
...
This diff is collapsed.
Click to expand it.
src/ccaosdb.cpp
+
21
−
0
View file @
ec2eb3eb
...
...
@@ -769,6 +769,17 @@ ERROR_RETURN_CODE(
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_remove_parent
(
caosdb_entity_entity
*
entity
,
int
index
),
{
auto
*
wrapped_entity
=
static_cast
<
caosdb
::
entity
::
Entity
*>
(
entity
->
wrapped_entity
);
wrapped_entity
->
RemoveParent
(
index
);
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_append_property
(
caosdb_entity_entity
*
entity
,
...
...
@@ -781,6 +792,16 @@ ERROR_RETURN_CODE(
wrapped_entity
->
AppendProperty
(
*
wrapped_property
);
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_remove_property
(
caosdb_entity_entity
*
entity
,
int
index
),
{
auto
*
wrapped_entity
=
static_cast
<
caosdb
::
entity
::
Entity
*>
(
entity
->
wrapped_entity
);
wrapped_entity
->
RemoveProperty
(
index
);
return
0
;
})
CAOSDB_PARENT_SET
(
id
,
id
,
wrapped_parent
->
SetId
(
std
::
string
(
id
));)
CAOSDB_PARENT_SET
(
name
,
name
,
wrapped_parent
->
SetName
(
std
::
string
(
name
));)
...
...
This diff is collapsed.
Click to expand it.
test/test_ccaosdb.cpp
+
63
−
0
View file @
ec2eb3eb
...
...
@@ -347,3 +347,66 @@ TEST_F(test_ccaosdb, test_entity_with_parent_and_property) {
return_code
=
caosdb_entity_delete_property
(
&
output_property
);
EXPECT_EQ
(
return_code
,
0
);
}
TEST_F
(
test_ccaosdb
,
test_remove_property
)
{
caosdb_entity_entity
entity
;
int
return_code
(
caosdb_entity_create_entity
(
&
entity
));
EXPECT_EQ
(
return_code
,
0
);
// Create two properties with names
caosdb_entity_property
in_prop_1
;
return_code
=
caosdb_entity_create_property
(
&
in_prop_1
);
EXPECT_EQ
(
return_code
,
0
);
return_code
=
caosdb_entity_property_set_name
(
&
in_prop_1
,
"Property 1"
);
EXPECT_EQ
(
return_code
,
0
);
caosdb_entity_property
in_prop_2
;
return_code
=
caosdb_entity_create_property
(
&
in_prop_2
);
EXPECT_EQ
(
return_code
,
0
);
return_code
=
caosdb_entity_property_set_name
(
&
in_prop_2
,
"Property 2"
);
EXPECT_EQ
(
return_code
,
0
);
// Append them
return_code
=
caosdb_entity_entity_append_property
(
&
entity
,
&
in_prop_1
);
EXPECT_EQ
(
return_code
,
0
);
return_code
=
caosdb_entity_entity_append_property
(
&
entity
,
&
in_prop_2
);
EXPECT_EQ
(
return_code
,
0
);
// Delete one and see that the number of properties decreases by one
int
count
[]
=
{
0
};
// NOLINT
return_code
=
caosdb_entity_entity_get_properties_size
(
&
entity
,
count
);
EXPECT_EQ
(
return_code
,
0
);
EXPECT_EQ
(
*
count
,
2
);
return_code
=
caosdb_entity_entity_remove_property
(
&
entity
,
0
);
EXPECT_EQ
(
return_code
,
0
);
return_code
=
caosdb_entity_entity_get_properties_size
(
&
entity
,
count
);
EXPECT_EQ
(
return_code
,
0
);
EXPECT_EQ
(
*
count
,
1
);
caosdb_entity_property
out_prop
;
return_code
=
caosdb_entity_entity_get_property
(
&
entity
,
&
out_prop
,
0
);
EXPECT_EQ
(
return_code
,
0
);
char
in
[
255
]
=
{
"a"
};
// NOLINT
char
out
[
255
]
=
{
"b"
};
// NOLINT
// Deleted the first property, so the second one should remain.
return_code
=
caosdb_entity_property_get_name
(
&
in_prop_2
,
in
);
EXPECT_EQ
(
return_code
,
0
);
return_code
=
caosdb_entity_property_get_name
(
&
out_prop
,
out
);
EXPECT_EQ
(
return_code
,
0
);
EXPECT_EQ
(
strcmp
(
in
,
out
),
0
);
// Delete everything we have created
return_code
=
caosdb_entity_delete_property
(
&
in_prop_2
);
EXPECT_EQ
(
return_code
,
0
);
return_code
=
caosdb_entity_delete_property
(
&
in_prop_1
);
EXPECT_EQ
(
return_code
,
0
);
return_code
=
caosdb_entity_delete_entity
(
&
entity
);
EXPECT_EQ
(
return_code
,
0
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment