ctkCoreTestingUtilities.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. /// This module provides functions to facilitate writing tests.
  21. ///
  22. /// Before using this module, first consider the QTestLib
  23. /// unit testing framework available in Qt.
  24. ///
  25. /// Example:
  26. ///
  27. /// \code{.cpp}
  28. /// int current = 40 + 2;
  29. /// int expected = 43;
  30. /// if (!CheckInt(__LINE__, "40 + 2", current, expected))
  31. /// {
  32. /// return false;
  33. /// }
  34. /// \endcode
  35. ///
  36. namespace ctkCoreTestingUtilities
  37. {
  38. CTK_CORE_EXPORT
  39. bool CheckInt(int line, const QString& description,
  40. int current, int expected);
  41. CTK_CORE_EXPORT
  42. bool CheckNotNull(int line, const QString& description,
  43. const void* pointer);
  44. CTK_CORE_EXPORT
  45. bool CheckNull(int line, const QString& description,
  46. const void* pointer);
  47. CTK_CORE_EXPORT
  48. bool CheckPointer(int line, const QString& description,
  49. void* current, void* expected, bool errorIfDifferent = true);
  50. CTK_CORE_EXPORT
  51. bool CheckString(int line, const QString& description,
  52. const char* current, const char* expected, bool errorIfDifferent = true );
  53. } // namespace ctkCoreTestingUtilities
  54. #include "ctkCoreTestingUtilities.tpp"
  55. #endif