1 /*############################################################################ 2 # Copyright 2016-2017 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 /*! 18 * \file 19 * \brief Error handling C++ wrapper interface. 20 */ 21 #ifndef EPID_COMMON_TESTHELPER_ERRORS_TESTHELPER_H_ 22 #define EPID_COMMON_TESTHELPER_ERRORS_TESTHELPER_H_ 23 24 #include <cstdio> 25 #include <initializer_list> 26 #include <stdexcept> 27 #include <string> 28 #include <vector> 29 30 extern "C" { 31 #include "epid/common/math/bignum.h" 32 } 33 34 /// Macro used to indicate fatal error during unit test run 35 #define THROW_ON_EPIDERR(actual) \ 36 if (kEpidNoErr != actual) { \ 37 printf("%s(%d): error: %s\n", __FILE__, __LINE__, "test defect"); \ 38 throw std::logic_error(std::string("Failed to call: ") + #actual); \ 39 } 40 41 /// Macro used to indicate fatal error during unit test run 42 #define THROW_NE(expected, actual) \ 43 if (expected != actual) { \ 44 printf("%s(%d): error: %s\n", __FILE__, __LINE__, "test defect"); \ 45 throw std::logic_error(std::string("Failed to call: ") + #actual); \ 46 } 47 48 #endif // EPID_COMMON_TESTHELPER_ERRORS_TESTHELPER_H_ 49