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
1e3386e6
Verified
Commit
1e3386e6
authored
3 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
TST: add tests for ccaosdb
parent
cba6eb76
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!22
Return to int64 for integer values
Pipeline
#13203
passed
3 years ago
Stage: info
Stage: setup
Stage: test
Stage: deploy
Pipeline: caosdb-cppinttest
#13219
Pipeline: caosdb-cppinttest
#13217
Pipeline: caosdb-cppinttest
#13204
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_ccaosdb.cpp
+82
-5
82 additions, 5 deletions
test/test_ccaosdb.cpp
with
82 additions
and
5 deletions
test/test_ccaosdb.cpp
+
82
−
5
View file @
1e3386e6
...
...
@@ -24,6 +24,7 @@
#include
"caosdb/status_code.h"
// for StatusCode
#include
"caosdb_test_utility.h"
// for EXPECT_THROW_MESSAGE, TEST_DATA_DIR
#include
"ccaosdb.h"
// for caosdb_utility_get_env_fallback
#include
<cstdint>
// for int64_t
#include
<cstring>
// for strcmp
#include
<gtest/gtest-message.h>
// for Message
#include
<gtest/gtest-test-part.h>
// for SuiteApiResolver, TestFactoryImpl
...
...
@@ -263,7 +264,7 @@ TEST_F(test_ccaosdb, test_property) {
EXPECT_EQ
(
return_code
,
0
);
}
TEST_F
(
test_ccaosdb
,
test_list_property
)
{
TEST_F
(
test_ccaosdb
,
test_
string_
list_property
)
{
caosdb_entity_property
property
;
int
return_code
(
caosdb_entity_create_property
(
&
property
));
...
...
@@ -285,12 +286,12 @@ TEST_F(test_ccaosdb, test_list_property) {
EXPECT_FALSE
(
*
is_ref
);
EXPECT_TRUE
(
*
is_list
);
int
length
[]
=
{
0
}
;
// NOLINT
return_code
=
caosdb_entity_property_get_value_list_length
(
&
property
,
length
);
int
length
=
-
1
;
// NOLINT
return_code
=
caosdb_entity_property_get_value_list_length
(
&
property
,
&
length
);
EXPECT_EQ
(
return_code
,
0
);
EXPECT_EQ
(
*
length
,
3
);
EXPECT_EQ
(
length
,
3
);
for
(
int
i
=
0
;
i
<
*
length
;
i
++
)
{
for
(
int
i
=
0
;
i
<
length
;
i
++
)
{
return_code
=
caosdb_entity_property_get_string_list_value_at
(
&
property
,
&
out
,
i
);
EXPECT_EQ
(
return_code
,
0
);
EXPECT_EQ
(
strcmp
(
value_list
[
i
],
out
),
0
);
// NOLINT
...
...
@@ -300,6 +301,82 @@ TEST_F(test_ccaosdb, test_list_property) {
EXPECT_EQ
(
return_code
,
0
);
}
TEST_F
(
test_ccaosdb
,
test_int_list_property
)
{
caosdb_entity_property
property
;
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
);
const
int64_t
value_list
[]
=
{
1
,
2
,
3
};
// NOLINT
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
bool
is_list
[]
=
{
false
};
// NOLINT
return_code
=
caosdb_entity_property_get_datatype
(
&
property
,
&
dt_out
,
is_ref
,
is_list
);
EXPECT_EQ
(
return_code
,
0
);
EXPECT_STREQ
(
dt_out
,
"INTEGER"
);
EXPECT_FALSE
(
*
is_ref
);
EXPECT_TRUE
(
*
is_list
);
int
length
=
-
1
;
// NOLINT
return_code
=
caosdb_entity_property_get_value_list_length
(
&
property
,
&
length
);
EXPECT_EQ
(
return_code
,
0
);
EXPECT_EQ
(
length
,
3
);
for
(
int
i
=
0
;
i
<
length
;
i
++
)
{
int64_t
out
=
-
1
;
return_code
=
caosdb_entity_property_get_int_list_value_at
(
&
property
,
&
out
,
i
);
EXPECT_EQ
(
return_code
,
0
);
EXPECT_EQ
(
value_list
[
i
],
out
);
// NOLINT
}
return_code
=
caosdb_entity_delete_property
(
&
property
);
EXPECT_EQ
(
return_code
,
0
);
}
TEST_F
(
test_ccaosdb
,
test_bool_list_property
)
{
caosdb_entity_property
property
;
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
);
const
bool
value_list
[]
=
{
true
,
true
,
false
};
// NOLINT
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
bool
is_list
[]
=
{
false
};
// NOLINT
return_code
=
caosdb_entity_property_get_datatype
(
&
property
,
&
dt_out
,
is_ref
,
is_list
);
EXPECT_EQ
(
return_code
,
0
);
EXPECT_STREQ
(
dt_out
,
"BOOLEAN"
);
EXPECT_FALSE
(
*
is_ref
);
EXPECT_TRUE
(
*
is_list
);
int
length
=
-
1
;
// NOLINT
return_code
=
caosdb_entity_property_get_value_list_length
(
&
property
,
&
length
);
EXPECT_EQ
(
return_code
,
0
);
EXPECT_EQ
(
length
,
3
);
for
(
int
i
=
0
;
i
<
length
;
i
++
)
{
bool
out
=
true
;
return_code
=
caosdb_entity_property_get_boolean_list_value_at
(
&
property
,
&
out
,
i
);
EXPECT_EQ
(
return_code
,
0
);
EXPECT_EQ
(
value_list
[
i
],
out
);
// NOLINT
}
return_code
=
caosdb_entity_delete_property
(
&
property
);
EXPECT_EQ
(
return_code
,
0
);
}
TEST_F
(
test_ccaosdb
,
test_entity_with_parent_and_property
)
{
caosdb_entity_parent
input_parent
;
int
return_code
(
caosdb_entity_create_parent
(
&
input_parent
));
...
...
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