errors-testhelper.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*############################################################################
  2. # Copyright 2016 Intel Corporation
  3. #
  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. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ############################################################################*/
  16. /*!
  17. * \file
  18. * \brief Error handling C++ wrapper interface.
  19. */
  20. #ifndef EPID_COMMON_TESTHELPER_ERRORS_TESTHELPER_H_
  21. #define EPID_COMMON_TESTHELPER_ERRORS_TESTHELPER_H_
  22. #include <string>
  23. #include <cstdio>
  24. #include <stdexcept>
  25. #include <vector>
  26. #include <initializer_list>
  27. extern "C" {
  28. #include "epid/common/math/bignum.h"
  29. }
  30. /// Macro used to indicate fatal error during unit test run
  31. #define THROW_ON_EPIDERR(actual) \
  32. if (kEpidNoErr != actual) { \
  33. printf("%s(%d): error: %s\n", __FILE__, __LINE__, "test defect"); \
  34. throw std::logic_error(std::string("Failed to call: ") + #actual); \
  35. }
  36. #endif // EPID_COMMON_TESTHELPER_ERRORS_TESTHELPER_H_