Skip to content
Snippets Groups Projects
Commit e815fc75 authored by Auke Klazema's avatar Auke Klazema
Browse files

SW-720: Convert golden output test to a unittest++ test

parent 5139b69c
No related branches found
No related tags found
1 merge request!6Import cobalt2 into lofar4
......@@ -24,6 +24,7 @@
#include <lofar_config.h>
//# Includes
#include <UnitTest++.h>
#include <Common/LofarLogger.h>
#include <Common/lofar_bitset.h>
#include <Common/lofar_map.h>
......@@ -32,51 +33,73 @@
using namespace LOFAR;
int main (int, char* argv[])
{
INIT_LOGGER(argv[0]);
// good file
CableAttenuation CA1("tCableAttenuation.in_1");
LOG_DEBUG_STR("Length 50 is " << (CA1.isLegalLength( 50) ? "" : "NOT") << " a legal length");
LOG_DEBUG_STR("Length 60 is " << (CA1.isLegalLength( 60) ? "" : "NOT") << " a legal length");
LOG_DEBUG_STR("Length 80 is " << (CA1.isLegalLength( 80) ? "" : "NOT") << " a legal length");
LOG_DEBUG_STR("Length 130 is " << (CA1.isLegalLength(130) ? "" : "NOT") << " a legal length");
SUITE(CableAttenuation) {
try {
CableAttenuation CA2("tCableAttenuation.in_2");
}
catch (Exception& ex) {
LOG_INFO_STR("Expected exception:" << ex.what());
}
TEST(legal_length) {
// good file
CableAttenuation CA1("tCableAttenuation.in_1");
// good length
CHECK_EQUAL(true, CA1.isLegalLength( 50));
CHECK_EQUAL(true, CA1.isLegalLength( 80));
CHECK_EQUAL(true, CA1.isLegalLength(130));
// bad length
CHECK_EQUAL(false, CA1.isLegalLength( 60));
}
try {
CableAttenuation CA3("tCableAttenuation.in_3");
}
catch (Exception& ex) {
LOG_INFO_STR("Expected exception:" << ex.what());
}
TEST(missing_line_for_rucmode_zero) {
try {
CableAttenuation CA2("tCableAttenuation.in_2");
CHECK(false);
}
catch (Exception& ex) {
// This should throw an exception. Good.
}
}
try {
CableAttenuation CA4("tCableAttenuation.in_4");
}
catch (Exception& ex) {
LOG_INFO_STR("Expected exception:" << ex.what());
}
TEST(lines_in_wrong_order) {
try {
CableAttenuation CA3("tCableAttenuation.in_3");
CHECK(false);
}
catch (Exception& ex) {
// This should throw and exception. Good.
}
}
try {
CableAttenuation CA5("tCableAttenuation.in_5");
}
catch (Exception& ex) {
LOG_INFO_STR("Expected exception:" << ex.what());
}
TEST(too_few_mode_lines) {
try {
CableAttenuation CA4("tCableAttenuation.in_4");
CHECK(false);
}
catch (Exception& ex) {
// This should throw and exception. Good.
}
}
try {
CableAttenuation CA6("tCableAttenuation.in_6");
}
catch (Exception& ex) {
LOG_INFO_STR("Expected exception:" << ex.what());
}
TEST(too_many_mode_lines) {
try {
CableAttenuation CA5("tCableAttenuation.in_5");
CHECK(false);
}
catch (Exception& ex) {
// This should throw and exception. Good.
}
}
TEST(missing_parameters_on_line) {
try {
CableAttenuation CA6("tCableAttenuation.in_6");
CHECK(false);
}
catch (Exception& ex) {
LOG_INFO_STR("Expected exception:" << ex.what());
}
}
}
int main (int, char* argv[])
{
INIT_LOGGER(argv[0]);
return UnitTest::RunAllTests() > 0;
}
\ No newline at end of file
DEBUG APL.PIC.RSP_Driver - Reading attenuations from file: ./tCableAttenuation.in_1 [CableAttenuation.cc:45]
DEBUG APL.PIC.RSP_Driver - Cable lenghts: 5
[ 50 80 85 115 130 ] [CableAttenuation.cc:80]
DEBUG APL.PIC.RSP_Driver - 8 x 5
[ 0 0 0 0 0
-2.05 -3.32 -3.53 -4.74 -5.4
-2.05 -3.32 -3.53 -4.74 -5.4
-2.05 -3.32 -3.53 -4.74 -5.4
-2.05 -3.32 -3.53 -4.74 -5.4
-3.64 -5.87 -6.22 -8.35 -9.52
-4.24 -6.82 -7.21 -9.7 -11.06
-4.46 -7.19 -7.58 -10.18 -11.61 ]
[CableAttenuation.cc:103]
DEBUG APL.PIC.RSP_Driver - Length 50 is a legal length [tCableAttenuation.cc:41]
DEBUG PIC.RSP_Driver.EXCEPTION - Assertion: false; Cablelength 60 is not a legal cablelength:5
[ 50 80 85 115 130 ] [CableAttenuation.cc:132]
DEBUG APL.PIC.RSP_Driver - Length 60 is NOT a legal length [tCableAttenuation.cc:42]
DEBUG APL.PIC.RSP_Driver - Length 80 is a legal length [tCableAttenuation.cc:43]
DEBUG APL.PIC.RSP_Driver - Length 130 is a legal length [tCableAttenuation.cc:44]
DEBUG APL.PIC.RSP_Driver - Reading attenuations from file: ./tCableAttenuation.in_2 [CableAttenuation.cc:45]
DEBUG PIC.RSP_Driver.EXCEPTION - Assertion: strToInt(column[0]) == 0; Table must begin with line for rcumode 0 [CableAttenuation.cc:70]
INFO APL.PIC.RSP_Driver - Expected exception:Assertion: strToInt(column[0]) == 0; Table must begin with line for rcumode 0 [tCableAttenuation.cc:50]
DEBUG APL.PIC.RSP_Driver - Reading attenuations from file: ./tCableAttenuation.in_3 [CableAttenuation.cc:45]
DEBUG APL.PIC.RSP_Driver - Cable lenghts: 5
[ 50 80 85 115 130 ] [CableAttenuation.cc:80]
DEBUG PIC.RSP_Driver.EXCEPTION - Assertion: rcuMode == prevRcuMode + 1; Expected line with rcumode 3 [CableAttenuation.cc:85]
INFO APL.PIC.RSP_Driver - Expected exception:Assertion: rcuMode == prevRcuMode + 1; Expected line with rcumode 3 [tCableAttenuation.cc:57]
DEBUG APL.PIC.RSP_Driver - Reading attenuations from file: ./tCableAttenuation.in_4 [CableAttenuation.cc:45]
DEBUG APL.PIC.RSP_Driver - Cable lenghts: 5
[ 50 80 85 115 130 ] [CableAttenuation.cc:80]
DEBUG PIC.RSP_Driver.EXCEPTION - Assertion: prevRcuMode == MAX_RCU_MODE; Expected settings for all 7 rcumodes. [CableAttenuation.cc:102]
INFO APL.PIC.RSP_Driver - Expected exception:Assertion: prevRcuMode == MAX_RCU_MODE; Expected settings for all 7 rcumodes. [tCableAttenuation.cc:64]
DEBUG APL.PIC.RSP_Driver - Reading attenuations from file: ./tCableAttenuation.in_5 [CableAttenuation.cc:45]
DEBUG APL.PIC.RSP_Driver - Cable lenghts: 5
[ 50 80 85 115 130 ] [CableAttenuation.cc:80]
DEBUG PIC.RSP_Driver.EXCEPTION - Assertion: rcuMode <= MAX_RCU_MODE; RCUmode 8 not in range [0..7] [CableAttenuation.cc:88]
INFO APL.PIC.RSP_Driver - Expected exception:Assertion: rcuMode <= MAX_RCU_MODE; RCUmode 8 not in range [0..7] [tCableAttenuation.cc:71]
DEBUG APL.PIC.RSP_Driver - Reading attenuations from file: ./tCableAttenuation.in_6 [CableAttenuation.cc:45]
DEBUG APL.PIC.RSP_Driver - Cable lenghts: 5
[ 50 80 85 115 130 ] [CableAttenuation.cc:80]
DEBUG PIC.RSP_Driver.EXCEPTION - Assertion: column.size() == nrOfColumns; Expected 6 fields on line: 4 -2.05 -3.32 [CableAttenuation.cc:86]
INFO APL.PIC.RSP_Driver - Expected exception:Assertion: column.size() == nrOfColumns; Expected 6 fields on line: 4 -2.05 -3.32 [tCableAttenuation.cc:78]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment