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
Commits
6cba107b
Verified
Commit
6cba107b
authored
3 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
WIP: test integer out of range
parent
4059f544
No related branches found
No related tags found
1 merge request
!14
Tests for f-int64
Pipeline
#12870
failed
3 years ago
Stage: info
Stage: setup
Stage: build
Stage: test
Changes
1
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_transaction.cpp
+48
-19
48 additions, 19 deletions
test/test_transaction.cpp
with
48 additions
and
19 deletions
test/test_transaction.cpp
+
48
−
19
View file @
6cba107b
...
@@ -142,7 +142,6 @@ auto test_transaction::getValueAs<int32_t>(const Value &value) -> int32_t {
...
@@ -142,7 +142,6 @@ auto test_transaction::getValueAs<int32_t>(const Value &value) -> int32_t {
return
static_cast
<
int32_t
>
(
value
.
AsInteger
());
return
static_cast
<
int32_t
>
(
value
.
AsInteger
());
}
}
template
<
>
template
<
>
auto
test_transaction
::
getValueAs
<
bool
>
(
const
Value
&
value
)
->
bool
{
auto
test_transaction
::
getValueAs
<
bool
>
(
const
Value
&
value
)
->
bool
{
return
value
.
AsBool
();
return
value
.
AsBool
();
...
@@ -700,8 +699,8 @@ TEST_F(test_transaction, test_query) {
...
@@ -700,8 +699,8 @@ TEST_F(test_transaction, test_query) {
/**
/**
* Test numeric values (template).
* Test numeric values (template).
*/
*/
template
<
typename
T
>
template
<
typename
T
,
typename
S
>
auto
test_numeric_values_impl
(
AtomicDataType
a_type
,
bool
cast_to_int64
)
->
void
{
auto
test_numeric_values_impl
(
AtomicDataType
a_type
)
->
void
{
const
auto
&
connection
=
const
auto
&
connection
=
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
...
@@ -718,11 +717,7 @@ auto test_numeric_values_impl(AtomicDataType a_type, bool cast_to_int64) -> void
...
@@ -718,11 +717,7 @@ auto test_numeric_values_impl(AtomicDataType a_type, bool cast_to_int64) -> void
prop
.
SetName
(
name
);
prop
.
SetName
(
name
);
prop
.
SetDataType
(
a_type
);
prop
.
SetDataType
(
a_type
);
std
::
cout
<<
"Setting value "
<<
value
<<
std
::
endl
;
std
::
cout
<<
"Setting value "
<<
value
<<
std
::
endl
;
if
(
cast_to_int64
)
{
prop
.
SetValue
(
static_cast
<
S
>
(
value
));
prop
.
SetValue
(
static_cast
<
int64_t
>
(
value
));
}
else
{
prop
.
SetValue
(
value
);
}
props_orig
.
push_back
(
prop
);
props_orig
.
push_back
(
prop
);
auto
i_stat
=
insert_transaction
->
InsertEntity
(
&
prop
);
auto
i_stat
=
insert_transaction
->
InsertEntity
(
&
prop
);
EXPECT_EQ
(
i_stat
,
StatusCode
::
READY
);
EXPECT_EQ
(
i_stat
,
StatusCode
::
READY
);
...
@@ -747,12 +742,14 @@ auto test_numeric_values_impl(AtomicDataType a_type, bool cast_to_int64) -> void
...
@@ -747,12 +742,14 @@ auto test_numeric_values_impl(AtomicDataType a_type, bool cast_to_int64) -> void
EXPECT_TRUE
(
t_stat
.
IsTerminated
());
EXPECT_TRUE
(
t_stat
.
IsTerminated
());
EXPECT_FALSE
(
t_stat
.
IsError
());
EXPECT_FALSE
(
t_stat
.
IsError
());
if
(
retrieve_transaction
->
GetResultSet
().
size
()
>
0
)
{
const
auto
result
=
retrieve_transaction
->
GetResultSet
().
at
(
0
);
const
auto
result
=
retrieve_transaction
->
GetResultSet
().
at
(
0
);
EXPECT_EQ
(
result
.
GetDataType
(),
a_type
);
EXPECT_EQ
(
result
.
GetDataType
(),
a_type
);
const
auto
&
retrieved_value
=
const
auto
&
retrieved_value
=
test_transaction
::
getValueAs
<
T
>
(
result
.
GetValue
());
test_transaction
::
getValueAs
<
T
>
(
result
.
GetValue
());
// std::cout << "retrieved_value: " << retrieved_value << std::endl;
// std::cout << "retrieved_value: " << retrieved_value << std::endl;
EXPECT_EQ
(
retrieved_value
,
value
);
EXPECT_EQ
(
retrieved_value
,
value
);
}
++
i
;
++
i
;
}
}
}
}
...
@@ -761,13 +758,45 @@ auto test_numeric_values_impl(AtomicDataType a_type, bool cast_to_int64) -> void
...
@@ -761,13 +758,45 @@ auto test_numeric_values_impl(AtomicDataType a_type, bool cast_to_int64) -> void
* Test numeric values (wrapper for types).
* Test numeric values (wrapper for types).
*/
*/
TEST_F
(
test_transaction
,
test_numeric_values
)
{
TEST_F
(
test_transaction
,
test_numeric_values
)
{
test_numeric_values_impl
<
double
>
(
AtomicDataType
::
DOUBLE
,
false
);
test_numeric_values_impl
<
double
,
double
>
(
AtomicDataType
::
DOUBLE
);
test_transaction
::
DeleteEntities
();
test_numeric_values_impl
<
int32_t
>
(
AtomicDataType
::
INTEGER
,
true
);
test_transaction
::
DeleteEntities
();
test_transaction
::
DeleteEntities
();
test_numeric_values_impl
<
bool
>
(
AtomicDataType
::
BOOLEAN
,
false
);
test_numeric_values_impl
<
int32_t
,
int64_t
>
(
AtomicDataType
::
INTEGER
);
test_transaction
::
DeleteEntities
();
test_transaction
::
DeleteEntities
();
test_numeric_values_impl
<
int64_t
>
(
AtomicDataType
::
INTEGER
,
false
);
test_numeric_values_impl
<
bool
,
bool
>
(
AtomicDataType
::
BOOLEAN
);
}
TEST_F
(
test_transaction
,
test_integer_out_of_range
)
{
const
auto
&
connection
=
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
// Insert entities
std
::
vector
<
int64_t
>
values
=
{
std
::
numeric_limits
<
int64_t
>::
max
(),
std
::
numeric_limits
<
int64_t
>::
min
()};
for
(
auto
value
:
values
)
{
auto
insert_transaction
(
connection
->
CreateTransaction
());
Entity
prop
;
prop
.
SetRole
(
Role
::
PROPERTY
);
const
auto
name
=
std
::
string
(
"Prop_"
)
+
std
::
to_string
(
value
);
prop
.
SetName
(
name
);
prop
.
SetDataType
(
AtomicDataType
::
INTEGER
);
prop
.
SetValue
(
value
);
auto
i_stat
=
insert_transaction
->
InsertEntity
(
&
prop
);
EXPECT_EQ
(
i_stat
,
StatusCode
::
READY
);
insert_transaction
->
ExecuteAsynchronously
();
auto
t_stat
=
insert_transaction
->
WaitForIt
();
EXPECT_TRUE
(
t_stat
.
IsTerminated
());
EXPECT_TRUE
(
t_stat
.
IsError
());
EXPECT_EQ
(
t_stat
.
GetCode
(),
StatusCode
::
GENERIC_TRANSACTION_ERROR
);
EXPECT_EQ
(
insert_transaction
->
GetResultSet
().
size
(),
1
);
EXPECT_TRUE
(
insert_transaction
->
GetResultSet
().
at
(
0
).
HasErrors
());
EXPECT_EQ
(
insert_transaction
->
GetResultSet
().
at
(
0
).
GetErrors
().
at
(
0
).
GetCode
(),
MessageCode
::
INTEGER_VALUE_OUT_OF_RANGE
);
}
}
}
// /*
// /*
...
...
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