Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
athena
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
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
Davide Di Croce
athena
Commits
d5f380b4
Commit
d5f380b4
authored
1 year ago
by
Evgeny Alexandrov
Committed by
Tadej Novak
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
improve Json2Cool_test
improve Json2Cool_test
parent
9b52a4db
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Database/IOVDbSvc/test/Json2Cool_test.cxx
+79
-9
79 additions, 9 deletions
Database/IOVDbSvc/test/Json2Cool_test.cxx
with
79 additions
and
9 deletions
Database/IOVDbSvc/test/Json2Cool_test.cxx
+
79
−
9
View file @
d5f380b4
...
...
@@ -32,6 +32,7 @@
#include
"CoolKernel/Record.h"
#include
"CxxUtils/checker_macros.h"
#include
"CxxUtils/base64.h"
#include
<istream>
#include
<string>
...
...
@@ -65,12 +66,13 @@ BOOST_AUTO_TEST_SUITE(Json2CoolTest)
}
BOOST_AUTO_TEST_CASE
(
parsePayloadSpec
){
const
std
::
string
testSpecString
=
"crate: UChar, ROB: Int32, BCIDOffset: Int16, AName: String255"
;
const
std
::
string
testSpecString
=
"crate: UChar, ROB: Int32, BCIDOffset: Int16, AName: String255
, fTest: Float
"
;
auto
*
referenceSpec
=
new
cool
::
RecordSpecification
();
referenceSpec
->
extend
(
"crate"
,
StorageType
::
UChar
);
referenceSpec
->
extend
(
"ROB"
,
StorageType
::
Int32
);
referenceSpec
->
extend
(
"BCIDOffset"
,
StorageType
::
Int16
);
referenceSpec
->
extend
(
"AName"
,
StorageType
::
String255
);
referenceSpec
->
extend
(
"fTest"
,
StorageType
::
Float
);
auto
*
returnedSpec
=
Json2Cool
::
parsePayloadSpec
(
testSpecString
);
BOOST_CHECK
(
*
(
returnedSpec
)
==
*
static_cast
<
const
cool
::
IRecordSpecification
*>
(
referenceSpec
));
}
...
...
@@ -78,30 +80,98 @@ BOOST_AUTO_TEST_SUITE(Json2CoolTest)
auto
*
referenceSpec
=
new
cool
::
RecordSpecification
();
referenceSpec
->
extend
(
"crate"
,
StorageType
::
UChar
);
referenceSpec
->
extend
(
"ROB"
,
StorageType
::
Int32
);
referenceSpec
->
extend
(
"ROB1"
,
StorageType
::
Int32
);
referenceSpec
->
extend
(
"BCIDOffset"
,
StorageType
::
Int16
);
referenceSpec
->
extend
(
"AName"
,
StorageType
::
String255
);
const
std
::
string
jsonValues
=
"[
\"
1
\"
,
\"
2
\"
,
\"
3
\"
,
\"
purple
\"
]"
;
std
::
istringstream
initializerStream
(
jsonValues
);
nlohmann
::
json
j
;
initializerStream
>>
j
;
auto
record
=
Json2Cool
::
createAttributeList
(
referenceSpec
,
j
);
referenceSpec
->
extend
(
"fnTest1"
,
StorageType
::
Float
);
referenceSpec
->
extend
(
"fnTest2"
,
StorageType
::
Float
);
referenceSpec
->
extend
(
"fsTest1"
,
StorageType
::
Float
);
referenceSpec
->
extend
(
"fsTest2"
,
StorageType
::
Float
);
referenceSpec
->
extend
(
"dnTest1"
,
StorageType
::
Double
);
referenceSpec
->
extend
(
"dnTest2"
,
StorageType
::
Double
);
referenceSpec
->
extend
(
"dsTest1"
,
StorageType
::
Double
);
referenceSpec
->
extend
(
"dsTest2"
,
StorageType
::
Double
);
referenceSpec
->
extend
(
"blobTest"
,
StorageType
::
Blob16M
);
nlohmann
::
json
j
=
nlohmann
::
json
::
array
();
cool
::
Record
reference
(
*
referenceSpec
);
BOOST_CHECK
(
record
.
size
()
==
reference
.
size
());
//
auto
&
att0
ATLAS_THREAD_SAFE
=
const_cast
<
coral
::
Attribute
&>
(
reference
.
attributeList
()[
0
]);
unsigned
char
set0
(
1
);
att0
.
setValue
<
unsigned
char
>
(
set0
);
j
.
push_back
(
set0
);
//
auto
&
att1
ATLAS_THREAD_SAFE
=
const_cast
<
coral
::
Attribute
&>
(
reference
.
attributeList
()[
1
]);
att1
.
setValue
<
int
>
(
2
);
j
.
push_back
(
2
);
//
auto
&
att2
ATLAS_THREAD_SAFE
=
const_cast
<
coral
::
Attribute
&>
(
reference
.
attributeList
()[
2
]);
auto
&
att1_
ATLAS_THREAD_SAFE
=
const_cast
<
coral
::
Attribute
&>
(
reference
.
attributeList
()[
2
]);
att1_
.
setValue
<
int
>
(
4
);
std
::
ostringstream
ss2
;
ss2
<<
4
;
j
.
push_back
(
ss2
.
str
());
//
auto
&
att2
ATLAS_THREAD_SAFE
=
const_cast
<
coral
::
Attribute
&>
(
reference
.
attributeList
()[
3
]);
short
set2
(
3
);
att2
.
setValue
<
short
>
(
set2
);
j
.
push_back
(
set2
);
//
auto
&
att3
ATLAS_THREAD_SAFE
=
const_cast
<
coral
::
Attribute
&>
(
reference
.
attributeList
()[
3
]);
auto
&
att3
ATLAS_THREAD_SAFE
=
const_cast
<
coral
::
Attribute
&>
(
reference
.
attributeList
()[
4
]);
att3
.
setValue
<
std
::
string
>
(
"purple"
);
j
.
push_back
(
"purple"
);
//
auto
&
att4
ATLAS_THREAD_SAFE
=
const_cast
<
coral
::
Attribute
&>
(
reference
.
attributeList
()[
5
]);
float
set4
(
1.01
);
att4
.
setValue
<
float
>
(
set4
);
j
.
push_back
(
set4
);
//
auto
&
att5
ATLAS_THREAD_SAFE
=
const_cast
<
coral
::
Attribute
&>
(
reference
.
attributeList
()[
6
]);
float
set5
(
1
);
att5
.
setValue
<
float
>
(
set5
);
j
.
push_back
(
set5
);
//
auto
&
att6
ATLAS_THREAD_SAFE
=
const_cast
<
coral
::
Attribute
&>
(
reference
.
attributeList
()[
7
]);
float
set6
(
1.02
);
att6
.
setValue
<
float
>
(
set6
);
j
.
push_back
(
std
::
to_string
(
set6
));
//
auto
&
att7
ATLAS_THREAD_SAFE
=
const_cast
<
coral
::
Attribute
&>
(
reference
.
attributeList
()[
8
]);
float
set7
(
2
);
att7
.
setValue
<
float
>
(
set7
);
j
.
push_back
(
std
::
to_string
(
set7
));
//
auto
&
att8
ATLAS_THREAD_SAFE
=
const_cast
<
coral
::
Attribute
&>
(
reference
.
attributeList
()[
9
]);
double
set8
(
1.01
);
att8
.
setValue
<
double
>
(
set8
);
j
.
push_back
(
set8
);
//
auto
&
att9
ATLAS_THREAD_SAFE
=
const_cast
<
coral
::
Attribute
&>
(
reference
.
attributeList
()[
10
]);
double
set9
(
1
);
att9
.
setValue
<
double
>
(
set9
);
j
.
push_back
(
set9
);
//
auto
&
att10
ATLAS_THREAD_SAFE
=
const_cast
<
coral
::
Attribute
&>
(
reference
.
attributeList
()[
11
]);
double
set10
(
1.02
);
att10
.
setValue
<
double
>
(
set10
);
j
.
push_back
(
std
::
to_string
(
set10
));
//
auto
&
att11
ATLAS_THREAD_SAFE
=
const_cast
<
coral
::
Attribute
&>
(
reference
.
attributeList
()[
12
]);
double
set11
(
2
);
att11
.
setValue
<
double
>
(
set11
);
j
.
push_back
(
std
::
to_string
(
set11
));
//
auto
&
att12
ATLAS_THREAD_SAFE
=
const_cast
<
coral
::
Attribute
&>
(
reference
.
attributeList
()[
13
]);
std
::
stringstream
p
;
unsigned
char
myString
[]
=
"This is my BLOB"
;
const
coral
::
Blob
bl
(
strlen
((
char
*
)
myString
));
att12
.
setValue
<
coral
::
Blob
>
(
bl
);
const
auto
address
=
static_cast
<
const
unsigned
char
*>
(
bl
.
startingAddress
());
const
unsigned
int
nBytes
=
bl
.
size
();
std
::
string
str
=
CxxUtils
::
base64_encode
(
address
,
nBytes
);
j
.
push_back
(
str
);
auto
record
=
Json2Cool
::
createAttributeList
(
referenceSpec
,
j
);
BOOST_CHECK
(
record
.
size
()
==
reference
.
size
());
BOOST_CHECK
(
reference
==
record
);
}
...
...
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