Commit d89a6bfe authored by daniel.bub's avatar daniel.bub
Browse files

[ADD #83] add unittest for WReaderCSV -> test header and data

parent 4f103eab
......@@ -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() );
}
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment