ctkDICOMQueryTest1.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0.txt
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. // Qt includes
  15. #include <QCoreApplication>
  16. #include <QStringList>
  17. #include <QVariant>
  18. // ctkDICOMCore includes
  19. #include "ctkDICOMQuery.h"
  20. // STD includes
  21. #include <cstdlib>
  22. #include <iostream>
  23. // Simple test that check the values are correctly set
  24. int ctkDICOMQueryTest1( int argc, char * argv [] )
  25. {
  26. QCoreApplication app(argc, argv);
  27. ctkDICOMQuery query;
  28. // check default values
  29. if (!query.callingAETitle().isEmpty() ||
  30. !query.calledAETitle().isEmpty() ||
  31. !query.host().isEmpty() ||
  32. query.port() != 0 ||
  33. !query.filters().isEmpty() ||
  34. !query.studyInstanceUIDQueried().isEmpty())
  35. {
  36. std::cerr << "ctkDICOMQuery::ctkDICOMQuery() failed: "
  37. << qPrintable(query.callingAETitle()) << " "
  38. << qPrintable(query.calledAETitle()) << " "
  39. << qPrintable(query.host()) << " "
  40. << query.port() << " "
  41. << std::endl;
  42. return EXIT_FAILURE;
  43. }
  44. query.setCallingAETitle("CallingAETitle");
  45. if (query.callingAETitle() != "CallingAETitle")
  46. {
  47. std::cerr << "ctkDICOMQuery::setCallingAETitle() failed: "
  48. << qPrintable(query.callingAETitle()) << std::endl;
  49. return EXIT_FAILURE;
  50. }
  51. query.setCalledAETitle("CalledAETitle");
  52. if (query.calledAETitle() != "CalledAETitle")
  53. {
  54. std::cerr << "ctkDICOMQuery::setCalledAETitle() failed: "
  55. << qPrintable(query.calledAETitle()) << std::endl;
  56. return EXIT_FAILURE;
  57. }
  58. query.setHost("host");
  59. if (query.host() != "host")
  60. {
  61. std::cerr << "ctkDICOMQuery::setHost() failed: "
  62. << qPrintable(query.host()) << std::endl;
  63. return EXIT_FAILURE;
  64. }
  65. query.setPort(80);
  66. if (query.port() != 80)
  67. {
  68. std::cerr << "ctkDICOMQuery::setPort() failed: "
  69. << query.port() << std::endl;
  70. return EXIT_FAILURE;
  71. }
  72. QMap<QString,QVariant> filters;
  73. filters["Name"] = QString("JohnDoe");
  74. filters["StartDate"] = QString("20090101");
  75. filters["EndDate"] = QString("20091231");
  76. query.setFilters(filters);
  77. if (query.filters() != filters)
  78. {
  79. std::cerr << "ctkDICOMDatabase::setFilters() failed: "
  80. << query.filters().count() << std::endl;
  81. return EXIT_FAILURE;
  82. }
  83. ctkDICOMDatabase database;
  84. query.query(database);
  85. // Queried studies should be empty because we use an empty database.
  86. if (!query.studyInstanceUIDQueried().isEmpty())
  87. {
  88. std::cerr << "ctkDICOMDatabase::query() failed: "
  89. << query.studyInstanceUIDQueried().count() << std::endl;
  90. return EXIT_FAILURE;
  91. }
  92. return EXIT_SUCCESS;
  93. }