ctkCoreTestingUtilities.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. #ifndef __ctkCoreTestingUtilities_h
  15. #define __ctkCoreTestingUtilities_h
  16. // CTK includes
  17. #include <ctkCoreExport.h>
  18. // Qt includes
  19. #include <QString>
  20. #include <QStringList>
  21. /// This module provides functions to facilitate writing tests.
  22. ///
  23. /// Before using this module, first consider the QTestLib
  24. /// unit testing framework available in Qt.
  25. ///
  26. /// Example:
  27. ///
  28. /// \code{.cpp}
  29. /// int current = 40 + 2;
  30. /// int expected = 43;
  31. /// if (!CheckInt(__LINE__, "40 + 2", current, expected))
  32. /// {
  33. /// return false;
  34. /// }
  35. /// \endcode
  36. ///
  37. /// Usually these test methods are used by single-line convenience macros
  38. /// defined in ctkCoreTestingMacros.h.
  39. namespace ctkCoreTestingUtilities
  40. {
  41. CTK_CORE_EXPORT
  42. bool CheckInt(int line, const QString& description,
  43. int current, int expected);
  44. CTK_CORE_EXPORT
  45. bool CheckNotNull(int line, const QString& description,
  46. const void* pointer);
  47. CTK_CORE_EXPORT
  48. bool CheckNull(int line, const QString& description,
  49. const void* pointer);
  50. CTK_CORE_EXPORT
  51. bool CheckPointer(int line, const QString& description,
  52. void* current, void* expected, bool errorIfDifferent = true);
  53. CTK_CORE_EXPORT
  54. bool CheckString(int line, const QString& description,
  55. const char* current, const char* expected, bool errorIfDifferent = true );
  56. CTK_CORE_EXPORT
  57. bool CheckStringList(int line, const QString& description,
  58. const QStringList& current, const QStringList& expected);
  59. } // namespace ctkCoreTestingUtilities
  60. #include "ctkCoreTestingUtilities.tpp"
  61. #endif