comparison UnitTestsSources/FromDcmtkTests.cpp @ 2445:6e5bc5c6d1a4

Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 14 Dec 2017 13:02:06 +0100
parents 82d5e305fbd9
children 878b59270859
comparison
equal deleted inserted replaced
2444:d9e3781d2023 2445:6e5bc5c6d1a4
1248 1248
1249 TEST(Toolbox, CaseWithAccents) 1249 TEST(Toolbox, CaseWithAccents)
1250 { 1250 {
1251 ASSERT_EQ(toUpperResult, Toolbox::ToUpperCaseWithAccents(toUpperSource)); 1251 ASSERT_EQ(toUpperResult, Toolbox::ToUpperCaseWithAccents(toUpperSource));
1252 } 1252 }
1253
1254
1255
1256 TEST(ParsedDicomFile, InvalidCharacterSets)
1257 {
1258 {
1259 // No encoding provided, fallback to default encoding
1260 DicomMap m;
1261 m.SetValue(DICOM_TAG_PATIENT_NAME, "HELLO", false);
1262
1263 ParsedDicomFile d(m, Encoding_Latin3 /* default encoding */);
1264 ASSERT_EQ(Encoding_Latin3, d.GetEncoding());
1265 }
1266
1267 {
1268 // Valid encoding, "ISO_IR 13" is Japanese
1269 DicomMap m;
1270 m.SetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET, "ISO_IR 13", false);
1271 m.SetValue(DICOM_TAG_PATIENT_NAME, "HELLO", false);
1272
1273 ParsedDicomFile d(m, Encoding_Latin3 /* default encoding */);
1274 ASSERT_EQ(Encoding_Japanese, d.GetEncoding());
1275 }
1276
1277 {
1278 // Invalid value for an encoding ("nope" is not in the DICOM standard)
1279 DicomMap m;
1280 m.SetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET, "nope", false);
1281 m.SetValue(DICOM_TAG_PATIENT_NAME, "HELLO", false);
1282
1283 ASSERT_THROW(ParsedDicomFile d(m, Encoding_Latin3), OrthancException);
1284 }
1285
1286 {
1287 // Invalid encoding, as provided as a binary string
1288 DicomMap m;
1289 m.SetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET, "ISO_IR 13", true);
1290 m.SetValue(DICOM_TAG_PATIENT_NAME, "HELLO", false);
1291
1292 ASSERT_THROW(ParsedDicomFile d(m, Encoding_Latin3), OrthancException);
1293 }
1294
1295 {
1296 // Encoding provided as an empty string, fallback to default encoding
1297 // In Orthanc <= 1.3.1, this test was throwing an exception
1298 DicomMap m;
1299 m.SetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET, "", false);
1300 m.SetValue(DICOM_TAG_PATIENT_NAME, "HELLO", false);
1301
1302 ParsedDicomFile d(m, Encoding_Latin3 /* default encoding */);
1303 ASSERT_EQ(Encoding_Latin3, d.GetEncoding());
1304 }
1305 }