diff options
author | Sergei Krivonos <sergeikrivonos@gmail.com> | 2021-12-15 21:11:26 +0200 |
---|---|---|
committer | Sergei Krivonos <sergeikrivonos@gmail.com> | 2021-12-15 21:36:56 +0200 |
commit | c9fcea14e9e1f34a97451706eac51276c85bbea7 (patch) | |
tree | 1114a45bc77a0b159ffc51c6204ce6ed64844b6f | |
parent | 6208228b78917bff13b5dc34428b38596f7404b4 (diff) | |
download | mariadb-git-c9fcea14e9e1f34a97451706eac51276c85bbea7.tar.gz |
MDEV-27036: re-enable my_json_writer-t unit testbb-10.8-MDEV-27036-enable-unittest
-rw-r--r-- | sql/my_json_writer.cc | 5 | ||||
-rw-r--r-- | sql/my_json_writer.h | 10 | ||||
-rw-r--r-- | sql/sql_explain.h | 1 | ||||
-rw-r--r-- | sql/sql_priv.h | 2 | ||||
-rw-r--r-- | unittest/sql/CMakeLists.txt | 6 | ||||
-rw-r--r-- | unittest/sql/my_json_writer-t.cc | 10 |
6 files changed, 17 insertions, 17 deletions
diff --git a/sql/my_json_writer.cc b/sql/my_json_writer.cc index 8284c9bbfca..54eb8423caf 100644 --- a/sql/my_json_writer.cc +++ b/sql/my_json_writer.cc @@ -13,13 +13,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ -#include "mariadb.h" -#include "sql_priv.h" -#include "sql_string.h" +#include "my_global.h" #include "my_json_writer.h" #if !defined(NDEBUG) || defined(JSON_WRITER_UNIT_TEST) -#include <iostream> bool Json_writer::named_item_expected() const { diff --git a/sql/my_json_writer.h b/sql/my_json_writer.h index a4e8c825582..9e7081c96d1 100644 --- a/sql/my_json_writer.h +++ b/sql/my_json_writer.h @@ -17,7 +17,7 @@ #define JSON_WRITER_INCLUDED #include "my_base.h" -#include "sql_select.h" +#include "sql_string.h" #if !defined(NDEBUG) || defined(JSON_WRITER_UNIT_TEST) || defined ENABLED_JSON_WRITER_CONSISTENCY_CHECKS #include <set> @@ -27,11 +27,11 @@ #endif #ifdef JSON_WRITER_UNIT_TEST -#include "sql_string.h" -constexpr uint FAKE_SELECT_LEX_ID= UINT_MAX; // Also, mock objects are defined in my_json_writer-t.cc #define VALIDITY_ASSERT(x) if (!(x)) this->invalid_json= true; #else +#include "sql_class.h" // For class THD +#include "log.h" // for sql_print_error #define VALIDITY_ASSERT(x) DBUG_ASSERT(x) #endif @@ -40,8 +40,10 @@ constexpr uint FAKE_SELECT_LEX_ID= UINT_MAX; class Opt_trace_stmt; class Opt_trace_context; class Json_writer; -struct TABLE_LIST; +struct TABLE; +struct st_join_table; +using JOIN_TAB= struct st_join_table; /* Single_line_formatting_helper is used by Json_writer to do better formatting diff --git a/sql/sql_explain.h b/sql/sql_explain.h index bfd52290374..88fae9d4f1a 100644 --- a/sql/sql_explain.h +++ b/sql/sql_explain.h @@ -74,7 +74,6 @@ class Json_writer; *************************************************************************************/ -const uint FAKE_SELECT_LEX_ID= UINT_MAX; class Explain_query; diff --git a/sql/sql_priv.h b/sql/sql_priv.h index f7d8ef0da67..b5efe53dfa4 100644 --- a/sql/sql_priv.h +++ b/sql/sql_priv.h @@ -334,6 +334,8 @@ #define UNCACHEABLE_DEPENDENT (UNCACHEABLE_DEPENDENT_GENERATED | \ UNCACHEABLE_DEPENDENT_INJECTED) +#define FAKE_SELECT_LEX_ID UINT_MAX + /* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */ #define UNDEF_POS (-1) diff --git a/unittest/sql/CMakeLists.txt b/unittest/sql/CMakeLists.txt index 7dd0074eddb..b8682de74c3 100644 --- a/unittest/sql/CMakeLists.txt +++ b/unittest/sql/CMakeLists.txt @@ -31,6 +31,6 @@ ADD_DEPENDENCIES(mf_iocache-t GenError) MY_ADD_TEST(mf_iocache) # Json writer needs String which needs sql library -#ADD_EXECUTABLE(my_json_writer-t my_json_writer-t.cc dummy_builtins.cc) -#TARGET_LINK_LIBRARIES(my_json_writer-t sql mytap) -#MY_ADD_TEST(my_json_writer) +ADD_EXECUTABLE(my_json_writer-t my_json_writer-t.cc dummy_builtins.cc) +TARGET_LINK_LIBRARIES(my_json_writer-t sql mytap) +MY_ADD_TEST(my_json_writer) diff --git a/unittest/sql/my_json_writer-t.cc b/unittest/sql/my_json_writer-t.cc index a585c17c75f..9363682d86d 100644 --- a/unittest/sql/my_json_writer-t.cc +++ b/unittest/sql/my_json_writer-t.cc @@ -26,7 +26,6 @@ */ struct TABLE; -struct JOIN_TAB; class Json_writer; @@ -45,6 +44,10 @@ public: Opt_trace opt_trace; }; +constexpr uint FAKE_SELECT_LEX_ID= UINT_MAX; + +#define sql_print_error printf + #define JSON_WRITER_UNIT_TEST #include "../sql/my_json_writer.h" #include "../sql/my_json_writer.cc" @@ -131,11 +134,8 @@ int main(int args, char **argv) { Json_writer w; w.start_object(); - w.add_member("name").add_ll(1); - w.start_object(); + w.add_member("name").start_object(); w.add_member("name").add_ll(2); - w.end_object(); - w.end_object(); ok(!w.invalid_json, "Valid JSON: nested object member name is the same"); } |