Loading isis/src/base/objs/TrackingTable/TrackingTable.truth +4 −0 Original line number Diff line number Diff line Unit test for TrackingTable Testing default constructor ... Record added: fileName1.cub, 1 Testing constructor with a Table object ... Constructing Table ... First record : fileName1.cub, 1234567890 Loading isis/src/base/objs/TrackingTable/unitTest.cpp +38 −18 Original line number Diff line number Diff line Loading @@ -17,6 +17,22 @@ int main(int argc, char *argv[]) { try{ cout << "Unit test for TrackingTable\n" << endl; cout << endl; cout << "Testing default constructor ..." << endl; TrackingTable trackingTable1; trackingTable1.fileNameToIndex("fileName1.cub", "1"); Table tableOut1 = trackingTable1.toTable(); cout << "Record added: " << QString(tableOut1[0][0]) << ", " << QString(tableOut1[0][1]) << endl; cout << endl; cout << "Testing constructor with a Table object ..." << endl; cout << "Constructing Table ..." << endl; Loading @@ -24,7 +40,6 @@ int main(int argc, char *argv[]) { TableField fileNameField("FileName", TableField::Text, 50); TableField serialNumberField("SerialNumber", TableField::Text, 50); TableRecord record; record += fileNameField; record += serialNumberField; Loading @@ -46,17 +61,18 @@ int main(int argc, char *argv[]) { cout << "Second record: " << QString(tableIn[1][0]) << ", " << QString(tableIn[1][1]) << endl; cout << "Third record : " << QString(tableIn[2][0]) << ", " << QString(tableIn[2][1]) << endl; TrackingTable trackingTable(tableIn); TrackingTable trackingTable2(tableIn); cout << "TrackingTable object created" << endl; cout << endl; cout << "Testing the indexToFileName method ..." << endl; for (int i = 0; i < 4; i++) { try { cout << "FileName at index " << i << ": " << trackingTable.indexToFileName(i).name() << endl; cout << "FileName at index " << i << ": " << trackingTable2.indexToFileName(i).name() << endl; } catch (IException e) { cout << "FileName at index " << i << " does not exist and an exception is thrown." << endl; Loading @@ -66,46 +82,50 @@ int main(int argc, char *argv[]) { cout << endl; cout << "Testing the fileNameToIndex method ..." << endl; cout << "Index of FileName fileName1.cub: " << trackingTable.fileNameToIndex("fileName1.cub", "1234567890") << endl; << trackingTable2.fileNameToIndex("fileName1.cub", "1234567890") << endl; cout << "Index of FileName fileName2.cub: " << trackingTable.fileNameToIndex("fileName2.cub", "123") << endl; << trackingTable2.fileNameToIndex("fileName2.cub", "123") << endl; cout << "Index of FileName fileName3.cub: " << trackingTable.fileNameToIndex("fileName3.dat", "456789") << endl; << trackingTable2.fileNameToIndex("fileName3.dat", "456789") << endl; cout << "Index of the non-existent FileName fileName4.cub (demonstrating its addition): " << trackingTable.fileNameToIndex("fileName4.cub", "12345678901234567890") << endl; << trackingTable2.fileNameToIndex("fileName4.cub", "12345678901234567890") << endl; cout << endl; cout << "Testing the toTable method ..." << endl; Table tableOut = trackingTable.toTable(); Table tableOut2 = trackingTable2.toTable(); cout << "First record : " << QString(tableOut[0][0]) << ", " << QString(tableOut[0][1]) << endl; cout << "Second record: " << QString(tableOut[1][0]) << ", " << QString(tableOut[1][1]) << endl; cout << "Third record : " << QString(tableOut[2][0]) << ", " << QString(tableOut[2][1]) << endl; cout << "Fourth record: " << QString(tableOut[3][0]) << ", " << QString(tableOut[3][1]) << endl; cout << "First record : " << QString(tableOut2[0][0]) << ", " << QString(tableOut2[0][1]) << endl; cout << "Second record: " << QString(tableOut2[1][0]) << ", " << QString(tableOut2[1][1]) << endl; cout << "Third record : " << QString(tableOut2[2][0]) << ", " << QString(tableOut2[2][1]) << endl; cout << "Fourth record: " << QString(tableOut2[3][0]) << ", " << QString(tableOut2[3][1]) << endl; cout << endl; cout << "Creating a new TrackingTable object with the table returned from toTable method ..." << endl; TrackingTable trackingTable2(tableOut); TrackingTable trackingTable3(tableOut2); cout << "New TrackingTable object created" << endl; cout << endl; cout << "Testing that the Table returned from toTable on new TrackingTable matches ..." << endl; Table tableOut2 = trackingTable2.toTable(); Table tableOut3 = trackingTable3.toTable(); cout << "First record : " << QString(tableOut2[0][0]) << ", " << QString(tableOut2[0][1]) << endl; cout << "Second record: " << QString(tableOut2[1][0]) << ", " << QString(tableOut2[1][1]) << endl; cout << "Third record : " << QString(tableOut2[2][0]) << ", " << QString(tableOut2[2][1]) << endl; cout << "Fourth record: " << QString(tableOut2[3][0]) << ", " << QString(tableOut2[3][1]) << endl; cout << "First record : " << QString(tableOut3[0][0]) << ", " << QString(tableOut3[0][1]) << endl; cout << "Second record: " << QString(tableOut3[1][0]) << ", " << QString(tableOut3[1][1]) << endl; cout << "Third record : " << QString(tableOut3[2][0]) << ", " << QString(tableOut3[2][1]) << endl; cout << "Fourth record: " << QString(tableOut3[3][0]) << ", " << QString(tableOut3[3][1]) << endl; } catch (IException &e) { Loading Loading
isis/src/base/objs/TrackingTable/TrackingTable.truth +4 −0 Original line number Diff line number Diff line Unit test for TrackingTable Testing default constructor ... Record added: fileName1.cub, 1 Testing constructor with a Table object ... Constructing Table ... First record : fileName1.cub, 1234567890 Loading
isis/src/base/objs/TrackingTable/unitTest.cpp +38 −18 Original line number Diff line number Diff line Loading @@ -17,6 +17,22 @@ int main(int argc, char *argv[]) { try{ cout << "Unit test for TrackingTable\n" << endl; cout << endl; cout << "Testing default constructor ..." << endl; TrackingTable trackingTable1; trackingTable1.fileNameToIndex("fileName1.cub", "1"); Table tableOut1 = trackingTable1.toTable(); cout << "Record added: " << QString(tableOut1[0][0]) << ", " << QString(tableOut1[0][1]) << endl; cout << endl; cout << "Testing constructor with a Table object ..." << endl; cout << "Constructing Table ..." << endl; Loading @@ -24,7 +40,6 @@ int main(int argc, char *argv[]) { TableField fileNameField("FileName", TableField::Text, 50); TableField serialNumberField("SerialNumber", TableField::Text, 50); TableRecord record; record += fileNameField; record += serialNumberField; Loading @@ -46,17 +61,18 @@ int main(int argc, char *argv[]) { cout << "Second record: " << QString(tableIn[1][0]) << ", " << QString(tableIn[1][1]) << endl; cout << "Third record : " << QString(tableIn[2][0]) << ", " << QString(tableIn[2][1]) << endl; TrackingTable trackingTable(tableIn); TrackingTable trackingTable2(tableIn); cout << "TrackingTable object created" << endl; cout << endl; cout << "Testing the indexToFileName method ..." << endl; for (int i = 0; i < 4; i++) { try { cout << "FileName at index " << i << ": " << trackingTable.indexToFileName(i).name() << endl; cout << "FileName at index " << i << ": " << trackingTable2.indexToFileName(i).name() << endl; } catch (IException e) { cout << "FileName at index " << i << " does not exist and an exception is thrown." << endl; Loading @@ -66,46 +82,50 @@ int main(int argc, char *argv[]) { cout << endl; cout << "Testing the fileNameToIndex method ..." << endl; cout << "Index of FileName fileName1.cub: " << trackingTable.fileNameToIndex("fileName1.cub", "1234567890") << endl; << trackingTable2.fileNameToIndex("fileName1.cub", "1234567890") << endl; cout << "Index of FileName fileName2.cub: " << trackingTable.fileNameToIndex("fileName2.cub", "123") << endl; << trackingTable2.fileNameToIndex("fileName2.cub", "123") << endl; cout << "Index of FileName fileName3.cub: " << trackingTable.fileNameToIndex("fileName3.dat", "456789") << endl; << trackingTable2.fileNameToIndex("fileName3.dat", "456789") << endl; cout << "Index of the non-existent FileName fileName4.cub (demonstrating its addition): " << trackingTable.fileNameToIndex("fileName4.cub", "12345678901234567890") << endl; << trackingTable2.fileNameToIndex("fileName4.cub", "12345678901234567890") << endl; cout << endl; cout << "Testing the toTable method ..." << endl; Table tableOut = trackingTable.toTable(); Table tableOut2 = trackingTable2.toTable(); cout << "First record : " << QString(tableOut[0][0]) << ", " << QString(tableOut[0][1]) << endl; cout << "Second record: " << QString(tableOut[1][0]) << ", " << QString(tableOut[1][1]) << endl; cout << "Third record : " << QString(tableOut[2][0]) << ", " << QString(tableOut[2][1]) << endl; cout << "Fourth record: " << QString(tableOut[3][0]) << ", " << QString(tableOut[3][1]) << endl; cout << "First record : " << QString(tableOut2[0][0]) << ", " << QString(tableOut2[0][1]) << endl; cout << "Second record: " << QString(tableOut2[1][0]) << ", " << QString(tableOut2[1][1]) << endl; cout << "Third record : " << QString(tableOut2[2][0]) << ", " << QString(tableOut2[2][1]) << endl; cout << "Fourth record: " << QString(tableOut2[3][0]) << ", " << QString(tableOut2[3][1]) << endl; cout << endl; cout << "Creating a new TrackingTable object with the table returned from toTable method ..." << endl; TrackingTable trackingTable2(tableOut); TrackingTable trackingTable3(tableOut2); cout << "New TrackingTable object created" << endl; cout << endl; cout << "Testing that the Table returned from toTable on new TrackingTable matches ..." << endl; Table tableOut2 = trackingTable2.toTable(); Table tableOut3 = trackingTable3.toTable(); cout << "First record : " << QString(tableOut2[0][0]) << ", " << QString(tableOut2[0][1]) << endl; cout << "Second record: " << QString(tableOut2[1][0]) << ", " << QString(tableOut2[1][1]) << endl; cout << "Third record : " << QString(tableOut2[2][0]) << ", " << QString(tableOut2[2][1]) << endl; cout << "Fourth record: " << QString(tableOut2[3][0]) << ", " << QString(tableOut2[3][1]) << endl; cout << "First record : " << QString(tableOut3[0][0]) << ", " << QString(tableOut3[0][1]) << endl; cout << "Second record: " << QString(tableOut3[1][0]) << ", " << QString(tableOut3[1][1]) << endl; cout << "Third record : " << QString(tableOut3[2][0]) << ", " << QString(tableOut3[2][1]) << endl; cout << "Fourth record: " << QString(tableOut3[3][0]) << ", " << QString(tableOut3[3][1]) << endl; } catch (IException &e) { Loading