Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-cppinttest
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-cppinttest
Merge requests
!14
Tests for f-int64
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Tests for f-int64
f-int64
into
dev
Overview
0
Commits
8
Pipelines
22
Changes
3
Merged
Timm Fitschen
requested to merge
f-int64
into
dev
3 years ago
Overview
0
Commits
8
Pipelines
22
Changes
3
Expand
Tests for
caosdb-server!29 (merged)
,
caosdb-cpplib!22 (merged)
, and
caosdb-proto!4 (merged)
Edited
3 years ago
by
Timm Fitschen
0
0
Merge request reports
Compare
dev
version 8
396cced4
3 years ago
version 7
624a6944
3 years ago
version 6
27370f8f
3 years ago
version 5
c06aab20
3 years ago
version 4
c06aab20
3 years ago
version 3
6cba107b
3 years ago
version 2
4059f544
3 years ago
version 1
6c217189
3 years ago
dev (base)
and
latest version
latest version
7843b3e3
8 commits,
3 years ago
version 8
396cced4
7 commits,
3 years ago
version 7
624a6944
6 commits,
3 years ago
version 6
27370f8f
5 commits,
3 years ago
version 5
c06aab20
4 commits,
3 years ago
version 4
c06aab20
9 commits,
3 years ago
version 3
6cba107b
5 commits,
3 years ago
version 2
4059f544
4 commits,
3 years ago
version 1
6c217189
3 commits,
3 years ago
3 files
+
169
−
15
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
test/test_list_properties.cpp
+
113
−
0
Options
@@ -24,6 +24,7 @@
#include
"caosdb/transaction.h"
// for Entity, Transaction,...
#include
"caosdb/transaction_status.h"
// for TransactionStatus, StatusCode
#include
"caosdb/value.h"
// for value
#include
<cstdint>
// for int64_t
#include
<gtest/gtest-message.h>
// for Message
#include
<gtest/gtest-test-part.h>
// for TestPartResult, SuiteApiResolver
#include
<gtest/gtest_pred_impl.h>
// for Test, EXPECT_EQ, AssertionResult
@@ -113,4 +114,116 @@ TEST_F(test_list_properties, insert_list_of_text) {
EXPECT_EQ
(
value
.
AsList
().
at
(
1
).
AsString
(),
"item5"
);
}
TEST_F
(
test_list_properties
,
insert_list_of_int
)
{
const
auto
&
connection
=
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
auto
insertion_prop
(
connection
->
CreateTransaction
());
Entity
abstract_list_property
;
abstract_list_property
.
SetRole
(
Role
::
PROPERTY
);
abstract_list_property
.
SetName
(
"TestProp"
);
abstract_list_property
.
SetDataType
(
DataType
::
ListOf
(
AtomicDataType
::
INTEGER
));
abstract_list_property
.
SetValue
(
std
::
vector
<
int64_t
>
{
1
,
2
,
3
});
insertion_prop
->
InsertEntity
(
&
abstract_list_property
);
std
::
cout
<<
"response "
<<
insertion_prop
->
ResponseToString
();
insertion_prop
->
Execute
();
EXPECT_TRUE
(
insertion_prop
->
GetStatus
().
IsTerminated
());
auto
insertion_rt
(
connection
->
CreateTransaction
());
Property
list_property
;
list_property
.
SetId
(
insertion_prop
->
GetResultSet
().
at
(
0
).
GetId
());
list_property
.
SetValue
(
std
::
vector
<
int64_t
>
{
4
,
5
,
6
});
Entity
entity
;
entity
.
SetRole
(
Role
::
RECORD_TYPE
);
entity
.
SetName
(
"TestRT"
);
entity
.
AppendProperty
(
list_property
);
insertion_rt
->
InsertEntity
(
&
entity
);
std
::
cout
<<
"response "
<<
insertion_rt
->
ResponseToString
();
insertion_rt
->
Execute
();
EXPECT_TRUE
(
insertion_rt
->
GetStatus
().
IsTerminated
());
EXPECT_FALSE
(
insertion_rt
->
GetStatus
().
IsError
());
// retrieve and check again
auto
retrieval
(
connection
->
CreateTransaction
());
retrieval
->
RetrieveById
(
insertion_rt
->
GetResultSet
().
at
(
0
).
GetId
());
retrieval
->
Execute
();
EXPECT_TRUE
(
retrieval
->
GetStatus
().
IsTerminated
());
EXPECT_FALSE
(
retrieval
->
GetStatus
().
IsError
());
const
auto
&
same_entity
=
retrieval
->
GetResultSet
().
at
(
0
);
const
auto
&
data_type
=
same_entity
.
GetProperties
().
at
(
0
).
GetDataType
();
const
auto
&
value
=
same_entity
.
GetProperties
().
at
(
0
).
GetValue
();
EXPECT_TRUE
(
data_type
.
IsList
());
EXPECT_TRUE
(
data_type
.
AsList
().
IsListOfAtomic
());
EXPECT_EQ
(
data_type
.
AsList
().
GetAtomicDataType
(),
AtomicDataType
::
INTEGER
);
EXPECT_TRUE
(
value
.
IsList
());
EXPECT_EQ
(
value
.
AsList
().
size
(),
3
);
EXPECT_TRUE
(
value
.
AsList
().
at
(
1
).
IsInteger
());
EXPECT_EQ
(
value
.
AsList
().
at
(
1
).
AsInteger
(),
5
);
}
TEST_F
(
test_list_properties
,
insert_list_of_bool
)
{
const
auto
&
connection
=
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
auto
insertion_prop
(
connection
->
CreateTransaction
());
Entity
abstract_list_property
;
abstract_list_property
.
SetRole
(
Role
::
PROPERTY
);
abstract_list_property
.
SetName
(
"TestProp"
);
abstract_list_property
.
SetDataType
(
DataType
::
ListOf
(
AtomicDataType
::
BOOLEAN
));
abstract_list_property
.
SetValue
(
std
::
vector
<
bool
>
{
true
,
true
,
false
});
insertion_prop
->
InsertEntity
(
&
abstract_list_property
);
std
::
cout
<<
"response "
<<
insertion_prop
->
ResponseToString
();
insertion_prop
->
Execute
();
EXPECT_TRUE
(
insertion_prop
->
GetStatus
().
IsTerminated
());
auto
insertion_rt
(
connection
->
CreateTransaction
());
Property
list_property
;
list_property
.
SetId
(
insertion_prop
->
GetResultSet
().
at
(
0
).
GetId
());
list_property
.
SetValue
(
std
::
vector
<
bool
>
{
false
,
false
,
true
});
Entity
entity
;
entity
.
SetRole
(
Role
::
RECORD_TYPE
);
entity
.
SetName
(
"TestRT"
);
entity
.
AppendProperty
(
list_property
);
insertion_rt
->
InsertEntity
(
&
entity
);
std
::
cout
<<
"response "
<<
insertion_rt
->
ResponseToString
();
insertion_rt
->
Execute
();
EXPECT_TRUE
(
insertion_rt
->
GetStatus
().
IsTerminated
());
EXPECT_FALSE
(
insertion_rt
->
GetStatus
().
IsError
());
// retrieve and check again
auto
retrieval
(
connection
->
CreateTransaction
());
retrieval
->
RetrieveById
(
insertion_rt
->
GetResultSet
().
at
(
0
).
GetId
());
retrieval
->
Execute
();
EXPECT_TRUE
(
retrieval
->
GetStatus
().
IsTerminated
());
EXPECT_FALSE
(
retrieval
->
GetStatus
().
IsError
());
const
auto
&
same_entity
=
retrieval
->
GetResultSet
().
at
(
0
);
const
auto
&
data_type
=
same_entity
.
GetProperties
().
at
(
0
).
GetDataType
();
const
auto
&
value
=
same_entity
.
GetProperties
().
at
(
0
).
GetValue
();
EXPECT_TRUE
(
data_type
.
IsList
());
EXPECT_TRUE
(
data_type
.
AsList
().
IsListOfAtomic
());
EXPECT_EQ
(
data_type
.
AsList
().
GetAtomicDataType
(),
AtomicDataType
::
BOOLEAN
);
EXPECT_TRUE
(
value
.
IsList
());
EXPECT_EQ
(
value
.
AsList
().
size
(),
3
);
EXPECT_TRUE
(
value
.
AsList
().
at
(
1
).
IsBool
());
EXPECT_FALSE
(
value
.
AsList
().
at
(
1
).
AsBool
());
}
}
// namespace caosdb::entity
Loading