comparison UnitTestsSources/FromDcmtkTests.cpp @ 1691:e447f3cb8b30

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 08 Oct 2015 10:53:14 +0200
parents ae09132e4237
children 4eaf164dd574
comparison
equal deleted inserted replaced
1690:ae09132e4237 1691:e447f3cb8b30
341 Json::Value b; 341 Json::Value b;
342 FromDcmtkBridge::ToJson(b, *element, DicomToJsonFormat_Short, 0, Encoding_Ascii); 342 FromDcmtkBridge::ToJson(b, *element, DicomToJsonFormat_Short, 0, Encoding_Ascii);
343 ASSERT_EQ("Hello", b["0010,0010"].asString()); 343 ASSERT_EQ("Hello", b["0010,0010"].asString());
344 } 344 }
345 345
346 printf("ici\n");
347
348 { 346 {
349 Json::Value a = Json::arrayValue; 347 Json::Value a = Json::arrayValue;
350 348
351 { 349 {
352 Json::Value b = Json::objectValue; 350 Json::Value b = Json::objectValue;
353 b["PatientName"] = "Hello"; 351 b["PatientName"] = "Hello";
354 b["PatientID"] = "World"; 352 b["PatientID"] = "World";
353 b["StudyDescription"] = "Toto";
355 a.append(b); 354 a.append(b);
356 } 355 }
357 356
358 { 357 {
359 Json::Value b = Json::objectValue; 358 Json::Value b = Json::objectValue;
361 b["PatientID"] = "World2"; 360 b["PatientID"] = "World2";
362 a.append(b); 361 a.append(b);
363 } 362 }
364 363
365 element.reset(FromDcmtkBridge::FromJson(a, REFERENCED_STUDY_SEQUENCE, false)); 364 element.reset(FromDcmtkBridge::FromJson(a, REFERENCED_STUDY_SEQUENCE, false));
366 element->writeXML(std::cout);
367 365
368 { 366 {
369 Json::Value b; 367 Json::Value b;
370 FromDcmtkBridge::ToJson(b, *element, DicomToJsonFormat_Full, 0, Encoding_Ascii); 368 FromDcmtkBridge::ToJson(b, *element, DicomToJsonFormat_Short, 0, Encoding_Ascii);
371 /*ASSERT_EQ(Json::arrayValue, b["0008,1110"].type()); 369 ASSERT_EQ(Json::arrayValue, b["0008,1110"].type());
372 ASSERT_EQ(2, b["0008,1110"].size());*/ 370 ASSERT_EQ(2, b["0008,1110"].size());
373 371
374 std::cout << b; 372 Json::Value::ArrayIndex i = (b["0008,1110"][0]["0010,0010"].asString() == "Hello") ? 0 : 1;
373
374 ASSERT_EQ(3, b["0008,1110"][i].size());
375 ASSERT_EQ(2, b["0008,1110"][1 - i].size());
376 ASSERT_EQ(b["0008,1110"][i]["0010,0010"].asString(), "Hello");
377 ASSERT_EQ(b["0008,1110"][i]["0010,0020"].asString(), "World");
378 ASSERT_EQ(b["0008,1110"][i]["0008,1030"].asString(), "Toto");
379 ASSERT_EQ(b["0008,1110"][1 - i]["0010,0010"].asString(), "Hello2");
380 ASSERT_EQ(b["0008,1110"][1 - i]["0010,0020"].asString(), "World2");
375 } 381 }
376 } 382 }
377 383
378 384
379 385