Mercurial > hg > orthanc
comparison OrthancFramework/UnitTestsSources/JobsTests.cpp @ 4204:318c16cfccab
cppcheck
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 17 Sep 2020 16:18:01 +0200 |
parents | bf7b9edf6b81 |
children | 2ae905070221 |
comparison
equal
deleted
inserted
replaced
4203:4d42408da117 | 4204:318c16cfccab |
---|---|
166 DummyInstancesJob() : | 166 DummyInstancesJob() : |
167 trailingStepDone_(false) | 167 trailingStepDone_(false) |
168 { | 168 { |
169 } | 169 } |
170 | 170 |
171 DummyInstancesJob(const Json::Value& value) : | 171 explicit DummyInstancesJob(const Json::Value& value) : |
172 SetOfInstancesJob(value) | 172 SetOfInstancesJob(value) |
173 { | 173 { |
174 if (HasTrailingStep()) | 174 if (HasTrailingStep()) |
175 { | 175 { |
176 trailingStepDone_ = (GetPosition() == GetCommandsCount()); | 176 trailingStepDone_ = (GetPosition() == GetCommandsCount()); |
829 } | 829 } |
830 } | 830 } |
831 | 831 |
832 | 832 |
833 static bool CheckIdempotentSerialization(IJobUnserializer& unserializer, | 833 static bool CheckIdempotentSerialization(IJobUnserializer& unserializer, |
834 JobOperationValue& value) | 834 const JobOperationValue& value) |
835 { | 835 { |
836 Json::Value a = 42; | 836 Json::Value a = 42; |
837 value.Serialize(a); | 837 value.Serialize(a); |
838 | 838 |
839 std::unique_ptr<JobOperationValue> unserialized(unserializer.UnserializeValue(a)); | 839 std::unique_ptr<JobOperationValue> unserialized(unserializer.UnserializeValue(a)); |
1028 ASSERT_EQ("hello", tmp); | 1028 ASSERT_EQ("hello", tmp); |
1029 } | 1029 } |
1030 } | 1030 } |
1031 | 1031 |
1032 | 1032 |
1033 static bool IsSameTagValue(ParsedDicomFile& dicom1, | 1033 static bool IsSameTagValue(const ParsedDicomFile& dicom1, |
1034 ParsedDicomFile& dicom2, | 1034 const ParsedDicomFile& dicom2, |
1035 DicomTag tag) | 1035 DicomTag tag) |
1036 { | 1036 { |
1037 std::string a, b; | 1037 std::string a, b; |
1038 return (dicom1.GetTagValue(a, tag) && | 1038 return (dicom1.GetTagValue(a, tag) && |
1039 dicom2.GetTagValue(b, tag) && | 1039 dicom2.GetTagValue(b, tag) && |
1071 ASSERT_EQ(ResourceType_Series, modification.GetLevel()); | 1071 ASSERT_EQ(ResourceType_Series, modification.GetLevel()); |
1072 | 1072 |
1073 std::unique_ptr<ParsedDicomFile> second(source.Clone(true)); | 1073 std::unique_ptr<ParsedDicomFile> second(source.Clone(true)); |
1074 modification.Apply(*second); | 1074 modification.Apply(*second); |
1075 | 1075 |
1076 std::string s; | 1076 std::string t; |
1077 ASSERT_TRUE(second->GetTagValue(s, DICOM_TAG_STUDY_DESCRIPTION)); | 1077 ASSERT_TRUE(second->GetTagValue(t, DICOM_TAG_STUDY_DESCRIPTION)); |
1078 ASSERT_TRUE(s.empty()); | 1078 ASSERT_TRUE(t.empty()); |
1079 ASSERT_FALSE(second->GetTagValue(s, DICOM_TAG_SERIES_DESCRIPTION)); | 1079 ASSERT_FALSE(second->GetTagValue(t, DICOM_TAG_SERIES_DESCRIPTION)); |
1080 ASSERT_TRUE(second->GetTagValue(s, DICOM_TAG_PATIENT_NAME)); | 1080 ASSERT_TRUE(second->GetTagValue(t, DICOM_TAG_PATIENT_NAME)); |
1081 ASSERT_EQ("Test 4", s); | 1081 ASSERT_EQ("Test 4", t); |
1082 | 1082 |
1083 ASSERT_TRUE(IsSameTagValue(source, *modified, DICOM_TAG_STUDY_INSTANCE_UID)); | 1083 ASSERT_TRUE(IsSameTagValue(source, *modified, DICOM_TAG_STUDY_INSTANCE_UID)); |
1084 ASSERT_TRUE(IsSameTagValue(source, *second, DICOM_TAG_STUDY_INSTANCE_UID)); | 1084 ASSERT_TRUE(IsSameTagValue(source, *second, DICOM_TAG_STUDY_INSTANCE_UID)); |
1085 | 1085 |
1086 ASSERT_FALSE(IsSameTagValue(source, *second, DICOM_TAG_SERIES_INSTANCE_UID)); | 1086 ASSERT_FALSE(IsSameTagValue(source, *second, DICOM_TAG_SERIES_INSTANCE_UID)); |
1367 } | 1367 } |
1368 } | 1368 } |
1369 } | 1369 } |
1370 | 1370 |
1371 { | 1371 { |
1372 Json::Value s; | 1372 Json::Value t; |
1373 s["AllowStorageCommitment"] = false; | 1373 t["AllowStorageCommitment"] = false; |
1374 s["AET"] = "AET"; | 1374 t["AET"] = "AET"; |
1375 s["Host"] = "host"; | 1375 t["Host"] = "host"; |
1376 s["Port"] = "104"; | 1376 t["Port"] = "104"; |
1377 | 1377 |
1378 RemoteModalityParameters modality(s); | 1378 RemoteModalityParameters modality(t); |
1379 ASSERT_TRUE(modality.IsAdvancedFormatNeeded()); | 1379 ASSERT_TRUE(modality.IsAdvancedFormatNeeded()); |
1380 ASSERT_EQ("AET", modality.GetApplicationEntityTitle()); | 1380 ASSERT_EQ("AET", modality.GetApplicationEntityTitle()); |
1381 ASSERT_EQ("host", modality.GetHost()); | 1381 ASSERT_EQ("host", modality.GetHost()); |
1382 ASSERT_EQ(104u, modality.GetPortNumber()); | 1382 ASSERT_EQ(104u, modality.GetPortNumber()); |
1383 ASSERT_FALSE(modality.IsRequestAllowed(DicomRequestType_NAction)); | 1383 ASSERT_FALSE(modality.IsRequestAllowed(DicomRequestType_NAction)); |
1384 ASSERT_FALSE(modality.IsRequestAllowed(DicomRequestType_NEventReport)); | 1384 ASSERT_FALSE(modality.IsRequestAllowed(DicomRequestType_NEventReport)); |
1385 ASSERT_TRUE(modality.IsTranscodingAllowed()); | 1385 ASSERT_TRUE(modality.IsTranscodingAllowed()); |
1386 } | 1386 } |
1387 | 1387 |
1388 { | 1388 { |
1389 Json::Value s; | 1389 Json::Value t; |
1390 s["AllowNAction"] = false; | 1390 t["AllowNAction"] = false; |
1391 s["AllowNEventReport"] = true; | 1391 t["AllowNEventReport"] = true; |
1392 s["AET"] = "AET"; | 1392 t["AET"] = "AET"; |
1393 s["Host"] = "host"; | 1393 t["Host"] = "host"; |
1394 s["Port"] = "104"; | 1394 t["Port"] = "104"; |
1395 s["AllowTranscoding"] = false; | 1395 t["AllowTranscoding"] = false; |
1396 | 1396 |
1397 RemoteModalityParameters modality(s); | 1397 RemoteModalityParameters modality(t); |
1398 ASSERT_TRUE(modality.IsAdvancedFormatNeeded()); | 1398 ASSERT_TRUE(modality.IsAdvancedFormatNeeded()); |
1399 ASSERT_EQ("AET", modality.GetApplicationEntityTitle()); | 1399 ASSERT_EQ("AET", modality.GetApplicationEntityTitle()); |
1400 ASSERT_EQ("host", modality.GetHost()); | 1400 ASSERT_EQ("host", modality.GetHost()); |
1401 ASSERT_EQ(104u, modality.GetPortNumber()); | 1401 ASSERT_EQ(104u, modality.GetPortNumber()); |
1402 ASSERT_FALSE(modality.IsRequestAllowed(DicomRequestType_NAction)); | 1402 ASSERT_FALSE(modality.IsRequestAllowed(DicomRequestType_NAction)); |
1403 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_NEventReport)); | 1403 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_NEventReport)); |
1404 ASSERT_FALSE(modality.IsTranscodingAllowed()); | 1404 ASSERT_FALSE(modality.IsTranscodingAllowed()); |
1405 } | 1405 } |
1406 | 1406 |
1407 { | 1407 { |
1408 Json::Value s; | 1408 Json::Value t; |
1409 s["AllowNAction"] = true; | 1409 t["AllowNAction"] = true; |
1410 s["AllowNEventReport"] = true; | 1410 t["AllowNEventReport"] = true; |
1411 s["AET"] = "AET"; | 1411 t["AET"] = "AET"; |
1412 s["Host"] = "host"; | 1412 t["Host"] = "host"; |
1413 s["Port"] = "104"; | 1413 t["Port"] = "104"; |
1414 | 1414 |
1415 RemoteModalityParameters modality(s); | 1415 RemoteModalityParameters modality(t); |
1416 ASSERT_FALSE(modality.IsAdvancedFormatNeeded()); | 1416 ASSERT_FALSE(modality.IsAdvancedFormatNeeded()); |
1417 ASSERT_EQ("AET", modality.GetApplicationEntityTitle()); | 1417 ASSERT_EQ("AET", modality.GetApplicationEntityTitle()); |
1418 ASSERT_EQ("host", modality.GetHost()); | 1418 ASSERT_EQ("host", modality.GetHost()); |
1419 ASSERT_EQ(104u, modality.GetPortNumber()); | 1419 ASSERT_EQ(104u, modality.GetPortNumber()); |
1420 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_NAction)); | 1420 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_NAction)); |