ctkCoreTestingUtilities.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. /// Usually these test methods are used by single-line convenience macros
  37. /// defined in ctkCoreTestingMacros.h.
  38. namespace ctkCoreTestingUtilities
  39. {
  40. CTK_CORE_EXPORT
  41. bool CheckInt(int line, const QString& description,
  42. int current, int expected);
  43. CTK_CORE_EXPORT
  44. bool CheckNotNull(int line, const QString& description,
  45. const void* pointer);
  46. CTK_CORE_EXPORT
  47. bool CheckNull(int line, const QString& description,
  48. const void* pointer);
  49. CTK_CORE_EXPORT
  50. bool CheckPointer(int line, const QString& description,
  51. void* current, void* expected, bool errorIfDifferent = true);
  52. CTK_CORE_EXPORT
  53. bool CheckString(int line, const QString& description,
  54. const char* current, const char* expected, bool errorIfDifferent = true );
  55. } // namespace ctkCoreTestingUtilities
  56. #include "ctkCoreTestingUtilities.tpp"
  57. #endif