11 using namespace boost::unit_test_framework;
18 void testInsertElement();
19 void testGetDeviceInfo();
20 void testCheckForDuplicateElements();
21 void testGetDeviceFileAndMapFileName();
22 void testErrorElemErrTypeStreamOperator();
23 void testDeviceInfoStreamOperator();
24 void testDeviceInfoMapStreamOperator();
25 void testErrorElemStreamOperator();
26 void testErrorListStreamOperator();
36 test_case* checkForDuplicateElementEntries =
38 test_case* testGetDeviceFileAndMapFileName =
40 test_case* testErrorElemErrTypeStreamOperator =
42 test_case* testDeviceInfoStreamOperator =
44 test_case* testDeviceInfoMapStreamOperator =
46 test_case* testErrorElemStreamOperator =
49 test_case* testErrorListStreamOperator =
51 add(insertElementsTestCase);
52 add(getDeviceInfoTestCase);
53 add(checkForDuplicateElementEntries);
54 add(testGetDeviceFileAndMapFileName);
55 add(testErrorElemErrTypeStreamOperator);
56 add(testDeviceInfoStreamOperator);
57 add(testDeviceInfoMapStreamOperator);
58 add(testErrorElemStreamOperator);
59 add(testErrorListStreamOperator);
64 framework::master_test_suite().p_name.value =
"DeviceInfoMap test suite";
72 std::string dMapFileName =
"dummy.map";
83 deviceInfoMap.
insert(deviceInfo1);
84 deviceInfoMap.
insert(deviceInfo2);
85 deviceInfoMap.
insert(deviceInfo3);
88 ptrList[0] = &deviceInfo1;
89 ptrList[1] = &deviceInfo2;
90 ptrList[2] = &deviceInfo3;
94 for(it = deviceInfoMap.
begin(), index = 0; (it != deviceInfoMap.
end()) && (index < 3); ++it, ++index) {
97 BOOST_CHECK(deviceInfoMap.
getSize() == 3);
101 std::string dMapFileName =
"dummy.map";
110 RegisterInfoMap.
insert(deviceInfo1);
111 RegisterInfoMap.
insert(deviceInfo2);
126 std::string dMapFileName =
"dummy.map";
127 std::string commonCardName =
"common_card";
145 RegisterInfoMap.
insert(deviceInfo1);
149 RegisterInfoMap.
insert(deviceInfo2);
150 RegisterInfoMap.
insert(deviceInfo3);
151 RegisterInfoMap.
insert(deviceInfo4);
155 int numberOfIncorrectLinesInFile = elementDuplications.
_errors.size();
156 BOOST_CHECK(numberOfIncorrectLinesInFile == 2);
158 std::list<ChimeraTK::DeviceInfoMap::ErrorList::ErrorElem>::iterator errorIterator;
159 for(errorIterator = elementDuplications.
_errors.begin(); errorIterator != elementDuplications.
_errors.end();
161 bool doesDetectedElementsHaveSameName =
162 (errorIterator->_errorDevice1.deviceName == errorIterator->_errorDevice2.deviceName);
163 BOOST_CHECK(doesDetectedElementsHaveSameName);
169 deviceInfo1.
uri =
"/dev/test";
172 std::pair<std::string, std::string> expected_pair(
"/dev/test",
"test_mapfile");
174 BOOST_CHECK(expected_pair == actual_pair);
178 std::stringstream file_stream1;
180 BOOST_CHECK(file_stream1.str() ==
"ERROR");
182 std::stringstream file_stream2;
184 BOOST_CHECK(file_stream2.str() ==
"WARNING");
186 std::stringstream file_stream3;
188 BOOST_CHECK(file_stream3.str() ==
"UNKNOWN");
193 deviceInfo1.
uri =
"/dev/dev1";
199 std::stringstream expected_file_stream;
200 expected_file_stream <<
"("
209 std::stringstream actual_file_stream;
210 actual_file_stream << deviceInfo1;
212 BOOST_CHECK(expected_file_stream.str() == actual_file_stream.str());
216 std::string dMapFileName =
"dummy.dmap";
221 deviceInfoMap.
insert(deviceInfo1);
223 std::stringstream expected_file_stream;
224 expected_file_stream <<
"=======================================" << std::endl;
225 expected_file_stream <<
"MAP FILE NAME: "
226 <<
"dummy.dmap" << std::endl;
227 expected_file_stream <<
"---------------------------------------" << std::endl;
229 expected_file_stream <<
"("
236 <<
"map_file" << std::endl;
238 expected_file_stream <<
"=======================================";
240 std::stringstream actual_file_stream;
241 actual_file_stream << deviceInfoMap;
242 BOOST_CHECK(expected_file_stream.str() == actual_file_stream.str());
246 std::string dMapFileName =
"dummy.map";
261 std::stringstream expected_file_stream;
263 <<
": Found two devices with the same name but different properties: \""
267 <<
"\" in line " << 1 <<
" and \""
269 <<
"\" in line " << 2;
271 std::stringstream actual_file_stream;
272 actual_file_stream << error_element;
274 BOOST_CHECK(expected_file_stream.str() == actual_file_stream.str());
278 std::string dMapFileName =
"dummy.dmap";
279 std::string commonCardName =
"card1";
295 RegisterInfoMap.
insert(deviceInfo1);
296 RegisterInfoMap.
insert(deviceInfo2);
299 std::stringstream expected_file_stream;
301 <<
": Found two devices with the same name but different properties: \""
305 <<
"\" in line " << 1 <<
" and \""
307 <<
"\" in line " << 2 << std::endl;
309 std::stringstream actual_file_stream;
310 actual_file_stream << elementDuplications;
312 BOOST_CHECK(expected_file_stream.str() == actual_file_stream.str());