Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
d89a6bfe
Commit
d89a6bfe
authored
Mar 19, 2021
by
daniel.bub
Browse files
[ADD
#83
] add unittest for WReaderCSV -> test header and data
parent
4f103eab
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
1 deletion
+36
-1
src/modules/data/io/test/WReaderCSV_test.h
src/modules/data/io/test/WReaderCSV_test.h
+36
-1
No files found.
src/modules/data/io/test/WReaderCSV_test.h
View file @
d89a6bfe
...
...
@@ -90,7 +90,42 @@ public:
std
::
string
fileName
=
W_FIXTURE_PATH
+
"CSVs/valid.csv"
;
std
::
cout
<<
std
::
endl
<<
"Test loading of "
<<
fileName
<<
"."
<<
std
::
endl
;
TS_ASSERT_THROWS_NOTHING
(
WReaderCSV
(
fileName
).
read
()
);
WDataSetCSV
::
ContentSPtr
testHeader
=
WDataSetCSV
::
ContentSPtr
(
new
WDataSetCSV
::
Content
()
);
WDataSetCSV
::
ContentSPtr
testDataFirstRow
=
WDataSetCSV
::
ContentSPtr
(
new
WDataSetCSV
::
Content
()
);
WDataSetCSV
::
ContentSPtr
testDataLastRow
=
WDataSetCSV
::
ContentSPtr
(
new
WDataSetCSV
::
Content
()
);
testHeader
->
push_back
(
{
"PDGEncoding"
,
"trackID"
,
"parentID"
,
"trackLocalTime"
,
"time"
,
"edep"
,
"stepLength"
,
"trackLength"
,
"posX"
,
"posY"
,
"posZ"
,
"localPosX"
,
"localPosY"
,
"localPosZ"
,
"momDirX"
,
"momDirY"
,
"momDirZ"
,
"baseID"
,
"level1ID"
,
"level2ID"
,
"level3ID"
,
"level4ID"
,
"layerID"
,
"photonID"
,
"nPhantomCompton"
,
"nCrystalCompton"
,
"nPhantomRayleigh"
,
"nCrystalRayleigh"
,
"primaryID"
,
"sourcePosX"
,
"sourcePosY"
,
"sourcePosZ"
,
"sourceID"
,
"eventID"
,
"runID"
,
"axialPos"
,
"rotationAngle"
,
"volumeID"
,
"processName"
,
"comptVolName"
,
"RayleighVolName"
}
);
testDataFirstRow
->
push_back
(
{
"2212"
,
"1"
,
"0"
,
"4.20922e-09"
,
"4.20922e-09"
,
"0.0199097"
,
"0.0250083"
,
"725.314"
,
"-1.86984"
,
"4.55793"
,
"225.244"
,
"-1.86984"
,
"4.55793"
,
"0.0125"
,
"-0.00614681"
,
"0.0255574"
,
"0.999654"
,
"0"
,
"0"
,
"0"
,
"0"
,
"0"
,
"0"
,
"0"
,
"0"
,
"0"
,
"0"
,
"0"
,
"1"
,
"-0.154322"
,
"0.156973"
,
"-500"
,
"0"
,
"1"
,
"0"
,
"277.4"
,
"0"
,
"[0;1;0;3;-1;-1;-1;-1;-1;-1]"
,
"Transportation"
,
"NULL"
,
"NULL"
}
);
testDataLastRow
->
push_back
(
{
"2212"
,
"1"
,
"0"
,
"5.92057e-09"
,
"5.92057e-09"
,
"0.3312"
,
"0.025598"
,
"955.947"
,
"14.127"
,
"28.6775"
,
"454.394"
,
"14.127"
,
"28.6775"
,
"0.0125"
,
"0.216802"
,
"0.0338896"
,
"0.975627"
,
"1"
,
"22"
,
"0"
,
"0"
,
"0"
,
"0"
,
"0"
,
"0"
,
"0"
,
"0"
,
"0"
,
"1"
,
"-0.480459"
,
"0.0634152"
,
"-500"
,
"0"
,
"2"
,
"0"
,
"461.8"
,
"0"
,
"[0;2;22;3;-1;-1;-1;-1;-1;-1]"
,
"Transportation"
,
"NULL"
,
"NULL"
}
);
WReaderCSV
tmpCsvReader
(
fileName
);
TS_ASSERT_THROWS_NOTHING
(
tmpCsvReader
.
read
()
);
// compare headers
TS_ASSERT_EQUALS
(
tmpCsvReader
.
read
()
->
getHeader
()
->
front
(),
testHeader
->
front
()
);
// compare first data rows
TS_ASSERT_EQUALS
(
tmpCsvReader
.
read
()
->
getData
()
->
front
(),
testDataFirstRow
->
front
()
);
// compare last data rows
TS_ASSERT_EQUALS
(
tmpCsvReader
.
read
()
->
getData
()
->
back
(),
testDataLastRow
->
front
()
);
}
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment