Debian Codegraph @

unittest/gunit/xplugin/xpl/assert_error_code.h

raw symbols SCIP
1 /*
2 * Copyright (c) 2017, 2026, Oracle and/or its affiliates.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2.0,
6 * as published by the Free Software Foundation.
7 *
8 * This program is designed to work with certain software (including
9 * but not limited to OpenSSL) that is licensed under separate terms,
10 * as designated in a particular file or component or in included license
11 * documentation. The authors of MySQL hereby grant you an additional
12 * permission to link the program and your derivative works with the
13 * separately licensed software that they have either included with
14 * the program or referenced in the documentation.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License, version 2.0, for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
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 } // namespace test
69 } // namespace xpl
70
71 #endif // UNITTEST_GUNIT_XPLUGIN_XPL_ASSERT_ERROR_CODE_H_