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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-cpplib
Commits
cd50b367
Commit
cd50b367
authored
Sep 10, 2021
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
DRAFT: Remove code to be changed, add todos
parent
7125bcd7
No related branches found
No related tags found
1 merge request
!24
API: Introduce value and datatype structs to Extern C
Pipeline
#13406
passed
Sep 10, 2021
Stage: info
Stage: setup
Stage: test
Stage: deploy
Pipeline: caosdb-cppinttest
#13417
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/ccaosdb.h
+14
-1
14 additions, 1 deletion
include/ccaosdb.h
src/ccaosdb.cpp
+118
-466
118 additions, 466 deletions
src/ccaosdb.cpp
test/test_ccaosdb.cpp
+166
-156
166 additions, 156 deletions
test/test_ccaosdb.cpp
with
298 additions
and
623 deletions
include/ccaosdb.h
+
14
−
1
View file @
cd50b367
...
@@ -430,7 +430,20 @@ int caosdb_entity_delete_parent(caosdb_entity_parent *out);
...
@@ -430,7 +430,20 @@ int caosdb_entity_delete_parent(caosdb_entity_parent *out);
// TODO(fspreck) implementations, also list_datatypes, list_values...
// TODO(fspreck) implementations, also list_datatypes, list_values...
int
caosdb_entity_create_datatype
(
caosdb_entity_datatype
*
out
);
int
caosdb_entity_create_datatype
(
caosdb_entity_datatype
*
out
);
int
caosdb_entity_delete_datatype
(
caosdb_entity_datatype
*
out
);
int
caosdb_entity_delete_datatype
(
caosdb_entity_datatype
*
out
);
int
caosdb_entity_create_value
(
caosdb_entity_value
*
out
);
// VALUE CONSTRUCTORS (resolve overloaded constructors)
int
caosdb_entity_create_value
(
caosdb_entity_value
*
out
,
caosdb_entity_value
*
in
);
int
caosdb_entity_create_int_value
(
caosdb_entity_value
*
out
,
const
int64_t
value
);
int
caosdb_entity_create_string_value
(
caosdb_entity_value
*
out
,
const
char
*
value
);
int
caosdb_entity_create_double_value
(
caosdb_entity_value
*
out
,
const
double
value
);
int
caosdb_entity_create_bool_value
(
caosdb_entity_value
*
out
,
const
bool
value
);
int
caosdb_entity_create_int_list_value
(
caosdb_entity_value
*
out
,
const
int64_t
*
value
,
const
int
length
);
int
caosdb_entity_create_string_list_value
(
caosdb_entity_value
*
out
,
const
char
**
value
,
const
int
length
);
int
caosdb_entity_create_double_list_value
(
caosdb_entity_value
*
out
,
const
double
*
value
,
const
int
length
);
int
caosdb_entity_create_bool_list_value
(
caosdb_entity_value
*
out
,
const
bool
*
value
,
const
int
length
);
int
caosdb_entity_delete_value
(
caosdb_entity_value
*
out
);
int
caosdb_entity_delete_value
(
caosdb_entity_value
*
out
);
// SETTERS FOR EVERYTHING THAT MAY BE SET
// SETTERS FOR EVERYTHING THAT MAY BE SET
...
...
This diff is collapsed.
Click to expand it.
src/ccaosdb.cpp
+
118
−
466
View file @
cd50b367
...
@@ -650,116 +650,41 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
...
@@ -650,116 +650,41 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
})
})
// CAOSDB_ENTITY_GET(file_path, GetFilePath()) TODO(henrik)
// CAOSDB_ENTITY_GET(file_path, GetFilePath()) TODO(henrik)
CAOSDB_ENTITY_GET
(
description
,
GetDescription
())
CAOSDB_ENTITY_GET
(
description
,
GetDescription
())
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
// TODO(fspreck)
int
caosdb_entity_entity_get_datatype
(
caosdb_entity_entity
*
entity
,
char
**
name
,
// ERROR_RETURN_CODE(GENERIC_ERROR,
bool
*
is_ref
,
bool
*
is_list
),
// int caosdb_entity_entity_get_datatype(caosdb_entity_entity *entity, char
{
// **name,
auto
*
wrapped_entity
=
WRAPPED_ENTITY_CAST
(
entity
);
// bool *is_ref, bool *is_list),
const
auto
&
datatype
=
wrapped_entity
->
GetDataType
();
// {
*
is_list
=
datatype
.
IsList
();
// auto *wrapped_entity = WRAPPED_ENTITY_CAST(entity);
std
::
string
datatype_name
;
// const auto &datatype = wrapped_entity->GetDataType();
if
(
*
is_list
)
{
// *is_list = datatype.IsList();
const
auto
&
list_datatype
=
datatype
.
AsList
();
// std::string datatype_name;
*
is_ref
=
list_datatype
.
IsListOfReference
();
// if (*is_list) {
if
(
*
is_ref
)
{
// const auto &list_datatype = datatype.AsList();
datatype_name
=
list_datatype
.
GetReferenceDataType
().
GetName
();
// *is_ref = list_datatype.IsListOfReference();
}
else
{
// if (*is_ref) {
datatype_name
=
// datatype_name = list_datatype.GetReferenceDataType().GetName();
ENUM_NAME_FROM_VALUE
(
list_datatype
.
GetAtomicDataType
(),
AtomicDataType
);
// } else {
}
// datatype_name =
}
else
{
// ENUM_NAME_FROM_VALUE(list_datatype.GetAtomicDataType(),
*
is_ref
=
datatype
.
IsReference
();
// AtomicDataType);
if
(
*
is_ref
)
{
// }
datatype_name
=
datatype
.
AsReference
().
GetName
();
// } else {
}
else
{
// *is_ref = datatype.IsReference();
datatype_name
=
ENUM_NAME_FROM_VALUE
(
datatype
.
AsAtomic
(),
AtomicDataType
);
// if (*is_ref) {
}
// datatype_name = datatype.AsReference().GetName();
}
// } else {
char
*
tmp
=
(
char
*
)
malloc
(
sizeof
(
char
)
*
datatype_name
.
length
()
+
1
);
// datatype_name = ENUM_NAME_FROM_VALUE(datatype.AsAtomic(),
strcpy
(
tmp
,
datatype_name
.
c_str
());
// AtomicDataType);
delete
[]
*
name
;
// }
*
name
=
tmp
;
// }
return
0
;
// char *tmp = (char *)malloc(sizeof(char) * datatype_name.length() + 1);
})
// strcpy(tmp, datatype_name.c_str());
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
// delete[] * name;
int
caosdb_entity_entity_get_int_value
(
caosdb_entity_entity
*
entity
,
// *name = tmp;
int64_t
*
out
),
// return 0;
{
// })
auto
*
wrapped_entity
=
WRAPPED_ENTITY_CAST
(
entity
);
*
out
=
wrapped_entity
->
GetValue
().
AsInteger
();
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_get_double_value
(
caosdb_entity_entity
*
entity
,
double
*
out
),
{
auto
*
wrapped_entity
=
WRAPPED_ENTITY_CAST
(
entity
);
*
out
=
wrapped_entity
->
GetValue
().
AsDouble
();
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_get_boolean_value
(
caosdb_entity_entity
*
entity
,
bool
*
out
),
{
auto
*
wrapped_entity
=
WRAPPED_ENTITY_CAST
(
entity
);
*
out
=
wrapped_entity
->
GetValue
().
AsBool
();
return
0
;
})
CAOSDB_ENTITY_GET
(
string_value
,
GetValue
().
AsString
())
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_get_int_list_value_at
(
caosdb_entity_entity
*
entity
,
int64_t
*
out
,
const
int
index
),
{
auto
*
wrapped_entity
=
WRAPPED_ENTITY_CAST
(
entity
);
auto
value_list
=
wrapped_entity
->
GetValue
().
AsList
();
*
out
=
value_list
[
index
].
AsInteger
();
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_get_double_list_value_at
(
caosdb_entity_entity
*
entity
,
double
*
out
,
const
int
index
),
{
auto
*
wrapped_entity
=
WRAPPED_ENTITY_CAST
(
entity
);
auto
value_list
=
wrapped_entity
->
GetValue
().
AsList
();
*
out
=
value_list
[
index
].
AsDouble
();
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_get_boolean_list_value_at
(
caosdb_entity_entity
*
entity
,
bool
*
out
,
const
int
index
),
{
auto
*
wrapped_entity
=
WRAPPED_ENTITY_CAST
(
entity
);
auto
value_list
=
wrapped_entity
->
GetValue
().
AsList
();
*
out
=
value_list
[
index
].
AsBool
();
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_get_string_list_value_at
(
caosdb_entity_entity
*
entity
,
char
**
out
,
const
int
index
),
{
auto
*
wrapped_entity
=
WRAPPED_ENTITY_CAST
(
entity
);
auto
value_list
=
wrapped_entity
->
GetValue
().
AsList
();
char
*
tmp
=
(
char
*
)
malloc
(
sizeof
(
char
)
*
value_list
[
index
].
AsString
().
length
()
+
1
);
strcpy
(
tmp
,
value_list
[
index
].
AsString
().
c_str
());
delete
[]
*
out
;
*
out
=
tmp
;
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_get_value_list_length
(
caosdb_entity_entity
*
entity
,
int
*
out
),
{
auto
*
wrapped_entity
=
WRAPPED_ENTITY_CAST
(
entity
);
if
(
wrapped_entity
->
GetValue
().
IsList
())
{
*
out
=
wrapped_entity
->
GetValue
().
AsList
().
size
();
}
else
{
*
out
=
0
;
}
return
0
;
})
CAOSDB_ENTITY_GET
(
unit
,
GetUnit
())
CAOSDB_ENTITY_GET
(
unit
,
GetUnit
())
CAOSDB_ENTITY_GET
(
version_id
,
GetVersionId
())
CAOSDB_ENTITY_GET
(
version_id
,
GetVersionId
())
...
@@ -902,120 +827,44 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
...
@@ -902,120 +827,44 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
return
0
;
return
0
;
})
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
// TODO(fspreck)
int
caosdb_entity_property_get_datatype
(
caosdb_entity_property
*
property
,
// ERROR_RETURN_CODE(GENERIC_ERROR,
char
**
name
,
bool
*
is_ref
,
bool
*
is_list
),
// int caosdb_entity_property_get_datatype(caosdb_entity_property *property,
{
// char **name, bool *is_ref, bool
auto
*
wrapped_property
=
WRAPPED_PROPERTY_CAST
(
property
);
// *is_list),
const
auto
&
datatype
=
wrapped_property
->
GetDataType
();
// {
*
is_list
=
datatype
.
IsList
();
// auto *wrapped_property = WRAPPED_PROPERTY_CAST(property);
std
::
string
datatype_name
;
// const auto &datatype = wrapped_property->GetDataType();
if
(
*
is_list
)
{
// *is_list = datatype.IsList();
const
auto
&
list_datatype
=
datatype
.
AsList
();
// std::string datatype_name;
*
is_ref
=
list_datatype
.
IsListOfReference
();
// if (*is_list) {
if
(
*
is_ref
)
{
// const auto &list_datatype = datatype.AsList();
datatype_name
=
list_datatype
.
GetReferenceDataType
().
GetName
();
// *is_ref = list_datatype.IsListOfReference();
}
else
{
// if (*is_ref) {
datatype_name
=
// datatype_name = list_datatype.GetReferenceDataType().GetName();
ENUM_NAME_FROM_VALUE
(
list_datatype
.
GetAtomicDataType
(),
AtomicDataType
);
// } else {
}
// datatype_name =
}
else
{
// ENUM_NAME_FROM_VALUE(list_datatype.GetAtomicDataType(),
*
is_ref
=
datatype
.
IsReference
();
// AtomicDataType);
if
(
*
is_ref
)
{
// }
datatype_name
=
datatype
.
AsReference
().
GetName
();
// } else {
}
else
{
// *is_ref = datatype.IsReference();
datatype_name
=
ENUM_NAME_FROM_VALUE
(
datatype
.
AsAtomic
(),
AtomicDataType
);
// if (*is_ref) {
}
// datatype_name = datatype.AsReference().GetName();
}
// } else {
char
*
tmp
=
(
char
*
)
malloc
(
sizeof
(
char
)
*
datatype_name
.
length
()
+
1
);
// datatype_name = ENUM_NAME_FROM_VALUE(datatype.AsAtomic(),
strcpy
(
tmp
,
datatype_name
.
c_str
());
// AtomicDataType);
delete
[]
*
name
;
// }
*
name
=
tmp
;
// }
return
0
;
// char *tmp = (char *)malloc(sizeof(char) * datatype_name.length() + 1);
})
// strcpy(tmp, datatype_name.c_str());
// delete[] * name;
// *name = tmp;
// return 0;
// })
CAOSDB_PROPERTY_GET
(
unit
,
GetUnit
())
CAOSDB_PROPERTY_GET
(
unit
,
GetUnit
())
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_get_int_value
(
caosdb_entity_property
*
property
,
int64_t
*
out
),
{
auto
*
wrapped_property
=
WRAPPED_PROPERTY_CAST
(
property
);
*
out
=
wrapped_property
->
GetValue
().
AsInteger
();
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_get_double_value
(
caosdb_entity_property
*
property
,
double
*
out
),
{
auto
*
wrapped_property
=
WRAPPED_PROPERTY_CAST
(
property
);
*
out
=
wrapped_property
->
GetValue
().
AsDouble
();
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_get_boolean_value
(
caosdb_entity_property
*
property
,
bool
*
out
),
{
auto
*
wrapped_property
=
WRAPPED_PROPERTY_CAST
(
property
);
*
out
=
wrapped_property
->
GetValue
().
AsBool
();
return
0
;
})
CAOSDB_PROPERTY_GET
(
string_value
,
GetValue
().
AsString
())
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_get_int_list_value_at
(
caosdb_entity_property
*
property
,
int64_t
*
out
,
const
int
index
),
{
auto
*
wrapped_property
=
WRAPPED_PROPERTY_CAST
(
property
);
auto
value_list
=
wrapped_property
->
GetValue
().
AsList
();
*
out
=
value_list
[
index
].
AsInteger
();
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_get_double_list_value_at
(
caosdb_entity_property
*
property
,
double
*
out
,
const
int
index
),
{
auto
*
wrapped_property
=
WRAPPED_PROPERTY_CAST
(
property
);
auto
value_list
=
wrapped_property
->
GetValue
().
AsList
();
*
out
=
value_list
[
index
].
AsDouble
();
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_get_boolean_list_value_at
(
caosdb_entity_property
*
property
,
bool
*
out
,
const
int
index
),
{
auto
*
wrapped_property
=
WRAPPED_PROPERTY_CAST
(
property
);
auto
value_list
=
wrapped_property
->
GetValue
().
AsList
();
*
out
=
value_list
[
index
].
AsBool
();
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_get_string_list_value_at
(
caosdb_entity_property
*
property
,
char
**
out
,
const
int
index
),
{
auto
*
wrapped_property
=
WRAPPED_PROPERTY_CAST
(
property
);
auto
value_list
=
wrapped_property
->
GetValue
().
AsList
();
auto
*
tmp
=
(
char
*
)
malloc
(
sizeof
(
char
)
*
value_list
[
index
].
AsString
().
length
()
+
1
);
strcpy
(
tmp
,
value_list
[
index
].
AsString
().
c_str
());
delete
[]
*
out
;
*
out
=
tmp
;
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_get_value_list_length
(
caosdb_entity_property
*
property
,
int
*
out
),
{
auto
*
wrapped_property
=
WRAPPED_PROPERTY_CAST
(
property
);
if
(
wrapped_property
->
GetValue
().
IsList
())
{
*
out
=
wrapped_property
->
GetValue
().
AsList
().
size
();
}
else
{
*
out
=
0
;
}
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_message_get_code
(
caosdb_entity_message
*
message
,
int
*
out
),
{
int
caosdb_entity_message_get_code
(
caosdb_entity_message
*
message
,
int
*
out
),
{
auto
*
wrapped_message
=
auto
*
wrapped_message
=
...
@@ -1054,131 +903,32 @@ CAOSDB_ENTITY_SET(local_path, local_path,
...
@@ -1054,131 +903,32 @@ CAOSDB_ENTITY_SET(local_path, local_path,
CAOSDB_ENTITY_SET
(
file_path
,
file_path
,
wrapped_entity
->
SetFilePath
(
std
::
string
(
file_path
));)
CAOSDB_ENTITY_SET
(
file_path
,
file_path
,
wrapped_entity
->
SetFilePath
(
std
::
string
(
file_path
));)
CAOSDB_ENTITY_SET
(
description
,
description
,
CAOSDB_ENTITY_SET
(
description
,
description
,
wrapped_entity
->
SetDescription
(
std
::
string
(
description
));)
wrapped_entity
->
SetDescription
(
std
::
string
(
description
));)
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
// TODO(fspreck)
int
caosdb_entity_entity_set_datatype
(
caosdb_entity_entity
*
entity
,
// ERROR_RETURN_CODE(GENERIC_ERROR,
const
char
*
datatype
,
const
bool
is_ref
,
// int caosdb_entity_entity_set_datatype(caosdb_entity_entity *entity,
const
bool
is_list
),
// const char *datatype, const bool is_ref,
{
// const bool is_list),
auto
*
wrapped_entity
=
WRAPPED_ENTITY_CAST
(
entity
);
// {
if
(
is_ref
)
{
// auto *wrapped_entity = WRAPPED_ENTITY_CAST(entity);
// Refernce datatype with name of reference
// if (is_ref) {
wrapped_entity
->
SetDataType
(
std
::
string
(
datatype
),
is_list
);
// // Refernce datatype with name of reference
return
0
;
// wrapped_entity->SetDataType(std::string(datatype), is_list);
}
else
{
// return 0;
// Atomic datatype so get from enum
// } else {
try
{
// // Atomic datatype so get from enum
auto
enum_value
=
// try {
ENUM_VALUE_FROM_NAME
(
std
::
string
(
datatype
),
AtomicDataType
);
// auto enum_value =
wrapped_entity
->
SetDataType
(
enum_value
,
is_list
);
// ENUM_VALUE_FROM_NAME(std::string(datatype), AtomicDataType);
return
0
;
// wrapped_entity->SetDataType(enum_value, is_list);
}
catch
(
const
std
::
out_of_range
&
exc
)
{
// return 0;
caosdb
::
logging
::
caosdb_log_fatal
(
CCAOSDB_LOGGER_NAME
,
exc
.
what
());
// } catch (const std::out_of_range &exc) {
return
caosdb
::
StatusCode
::
ENUM_MAPPING_ERROR
;
// caosdb::logging::caosdb_log_fatal(CCAOSDB_LOGGER_NAME, exc.what());
}
// return caosdb::StatusCode::ENUM_MAPPING_ERROR;
}
// }
})
// }
// })
CAOSDB_ENTITY_SET
(
unit
,
unit
,
wrapped_entity
->
SetUnit
(
std
::
string
(
unit
));)
CAOSDB_ENTITY_SET
(
unit
,
unit
,
wrapped_entity
->
SetUnit
(
std
::
string
(
unit
));)
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_set_int_value
(
caosdb_entity_entity
*
entity
,
const
int64_t
value
),
{
auto
*
wrapped_entity
=
static_cast
<
caosdb
::
entity
::
Entity
*>
(
entity
->
wrapped_entity
);
wrapped_entity
->
SetValue
(
value
);
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_set_double_value
(
caosdb_entity_entity
*
entity
,
const
double
value
),
{
auto
*
wrapped_entity
=
static_cast
<
caosdb
::
entity
::
Entity
*>
(
entity
->
wrapped_entity
);
wrapped_entity
->
SetValue
(
value
);
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_set_boolean_value
(
caosdb_entity_entity
*
entity
,
const
bool
value
),
{
auto
*
wrapped_entity
=
static_cast
<
caosdb
::
entity
::
Entity
*>
(
entity
->
wrapped_entity
);
wrapped_entity
->
SetValue
(
value
);
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_set_string_value
(
caosdb_entity_entity
*
entity
,
const
char
*
value
),
{
auto
*
wrapped_entity
=
static_cast
<
caosdb
::
entity
::
Entity
*>
(
entity
->
wrapped_entity
);
wrapped_entity
->
SetValue
(
std
::
string
(
value
));
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_set_int_list_value
(
caosdb_entity_entity
*
entity
,
const
int64_t
*
value
,
const
int
length
),
{
auto
*
wrapped_entity
=
static_cast
<
caosdb
::
entity
::
Entity
*>
(
entity
->
wrapped_entity
);
std
::
vector
<
int64_t
>
value_list
;
for
(
int
i
=
0
;
i
<
length
;
i
++
)
{
value_list
.
push_back
(
value
[
i
]);
}
wrapped_entity
->
SetValue
(
value_list
);
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_set_double_list_value
(
caosdb_entity_entity
*
entity
,
const
double
*
value
,
const
int
length
),
{
auto
*
wrapped_entity
=
static_cast
<
caosdb
::
entity
::
Entity
*>
(
entity
->
wrapped_entity
);
std
::
vector
<
double
>
value_list
;
for
(
int
i
=
0
;
i
<
length
;
i
++
)
{
value_list
.
push_back
(
value
[
i
]);
}
wrapped_entity
->
SetValue
(
value_list
);
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_set_boolean_list_value
(
caosdb_entity_entity
*
entity
,
const
bool
*
value
,
const
int
length
),
{
auto
*
wrapped_entity
=
static_cast
<
caosdb
::
entity
::
Entity
*>
(
entity
->
wrapped_entity
);
std
::
vector
<
bool
>
value_list
;
for
(
int
i
=
0
;
i
<
length
;
i
++
)
{
value_list
.
push_back
(
value
[
i
]);
}
wrapped_entity
->
SetValue
(
value_list
);
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_set_string_list_value
(
caosdb_entity_entity
*
entity
,
const
char
**
value
,
const
int
length
),
{
auto
*
wrapped_entity
=
static_cast
<
caosdb
::
entity
::
Entity
*>
(
entity
->
wrapped_entity
);
std
::
vector
<
std
::
string
>
value_list
;
for
(
int
i
=
0
;
i
<
length
;
i
++
)
{
value_list
.
push_back
(
std
::
string
(
value
[
i
]));
}
wrapped_entity
->
SetValue
(
value_list
);
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_append_parent
(
caosdb_entity_entity
*
entity
,
int
caosdb_entity_entity_append_parent
(
caosdb_entity_entity
*
entity
,
caosdb_entity_parent
*
parent
),
caosdb_entity_parent
*
parent
),
...
@@ -1225,29 +975,30 @@ CAOSDB_PARENT_SET(name, name, wrapped_parent->SetName(std::string(name));)
...
@@ -1225,29 +975,30 @@ CAOSDB_PARENT_SET(name, name, wrapped_parent->SetName(std::string(name));)
CAOSDB_PROPERTY_SET
(
name
,
name
,
wrapped_property
->
SetName
(
std
::
string
(
name
));)
CAOSDB_PROPERTY_SET
(
name
,
name
,
wrapped_property
->
SetName
(
std
::
string
(
name
));)
CAOSDB_PROPERTY_SET
(
id
,
id
,
wrapped_property
->
SetId
(
std
::
string
(
id
));)
CAOSDB_PROPERTY_SET
(
id
,
id
,
wrapped_property
->
SetId
(
std
::
string
(
id
));)
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
// TODO(fspreck)
int
caosdb_entity_property_set_datatype
(
caosdb_entity_property
*
property
,
// ERROR_RETURN_CODE(GENERIC_ERROR,
const
char
*
datatype
,
const
bool
is_ref
,
// int caosdb_entity_property_set_datatype(caosdb_entity_property *property,
const
bool
is_list
),
// const char *datatype, const bool
{
// is_ref, const bool is_list),
auto
*
wrapped_property
=
WRAPPED_PROPERTY_CAST
(
property
);
// {
if
(
is_ref
)
{
// auto *wrapped_property = WRAPPED_PROPERTY_CAST(property);
// Refernce datatype with name of reference
// if (is_ref) {
wrapped_property
->
SetDataType
(
std
::
string
(
datatype
),
is_list
);
// // Refernce datatype with name of reference
return
0
;
// wrapped_property->SetDataType(std::string(datatype), is_list);
}
else
{
// return 0;
// Atomic datatype so get from enum
// } else {
try
{
// // Atomic datatype so get from enum
auto
enum_value
=
// try {
ENUM_VALUE_FROM_NAME
(
std
::
string
(
datatype
),
AtomicDataType
);
// auto enum_value =
wrapped_property
->
SetDataType
(
enum_value
,
is_list
);
// ENUM_VALUE_FROM_NAME(std::string(datatype), AtomicDataType);
return
0
;
// wrapped_property->SetDataType(enum_value, is_list);
}
catch
(
const
std
::
out_of_range
&
exc
)
{
// return 0;
caosdb
::
logging
::
caosdb_log_fatal
(
CCAOSDB_LOGGER_NAME
,
exc
.
what
());
// } catch (const std::out_of_range &exc) {
return
caosdb
::
StatusCode
::
ENUM_MAPPING_ERROR
;
// caosdb::logging::caosdb_log_fatal(CCAOSDB_LOGGER_NAME, exc.what());
}
// return caosdb::StatusCode::ENUM_MAPPING_ERROR;
}
// }
})
// }
// })
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_set_importance
(
caosdb_entity_property
*
property
,
int
caosdb_entity_property_set_importance
(
caosdb_entity_property
*
property
,
...
@@ -1265,103 +1016,4 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
...
@@ -1265,103 +1016,4 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
})
})
CAOSDB_PROPERTY_SET
(
unit
,
unit
,
wrapped_property
->
SetUnit
(
std
::
string
(
unit
));)
CAOSDB_PROPERTY_SET
(
unit
,
unit
,
wrapped_property
->
SetUnit
(
std
::
string
(
unit
));)
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_set_int_value
(
caosdb_entity_property
*
property
,
const
int64_t
value
),
{
auto
*
wrapped_property
=
static_cast
<
caosdb
::
entity
::
Property
*>
(
property
->
wrapped_property
);
wrapped_property
->
SetValue
(
value
);
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_set_double_value
(
caosdb_entity_property
*
property
,
const
double
value
),
{
auto
*
wrapped_property
=
static_cast
<
caosdb
::
entity
::
Property
*>
(
property
->
wrapped_property
);
wrapped_property
->
SetValue
(
value
);
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_set_boolean_value
(
caosdb_entity_property
*
property
,
const
bool
value
),
{
auto
*
wrapped_property
=
static_cast
<
caosdb
::
entity
::
Property
*>
(
property
->
wrapped_property
);
wrapped_property
->
SetValue
(
value
);
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_set_string_value
(
caosdb_entity_property
*
property
,
const
char
*
value
),
{
auto
*
wrapped_property
=
static_cast
<
caosdb
::
entity
::
Property
*>
(
property
->
wrapped_property
);
wrapped_property
->
SetValue
(
std
::
string
(
value
));
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_set_int_list_value
(
caosdb_entity_property
*
property
,
const
int64_t
*
value
,
const
int
length
),
{
auto
*
wrapped_property
=
static_cast
<
caosdb
::
entity
::
Property
*>
(
property
->
wrapped_property
);
std
::
vector
<
int64_t
>
value_list
;
for
(
int
i
=
0
;
i
<
length
;
i
++
)
{
value_list
.
push_back
(
value
[
i
]);
}
wrapped_property
->
SetValue
(
value_list
);
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_set_double_list_value
(
caosdb_entity_property
*
property
,
const
double
*
value
,
const
int
length
),
{
auto
*
wrapped_property
=
static_cast
<
caosdb
::
entity
::
Property
*>
(
property
->
wrapped_property
);
std
::
vector
<
double
>
value_list
;
for
(
int
i
=
0
;
i
<
length
;
i
++
)
{
value_list
.
push_back
(
value
[
i
]);
}
wrapped_property
->
SetValue
(
value_list
);
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_set_boolean_list_value
(
caosdb_entity_property
*
property
,
const
bool
*
value
,
const
int
length
),
{
auto
*
wrapped_property
=
static_cast
<
caosdb
::
entity
::
Property
*>
(
property
->
wrapped_property
);
std
::
vector
<
bool
>
value_list
;
for
(
int
i
=
0
;
i
<
length
;
i
++
)
{
value_list
.
push_back
(
value
[
i
]);
}
wrapped_property
->
SetValue
(
value_list
);
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_set_string_list_value
(
caosdb_entity_property
*
property
,
const
char
**
value
,
const
int
length
),
{
auto
*
wrapped_property
=
static_cast
<
caosdb
::
entity
::
Property
*>
(
property
->
wrapped_property
);
std
::
vector
<
std
::
string
>
value_list
;
for
(
int
i
=
0
;
i
<
length
;
i
++
)
{
value_list
.
push_back
(
std
::
string
(
value
[
i
]));
}
wrapped_property
->
SetValue
(
value_list
);
return
0
;
})
}
}
This diff is collapsed.
Click to expand it.
test/test_ccaosdb.cpp
+
166
−
156
View file @
cd50b367
...
@@ -174,30 +174,32 @@ TEST_F(test_ccaosdb, test_entity) {
...
@@ -174,30 +174,32 @@ TEST_F(test_ccaosdb, test_entity) {
caosdb_entity_entity_get_description
(
&
entity
,
&
out
);
caosdb_entity_entity_get_description
(
&
entity
,
&
out
);
EXPECT_EQ
(
strcmp
(
out
,
"The length of an object"
),
0
);
EXPECT_EQ
(
strcmp
(
out
,
"The length of an object"
),
0
);
caosdb_entity_entity_set_datatype
(
&
entity
,
"DOUBLE"
,
false
,
false
);
// TODO(fspreck)
bool
is_list
[]
=
{
false
};
// NOLINT
// caosdb_entity_entity_set_datatype(&entity, "DOUBLE", false, false);
bool
is_ref
[]
=
{
false
};
// NOLINT
// bool is_list[] = {false}; // NOLINT
caosdb_entity_entity_get_datatype
(
&
entity
,
&
out
,
is_ref
,
is_list
);
// bool is_ref[] = {false}; // NOLINT
EXPECT_EQ
(
strcmp
(
out
,
"DOUBLE"
),
0
);
// caosdb_entity_entity_get_datatype(&entity, &out, is_ref, is_list);
EXPECT_FALSE
(
*
is_list
);
// EXPECT_EQ(strcmp(out, "DOUBLE"), 0);
EXPECT_FALSE
(
*
is_ref
);
// EXPECT_FALSE(*is_list);
// EXPECT_FALSE(*is_ref);
caosdb_entity_entity_set_datatype
(
&
entity
,
"Person"
,
true
,
true
);
caosdb_entity_entity_get_datatype
(
&
entity
,
&
out
,
is_ref
,
is_list
);
// caosdb_entity_entity_set_datatype(&entity, "Person", true, true);
EXPECT_EQ
(
strcmp
(
out
,
"Person"
),
0
);
// caosdb_entity_entity_get_datatype(&entity, &out, is_ref, is_list);
EXPECT_TRUE
(
*
is_list
);
// EXPECT_EQ(strcmp(out, "Person"), 0);
EXPECT_TRUE
(
*
is_ref
);
// EXPECT_TRUE(*is_list);
// EXPECT_TRUE(*is_ref);
caosdb_entity_entity_set_unit
(
&
entity
,
"m"
);
caosdb_entity_entity_set_unit
(
&
entity
,
"m"
);
caosdb_entity_entity_get_unit
(
&
entity
,
&
out
);
caosdb_entity_entity_get_unit
(
&
entity
,
&
out
);
EXPECT_EQ
(
strcmp
(
out
,
"m"
),
0
);
EXPECT_EQ
(
strcmp
(
out
,
"m"
),
0
);
return_code
=
caosdb_entity_entity_set_double_value
(
&
entity
,
5.0
);
// TODO(fspreck)
EXPECT_EQ
(
return_code
,
0
);
// return_code = caosdb_entity_entity_set_double_value(&entity, 5.0);
double
value
[]
=
{
0.0
};
// NOLINT
// EXPECT_EQ(return_code, 0);
return_code
=
caosdb_entity_entity_get_double_value
(
&
entity
,
value
);
// double value[] = {0.0}; // NOLINT
EXPECT_EQ
(
return_code
,
0
);
// return_code = caosdb_entity_entity_get_double_value(&entity, value);
EXPECT_EQ
(
*
value
,
5.0
);
// EXPECT_EQ(return_code, 0);
// EXPECT_EQ(*value, 5.0);
return_code
=
caosdb_entity_delete_entity
(
&
entity
);
return_code
=
caosdb_entity_delete_entity
(
&
entity
);
EXPECT_EQ
(
return_code
,
0
);
EXPECT_EQ
(
return_code
,
0
);
...
@@ -232,10 +234,12 @@ TEST_F(test_ccaosdb, test_property) {
...
@@ -232,10 +234,12 @@ TEST_F(test_ccaosdb, test_property) {
caosdb_entity_property_set_id
(
&
property
,
"some_id"
);
caosdb_entity_property_set_id
(
&
property
,
"some_id"
);
caosdb_entity_property_set_name
(
&
property
,
"some_name"
);
caosdb_entity_property_set_name
(
&
property
,
"some_name"
);
caosdb_entity_property_set_datatype
(
&
property
,
"TEXT"
,
false
,
false
);
// TODO(fspreck)
// caosdb_entity_property_set_datatype(&property, "TEXT", false, false);
caosdb_entity_property_set_importance
(
&
property
,
"FIX"
);
caosdb_entity_property_set_importance
(
&
property
,
"FIX"
);
caosdb_entity_property_set_unit
(
&
property
,
"some_unit"
);
caosdb_entity_property_set_unit
(
&
property
,
"some_unit"
);
caosdb_entity_property_set_string_value
(
&
property
,
"some_value"
);
// TODO(fspreck)
// caosdb_entity_property_set_string_value(&property, "some_value");
char
*
out
=
nullptr
;
// NOLINT
char
*
out
=
nullptr
;
// NOLINT
caosdb_entity_property_get_id
(
&
property
,
&
out
);
caosdb_entity_property_get_id
(
&
property
,
&
out
);
...
@@ -244,12 +248,13 @@ TEST_F(test_ccaosdb, test_property) {
...
@@ -244,12 +248,13 @@ TEST_F(test_ccaosdb, test_property) {
caosdb_entity_property_get_name
(
&
property
,
&
out
);
caosdb_entity_property_get_name
(
&
property
,
&
out
);
EXPECT_EQ
(
strcmp
(
out
,
"some_name"
),
0
);
EXPECT_EQ
(
strcmp
(
out
,
"some_name"
),
0
);
bool
is_ref
[]
=
{
false
};
// NOLINT
// TODO(fspreck)
bool
is_list
[]
=
{
false
};
// NOLINT
// bool is_ref[] = {false}; // NOLINT
caosdb_entity_property_get_datatype
(
&
property
,
&
out
,
is_ref
,
is_list
);
// bool is_list[] = {false}; // NOLINT
EXPECT_EQ
(
strcmp
(
out
,
"TEXT"
),
0
);
// caosdb_entity_property_get_datatype(&property, &out, is_ref, is_list);
EXPECT_FALSE
(
*
is_ref
);
// EXPECT_EQ(strcmp(out, "TEXT"), 0);
EXPECT_FALSE
(
*
is_list
);
// EXPECT_FALSE(*is_ref);
// EXPECT_FALSE(*is_list);
caosdb_entity_property_get_importance
(
&
property
,
&
out
);
caosdb_entity_property_get_importance
(
&
property
,
&
out
);
EXPECT_EQ
(
strcmp
(
out
,
"FIX"
),
0
);
EXPECT_EQ
(
strcmp
(
out
,
"FIX"
),
0
);
...
@@ -257,125 +262,127 @@ TEST_F(test_ccaosdb, test_property) {
...
@@ -257,125 +262,127 @@ TEST_F(test_ccaosdb, test_property) {
caosdb_entity_property_get_unit
(
&
property
,
&
out
);
caosdb_entity_property_get_unit
(
&
property
,
&
out
);
EXPECT_EQ
(
strcmp
(
out
,
"some_unit"
),
0
);
EXPECT_EQ
(
strcmp
(
out
,
"some_unit"
),
0
);
caosdb_entity_property_get_string_value
(
&
property
,
&
out
);
// TODO(fspreck)
EXPECT_EQ
(
strcmp
(
out
,
"some_value"
),
0
);
// caosdb_entity_property_get_string_value(&property, &out);
// EXPECT_EQ(strcmp(out, "some_value"), 0);
return_code
=
caosdb_entity_delete_property
(
&
property
);
return_code
=
caosdb_entity_delete_property
(
&
property
);
EXPECT_EQ
(
return_code
,
0
);
EXPECT_EQ
(
return_code
,
0
);
}
}
TEST_F
(
test_ccaosdb
,
test_string_list_property
)
{
// TODO(fspreck)
// TEST_F(test_ccaosdb, test_string_list_property) {
caosdb_entity_property
property
;
int
return_code
(
caosdb_entity_create_property
(
&
property
));
// caosdb_entity_property property;
EXPECT_EQ
(
return_code
,
0
);
// int return_code(caosdb_entity_create_property(&property));
// EXPECT_EQ(return_code, 0);
return_code
=
caosdb_entity_property_set_datatype
(
&
property
,
"TEXT"
,
false
,
true
);
EXPECT_EQ
(
return_code
,
0
);
// return_code = caosdb_entity_property_set_datatype(&property, "TEXT", false, true);
// EXPECT_EQ(return_code, 0);
const
char
*
value_list
[]
=
{
"val0"
,
"val1"
,
"val2"
};
// NOLINT
return_code
=
caosdb_entity_property_set_string_list_value
(
&
property
,
value_list
,
3
);
// const char *value_list[] = {"val0", "val1", "val2"}; // NOLINT
EXPECT_EQ
(
return_code
,
0
);
// return_code = caosdb_entity_property_set_string_list_value(&property, value_list, 3);
// EXPECT_EQ(return_code, 0);
char
*
out
=
nullptr
;
// NOLINT
bool
is_ref
[]
=
{
false
};
// NOLINT
// char *out = nullptr; // NOLINT
bool
is_list
[]
=
{
false
};
// NOLINT
// bool is_ref[] = {false}; // NOLINT
return_code
=
caosdb_entity_property_get_datatype
(
&
property
,
&
out
,
is_ref
,
is_list
);
// bool is_list[] = {false}; // NOLINT
EXPECT_EQ
(
return_code
,
0
);
// return_code = caosdb_entity_property_get_datatype(&property, &out, is_ref, is_list);
EXPECT_EQ
(
strcmp
(
out
,
"TEXT"
),
0
);
// EXPECT_EQ(return_code, 0);
EXPECT_FALSE
(
*
is_ref
);
// EXPECT_EQ(strcmp(out, "TEXT"), 0);
EXPECT_TRUE
(
*
is_list
);
// EXPECT_FALSE(*is_ref);
// EXPECT_TRUE(*is_list);
int
length
=
-
1
;
// NOLINT
return_code
=
caosdb_entity_property_get_value_list_length
(
&
property
,
&
length
);
// int length = -1; // NOLINT
EXPECT_EQ
(
return_code
,
0
);
// return_code = caosdb_entity_property_get_value_list_length(&property, &length);
EXPECT_EQ
(
length
,
3
);
// EXPECT_EQ(return_code, 0);
// EXPECT_EQ(length, 3);
for
(
int
i
=
0
;
i
<
length
;
i
++
)
{
return_code
=
caosdb_entity_property_get_string_list_value_at
(
&
property
,
&
out
,
i
);
// for (int i = 0; i < length; i++) {
EXPECT_EQ
(
return_code
,
0
);
// return_code = caosdb_entity_property_get_string_list_value_at(&property, &out, i);
EXPECT_EQ
(
strcmp
(
value_list
[
i
],
out
),
0
);
// NOLINT
// EXPECT_EQ(return_code, 0);
}
// EXPECT_EQ(strcmp(value_list[i], out), 0); // NOLINT
// }
return_code
=
caosdb_entity_delete_property
(
&
property
);
EXPECT_EQ
(
return_code
,
0
);
// return_code = caosdb_entity_delete_property(&property);
}
// EXPECT_EQ(return_code, 0);
// }
TEST_F
(
test_ccaosdb
,
test_int_list_property
)
{
// TEST_F(test_ccaosdb, test_int_list_property) {
caosdb_entity_property
property
;
int
return_code
(
caosdb_entity_create_property
(
&
property
));
// caosdb_entity_property property;
EXPECT_EQ
(
return_code
,
0
);
// int return_code(caosdb_entity_create_property(&property));
// EXPECT_EQ(return_code, 0);
return_code
=
caosdb_entity_property_set_datatype
(
&
property
,
"INTEGER"
,
false
,
true
);
EXPECT_EQ
(
return_code
,
0
);
// return_code = caosdb_entity_property_set_datatype(&property, "INTEGER", false, true);
// EXPECT_EQ(return_code, 0);
const
int64_t
value_list
[]
=
{
1
,
2
,
3
};
// NOLINT
return_code
=
caosdb_entity_property_set_int_list_value
(
&
property
,
&
(
value_list
)[
0
],
3
);
// const int64_t value_list[] = {1, 2, 3}; // NOLINT
EXPECT_EQ
(
return_code
,
0
);
// return_code = caosdb_entity_property_set_int_list_value(&property, &(value_list)[0], 3);
// EXPECT_EQ(return_code, 0);
char
*
dt_out
=
nullptr
;
// NOLINT
bool
is_ref
[]
=
{
false
};
// NOLINT
// char *dt_out = nullptr; // NOLINT
bool
is_list
[]
=
{
false
};
// NOLINT
// bool is_ref[] = {false}; // NOLINT
return_code
=
caosdb_entity_property_get_datatype
(
&
property
,
&
dt_out
,
is_ref
,
is_list
);
// bool is_list[] = {false}; // NOLINT
EXPECT_EQ
(
return_code
,
0
);
// return_code = caosdb_entity_property_get_datatype(&property, &dt_out, is_ref, is_list);
EXPECT_STREQ
(
dt_out
,
"INTEGER"
);
// EXPECT_EQ(return_code, 0);
EXPECT_FALSE
(
*
is_ref
);
// EXPECT_STREQ(dt_out, "INTEGER");
EXPECT_TRUE
(
*
is_list
);
// EXPECT_FALSE(*is_ref);
// EXPECT_TRUE(*is_list);
int
length
=
-
1
;
// NOLINT
return_code
=
caosdb_entity_property_get_value_list_length
(
&
property
,
&
length
);
// int length = -1; // NOLINT
EXPECT_EQ
(
return_code
,
0
);
// return_code = caosdb_entity_property_get_value_list_length(&property, &length);
EXPECT_EQ
(
length
,
3
);
// EXPECT_EQ(return_code, 0);
// EXPECT_EQ(length, 3);
for
(
int
i
=
0
;
i
<
length
;
i
++
)
{
int64_t
out
=
-
1
;
// for (int i = 0; i < length; i++) {
return_code
=
caosdb_entity_property_get_int_list_value_at
(
&
property
,
&
out
,
i
);
// int64_t out = -1;
EXPECT_EQ
(
return_code
,
0
);
// return_code = caosdb_entity_property_get_int_list_value_at(&property, &out, i);
EXPECT_EQ
(
value_list
[
i
],
out
);
// NOLINT
// EXPECT_EQ(return_code, 0);
}
// EXPECT_EQ(value_list[i], out); // NOLINT
// }
return_code
=
caosdb_entity_delete_property
(
&
property
);
EXPECT_EQ
(
return_code
,
0
);
// return_code = caosdb_entity_delete_property(&property);
}
// EXPECT_EQ(return_code, 0);
// }
TEST_F
(
test_ccaosdb
,
test_bool_list_property
)
{
// TEST_F(test_ccaosdb, test_bool_list_property) {
caosdb_entity_property
property
;
int
return_code
(
caosdb_entity_create_property
(
&
property
));
// caosdb_entity_property property;
EXPECT_EQ
(
return_code
,
0
);
// int return_code(caosdb_entity_create_property(&property));
// EXPECT_EQ(return_code, 0);
return_code
=
caosdb_entity_property_set_datatype
(
&
property
,
"BOOLEAN"
,
false
,
true
);
EXPECT_EQ
(
return_code
,
0
);
// return_code = caosdb_entity_property_set_datatype(&property, "BOOLEAN", false, true);
// EXPECT_EQ(return_code, 0);
const
bool
value_list
[]
=
{
true
,
true
,
false
};
// NOLINT
return_code
=
caosdb_entity_property_set_boolean_list_value
(
&
property
,
&
(
value_list
)[
0
],
3
);
// const bool value_list[] = {true, true, false}; // NOLINT
EXPECT_EQ
(
return_code
,
0
);
// return_code = caosdb_entity_property_set_boolean_list_value(&property, &(value_list)[0], 3);
// EXPECT_EQ(return_code, 0);
char
*
dt_out
=
nullptr
;
// NOLINT
bool
is_ref
[]
=
{
false
};
// NOLINT
// char *dt_out = nullptr; // NOLINT
bool
is_list
[]
=
{
false
};
// NOLINT
// bool is_ref[] = {false}; // NOLINT
return_code
=
caosdb_entity_property_get_datatype
(
&
property
,
&
dt_out
,
is_ref
,
is_list
);
// bool is_list[] = {false}; // NOLINT
EXPECT_EQ
(
return_code
,
0
);
// return_code = caosdb_entity_property_get_datatype(&property, &dt_out, is_ref, is_list);
EXPECT_STREQ
(
dt_out
,
"BOOLEAN"
);
// EXPECT_EQ(return_code, 0);
EXPECT_FALSE
(
*
is_ref
);
// EXPECT_STREQ(dt_out, "BOOLEAN");
EXPECT_TRUE
(
*
is_list
);
// EXPECT_FALSE(*is_ref);
// EXPECT_TRUE(*is_list);
int
length
=
-
1
;
// NOLINT
return_code
=
caosdb_entity_property_get_value_list_length
(
&
property
,
&
length
);
// int length = -1; // NOLINT
EXPECT_EQ
(
return_code
,
0
);
// return_code = caosdb_entity_property_get_value_list_length(&property, &length);
EXPECT_EQ
(
length
,
3
);
// EXPECT_EQ(return_code, 0);
// EXPECT_EQ(length, 3);
for
(
int
i
=
0
;
i
<
length
;
i
++
)
{
bool
out
=
true
;
// for (int i = 0; i < length; i++) {
return_code
=
caosdb_entity_property_get_boolean_list_value_at
(
&
property
,
&
out
,
i
);
// bool out = true;
EXPECT_EQ
(
return_code
,
0
);
// return_code = caosdb_entity_property_get_boolean_list_value_at(&property, &out, i);
EXPECT_EQ
(
value_list
[
i
],
out
);
// NOLINT
// EXPECT_EQ(return_code, 0);
}
// EXPECT_EQ(value_list[i], out); // NOLINT
// }
return_code
=
caosdb_entity_delete_property
(
&
property
);
EXPECT_EQ
(
return_code
,
0
);
// return_code = caosdb_entity_delete_property(&property);
}
// EXPECT_EQ(return_code, 0);
// }
TEST_F
(
test_ccaosdb
,
test_entity_with_parent_and_property
)
{
TEST_F
(
test_ccaosdb
,
test_entity_with_parent_and_property
)
{
caosdb_entity_parent
input_parent
;
caosdb_entity_parent
input_parent
;
...
@@ -392,8 +399,9 @@ TEST_F(test_ccaosdb, test_entity_with_parent_and_property) {
...
@@ -392,8 +399,9 @@ TEST_F(test_ccaosdb, test_entity_with_parent_and_property) {
caosdb_entity_property_set_id
(
&
input_property
,
"property_id"
);
caosdb_entity_property_set_id
(
&
input_property
,
"property_id"
);
caosdb_entity_property_set_name
(
&
input_property
,
"property_name"
);
caosdb_entity_property_set_name
(
&
input_property
,
"property_name"
);
caosdb_entity_property_set_datatype
(
&
input_property
,
"TEXT"
,
false
,
false
);
// TODO(fspreck)
caosdb_entity_property_set_string_value
(
&
input_property
,
"property_value"
);
// caosdb_entity_property_set_datatype(&input_property, "TEXT", false, false);
// caosdb_entity_property_set_string_value(&input_property, "property_value");
caosdb_entity_entity
entity
;
caosdb_entity_entity
entity
;
return_code
=
caosdb_entity_create_entity
(
&
entity
);
return_code
=
caosdb_entity_create_entity
(
&
entity
);
...
@@ -432,19 +440,21 @@ TEST_F(test_ccaosdb, test_entity_with_parent_and_property) {
...
@@ -432,19 +440,21 @@ TEST_F(test_ccaosdb, test_entity_with_parent_and_property) {
caosdb_entity_property_get_name
(
&
output_property
,
&
out
);
caosdb_entity_property_get_name
(
&
output_property
,
&
out
);
EXPECT_EQ
(
strcmp
(
in
,
out
),
0
);
EXPECT_EQ
(
strcmp
(
in
,
out
),
0
);
bool
is_list
[]
=
{
false
};
// NOLINT
// TODO(fspreck)
bool
is_ref
[]
=
{
false
};
// NOLINT
// bool is_list[] = {false}; // NOLINT
caosdb_entity_property_get_datatype
(
&
input_property
,
&
in
,
is_ref
,
is_list
);
// bool is_ref[] = {false}; // NOLINT
EXPECT_FALSE
(
*
is_list
);
// caosdb_entity_property_get_datatype(&input_property, &in, is_ref, is_list);
EXPECT_FALSE
(
*
is_ref
);
// EXPECT_FALSE(*is_list);
caosdb_entity_property_get_datatype
(
&
output_property
,
&
out
,
is_ref
,
is_list
);
// EXPECT_FALSE(*is_ref);
EXPECT_FALSE
(
*
is_list
);
// caosdb_entity_property_get_datatype(&output_property, &out, is_ref, is_list);
EXPECT_FALSE
(
*
is_ref
);
// EXPECT_FALSE(*is_list);
EXPECT_EQ
(
strcmp
(
in
,
out
),
0
);
// EXPECT_FALSE(*is_ref);
// EXPECT_EQ(strcmp(in, out), 0);
caosdb_entity_property_get_string_value
(
&
input_property
,
&
in
);
caosdb_entity_property_get_string_value
(
&
output_property
,
&
out
);
// TODO(fspreck)
EXPECT_EQ
(
strcmp
(
in
,
out
),
0
);
// caosdb_entity_property_get_string_value(&input_property, &in);
// caosdb_entity_property_get_string_value(&output_property, &out);
// EXPECT_EQ(strcmp(in, out), 0);
caosdb_entity_parent
output_parent
;
caosdb_entity_parent
output_parent
;
return_code
=
caosdb_entity_entity_get_parent
(
&
entity
,
&
output_parent
,
0
);
return_code
=
caosdb_entity_entity_get_parent
(
&
entity
,
&
output_parent
,
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