ctkDICOMDatabaseTest7.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 <QDir>
  17. // ctkDICOMCore includes
  18. #include "ctkDICOMDatabase.h"
  19. // STD includes
  20. #include <iostream>
  21. #include <cstdlib>
  22. int ctkDICOMDatabaseTest7( int argc, char * argv [] )
  23. {
  24. QCoreApplication app(argc, argv);
  25. ctkDICOMDatabase database;
  26. QDir databaseDirectory = QDir::temp();
  27. databaseDirectory.remove("ctkDICOMDatabase.sql");
  28. databaseDirectory.remove("ctkDICOMTagCache.sql");
  29. QFileInfo databaseFile(databaseDirectory, QString("database.test"));
  30. database.openDatabase(databaseFile.absoluteFilePath());
  31. bool res = database.initializeDatabase();
  32. if (!res)
  33. {
  34. std::cerr << "ctkDICOMDatabase::initializeDatabase() failed." << std::endl;
  35. return EXIT_FAILURE;
  36. }
  37. std::cerr << "Database is in " << databaseDirectory.path().toStdString() << std::endl;
  38. // try to call fileValue with bogus data - should not trigger and exception
  39. // (see https://github.com/commontk/CTK/issues/706)
  40. database.fileValue("/tmp/file-that-does-not-exist", "00ff,eeee");
  41. //
  42. // Close and clean up
  43. //
  44. database.closeDatabase();
  45. return EXIT_SUCCESS;
  46. }