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
GitLab 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
Open in Workspace
Download
Patches
Plain diff
Expand sidebar
Merged
Tests for f-int64
f-int64
into
dev
Overview
0
Commits
8
Pipelines
22
Changes
3
Merged
Tests for f-int64
Timm Fitschen
requested to merge
f-int64
into
dev
Aug 31, 2021
Overview
0
Commits
8
Pipelines
22
Changes
3
Tests for
caosdb-server!29 (merged)
,
caosdb-cpplib!22 (merged)
, and
caosdb-proto!4 (merged)
Edited
Sep 7, 2021
by
Timm Fitschen
0
0
Merge request reports
Compare
dev
version 8
396cced4
Sep 7, 2021
version 7
624a6944
Sep 3, 2021
version 6
27370f8f
Sep 3, 2021
version 5
c06aab20
Sep 3, 2021
version 4
c06aab20
Sep 1, 2021
version 3
6cba107b
Aug 31, 2021
version 2
4059f544
Aug 31, 2021
version 1
6c217189
Aug 31, 2021
dev (base)
and
latest version
latest version
7843b3e3
8 commits,
Sep 7, 2021
version 8
396cced4
7 commits,
Sep 7, 2021
version 7
624a6944
6 commits,
Sep 3, 2021
version 6
27370f8f
5 commits,
Sep 3, 2021
version 5
c06aab20
4 commits,
Sep 3, 2021
version 4
c06aab20
9 commits,
Sep 1, 2021
version 3
6cba107b
5 commits,
Aug 31, 2021
version 2
4059f544
4 commits,
Aug 31, 2021
version 1
6c217189
3 commits,
Aug 31, 2021
3 files
+
169
−
15
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
test/test_list_properties.cpp
+
113
−
0
View file @ 7843b3e3
Edit in single-file editor
Open in Web IDE
Show full file
@@ -24,6 +24,7 @@
@@ -24,6 +24,7 @@
#include
"caosdb/transaction.h"
// for Entity, Transaction,...
#include
"caosdb/transaction.h"
// for Entity, Transaction,...
#include
"caosdb/transaction_status.h"
// for TransactionStatus, StatusCode
#include
"caosdb/transaction_status.h"
// for TransactionStatus, StatusCode
#include
"caosdb/value.h"
// for value
#include
"caosdb/value.h"
// for value
#include
<cstdint>
// for int64_t
#include
<gtest/gtest-message.h>
// for Message
#include
<gtest/gtest-message.h>
// for Message
#include
<gtest/gtest-test-part.h>
// for TestPartResult, SuiteApiResolver
#include
<gtest/gtest-test-part.h>
// for TestPartResult, SuiteApiResolver
#include
<gtest/gtest_pred_impl.h>
// for Test, EXPECT_EQ, AssertionResult
#include
<gtest/gtest_pred_impl.h>
// for Test, EXPECT_EQ, AssertionResult
@@ -113,4 +114,116 @@ TEST_F(test_list_properties, insert_list_of_text) {
@@ -113,4 +114,116 @@ TEST_F(test_list_properties, insert_list_of_text) {
EXPECT_EQ
(
value
.
AsList
().
at
(
1
).
AsString
(),
"item5"
);
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
}
// namespace caosdb::entity
Loading