| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
#ifndef UNITTEST_GUNIT_XPLUGIN_XPL_ASSERT_ERROR_CODE_H_ |
| 26 |
#define UNITTEST_GUNIT_XPLUGIN_XPL_ASSERT_ERROR_CODE_H_ |
| 27 |
|
| 28 |
#include <gtest/gtest.h> |
| 29 |
|
| 30 |
#include "plugin/x/generated/mysqlx_error.h" |
| 31 |
#include "plugin/x/src/ngs/error_code.h" |
| 32 |
|
| 33 |
namespace xpl { |
| 34 |
namespace test { |
| 35 |
|
| 36 |
inline ::testing::AssertionResult Assert_error_code(const char *e1_expr, |
| 37 |
const char *e2_expr, int e1, |
| 38 |
const ngs::Error_code &e2) { |
| 39 |
return (e1 == e2.error) ? ::testing::AssertionSuccess() |
| 40 |
: (::testing::AssertionFailure() |
| 41 |
<< "Value of: " << e2_expr << "\nActual: {" |
| 42 |
<< e2.error << ", " << e2.message << "}\n" |
| 43 |
<< "Expected: " << e1_expr << "\nWhich is:" << e1); |
| 44 |
} |
| 45 |
|
| 46 |
inline ::testing::AssertionResult Assert_error(const char *e1_expr, |
| 47 |
const char *e2_expr, |
| 48 |
const ngs::Error_code &e1, |
| 49 |
const ngs::Error_code &e2) { |
| 50 |
return (e1.error == e2.error) && (e1.message == e2.message) |
| 51 |
? ::testing::AssertionSuccess() |
| 52 |
: (::testing::AssertionFailure() |
| 53 |
<< "Value of: " << e2_expr << "\nActual: {" << e2.error << ", " |
| 54 |
<< e2.message << "}\n" |
| 55 |
<< "Expected: " << e1_expr << "\nWhich is: {" << e1.error |
| 56 |
<< ", " << e1.message << "}"); |
| 57 |
} |
| 58 |
|
| 59 |
#define ASSERT_ERROR_CODE(a, b) ASSERT_PRED_FORMAT2(Assert_error_code, a, b); |
| 60 |
#define ASSERT_ERROR(a, b) ASSERT_PRED_FORMAT2(Assert_error, a, b); |
| 61 |
#define ER_X_SUCCESS 0 |
| 62 |
#define ER_X_ARTIFICIAL1 7001 |
| 63 |
#define ER_X_ARTIFICIAL2 7002 |
| 64 |
#define ER_X_ARTIFICIAL3 7003 |
| 65 |
#define ER_X_ARTIFICIAL4 7004 |
| 66 |
#define ER_X_ARTIFICIAL5 7005 |
| 67 |
|
| 68 |
} |
| 69 |
} |
| 70 |
|
| 71 |
#endif |