| 1 | /* Copyright (c) 2016, 2026, Oracle and/or its affiliates. |
| 2 | |
| 3 | This program is free software; you can redistribute it and/or modify |
| 4 | it under the terms of the GNU General Public License, version 2.0, |
| 5 | as published by the Free Software Foundation. |
| 6 | |
| 7 | This program is designed to work with certain software (including |
| 8 | but not limited to OpenSSL) that is licensed under separate terms, |
| 9 | as designated in a particular file or component or in included license |
| 10 | documentation. The authors of MySQL hereby grant you an additional |
| 11 | permission to link the program and your derivative works with the |
| 12 | separately licensed software that they have either included with |
| 13 | the program or referenced in the documentation. |
| 14 | |
| 15 | This program is distributed in the hope that it will be useful, |
| 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | GNU General Public License, version 2.0, for more details. |
| 19 | |
| 20 | You should have received a copy of the GNU General Public License |
| 21 | along with this program; if not, write to the Free Software |
| 22 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ |
| 23 | |
| 24 | #include <gtest/gtest.h> |
| 25 | #include <stddef.h> |
| 26 | |
| 27 | #include "plugin/x/protocol/encoders/encoding_xmessages.h" |
| 28 | #include "plugin/x/src/ngs/protocol/protocol_protobuf.h" |
| 29 | #include "unittest/gunit/xplugin/xpl/encoder_validator.h" |
| 30 | #include "unittest/gunit/xplugin/xpl/protobuf_message.h" |
| 31 | |
| 32 | namespace protocol { |
| 33 | |
| 34 | namespace test { |
| 35 | |
| 36 | class Encoder_validator_testsuite : public ::testing::Test { |
| 37 | public: |
| 38 | protocol::XMessage_encoder_base<Encoder_validator> m_encoder; |
| 39 | }; |
| 40 | |
| 41 | TEST_F(Encoder_validator_testsuite, encode_full_metadata) { |
| 42 | ::ngs::Encode_column_info column_info; |
| 43 | column_info.m_compact = false; |
| 44 | |
| 45 | m_encoder.encode_metadata(&column_info); |
| 46 | } |
| 47 | |
| 48 | TEST_F(Encoder_validator_testsuite, encode_compact_metadata) { |
| 49 | ::ngs::Encode_column_info column_info; |
| 50 | |
| 51 | m_encoder.encode_metadata(&column_info); |
| 52 | } |
| 53 | |
| 54 | TEST_F(Encoder_validator_testsuite, encode_compact_metadata_multiple_params) { |
| 55 | m_encoder.encode_compact_metadata(0, nullptr, nullptr, nullptr, nullptr, |
| 56 | nullptr); |
| 57 | } |
| 58 | |
| 59 | TEST_F(Encoder_validator_testsuite, encode_full_metadata_multiple_params) { |
| 60 | m_encoder.encode_full_metadata("", "", "", "", "", "", 0, nullptr, nullptr, |
| 61 | nullptr, nullptr, nullptr); |
| 62 | } |
| 63 | |
| 64 | TEST_F(Encoder_validator_testsuite, encode_notice_row_affected) { |
| 65 | m_encoder.encode_notice_rows_affected(0); |
| 66 | } |
| 67 | |
| 68 | TEST_F(Encoder_validator_testsuite, encode_notice_client_id) { |
| 69 | m_encoder.encode_notice_client_id(0); |
| 70 | } |
| 71 | |
| 72 | TEST_F(Encoder_validator_testsuite, encode_notice_expired) { |
| 73 | m_encoder.encode_notice_expired(); |
| 74 | } |
| 75 | |
| 76 | TEST_F(Encoder_validator_testsuite, encode_notice_generated_insert_id) { |
| 77 | m_encoder.encode_notice_generated_insert_id(0); |
| 78 | } |
| 79 | |
| 80 | TEST_F(Encoder_validator_testsuite, encode_notice_text_message) { |
| 81 | m_encoder.encode_notice_text_message(""); |
| 82 | } |
| 83 | |
| 84 | TEST_F(Encoder_validator_testsuite, encode_notice) { |
| 85 | m_encoder.encode_notice(0, 0, ""); |
| 86 | } |
| 87 | |
| 88 | TEST_F(Encoder_validator_testsuite, encode_global_notice) { |
| 89 | m_encoder.encode_global_notice(0, ""); |
| 90 | } |
| 91 | |
| 92 | TEST_F(Encoder_validator_testsuite, encode_fetch_more_resultsets) { |
| 93 | m_encoder.encode_fetch_more_resultsets(); |
| 94 | } |
| 95 | |
| 96 | TEST_F(Encoder_validator_testsuite, encode_fetch_out_params) { |
| 97 | m_encoder.encode_fetch_out_params(); |
| 98 | } |
| 99 | |
| 100 | TEST_F(Encoder_validator_testsuite, encode_fetch_suspended) { |
| 101 | m_encoder.encode_fetch_suspended(); |
| 102 | } |
| 103 | |
| 104 | TEST_F(Encoder_validator_testsuite, encode_fetch_done) { |
| 105 | m_encoder.encode_fetch_done(); |
| 106 | } |
| 107 | |
| 108 | TEST_F(Encoder_validator_testsuite, encode_stmt_execute_ok) { |
| 109 | m_encoder.encode_stmt_execute_ok(); |
| 110 | } |
| 111 | |
| 112 | TEST_F(Encoder_validator_testsuite, encode_ok) { m_encoder.encode_ok(); } |
| 113 | |
| 114 | TEST_F(Encoder_validator_testsuite, encode_ok_with_param) { |
| 115 | m_encoder.encode_ok(""); |
| 116 | } |
| 117 | |
| 118 | TEST_F(Encoder_validator_testsuite, encode_error) { |
| 119 | m_encoder.encode_error(0, 0, "", ""); |
| 120 | } |
| 121 | |
| 122 | TEST_F(Encoder_validator_testsuite, encode_xmessage) { |
| 123 | m_encoder.encode_xmessage<1>(""); |
| 124 | } |
| 125 | |
| 126 | } // namespace test |
| 127 | |
| 128 | } // namespace protocol |