Commit c9fcea14 authored by Sergei Krivonos's avatar Sergei Krivonos

MDEV-27036: re-enable my_json_writer-t unit test

parent 6208228b
...@@ -13,13 +13,10 @@ ...@@ -13,13 +13,10 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
#include "mariadb.h" #include "my_global.h"
#include "sql_priv.h"
#include "sql_string.h"
#include "my_json_writer.h" #include "my_json_writer.h"
#if !defined(NDEBUG) || defined(JSON_WRITER_UNIT_TEST) #if !defined(NDEBUG) || defined(JSON_WRITER_UNIT_TEST)
#include <iostream>
bool Json_writer::named_item_expected() const bool Json_writer::named_item_expected() const
{ {
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#define JSON_WRITER_INCLUDED #define JSON_WRITER_INCLUDED
#include "my_base.h" #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 #if !defined(NDEBUG) || defined(JSON_WRITER_UNIT_TEST) || defined ENABLED_JSON_WRITER_CONSISTENCY_CHECKS
#include <set> #include <set>
...@@ -27,11 +27,11 @@ ...@@ -27,11 +27,11 @@
#endif #endif
#ifdef JSON_WRITER_UNIT_TEST #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 // Also, mock objects are defined in my_json_writer-t.cc
#define VALIDITY_ASSERT(x) if (!(x)) this->invalid_json= true; #define VALIDITY_ASSERT(x) if (!(x)) this->invalid_json= true;
#else #else
#include "sql_class.h" // For class THD
#include "log.h" // for sql_print_error
#define VALIDITY_ASSERT(x) DBUG_ASSERT(x) #define VALIDITY_ASSERT(x) DBUG_ASSERT(x)
#endif #endif
...@@ -40,8 +40,10 @@ constexpr uint FAKE_SELECT_LEX_ID= UINT_MAX; ...@@ -40,8 +40,10 @@ constexpr uint FAKE_SELECT_LEX_ID= UINT_MAX;
class Opt_trace_stmt; class Opt_trace_stmt;
class Opt_trace_context; class Opt_trace_context;
class Json_writer; 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 Single_line_formatting_helper is used by Json_writer to do better formatting
......
...@@ -74,7 +74,6 @@ class Json_writer; ...@@ -74,7 +74,6 @@ class Json_writer;
*************************************************************************************/ *************************************************************************************/
const uint FAKE_SELECT_LEX_ID= UINT_MAX;
class Explain_query; class Explain_query;
......
...@@ -334,6 +334,8 @@ ...@@ -334,6 +334,8 @@
#define UNCACHEABLE_DEPENDENT (UNCACHEABLE_DEPENDENT_GENERATED | \ #define UNCACHEABLE_DEPENDENT (UNCACHEABLE_DEPENDENT_GENERATED | \
UNCACHEABLE_DEPENDENT_INJECTED) UNCACHEABLE_DEPENDENT_INJECTED)
#define FAKE_SELECT_LEX_ID UINT_MAX
/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */ /* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
#define UNDEF_POS (-1) #define UNDEF_POS (-1)
......
...@@ -31,6 +31,6 @@ ADD_DEPENDENCIES(mf_iocache-t GenError) ...@@ -31,6 +31,6 @@ ADD_DEPENDENCIES(mf_iocache-t GenError)
MY_ADD_TEST(mf_iocache) MY_ADD_TEST(mf_iocache)
# Json writer needs String which needs sql library # Json writer needs String which needs sql library
#ADD_EXECUTABLE(my_json_writer-t my_json_writer-t.cc dummy_builtins.cc) ADD_EXECUTABLE(my_json_writer-t my_json_writer-t.cc dummy_builtins.cc)
#TARGET_LINK_LIBRARIES(my_json_writer-t sql mytap) TARGET_LINK_LIBRARIES(my_json_writer-t sql mytap)
#MY_ADD_TEST(my_json_writer) MY_ADD_TEST(my_json_writer)
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
*/ */
struct TABLE; struct TABLE;
struct JOIN_TAB;
class Json_writer; class Json_writer;
...@@ -45,6 +44,10 @@ class THD ...@@ -45,6 +44,10 @@ class THD
Opt_trace opt_trace; Opt_trace opt_trace;
}; };
constexpr uint FAKE_SELECT_LEX_ID= UINT_MAX;
#define sql_print_error printf
#define JSON_WRITER_UNIT_TEST #define JSON_WRITER_UNIT_TEST
#include "../sql/my_json_writer.h" #include "../sql/my_json_writer.h"
#include "../sql/my_json_writer.cc" #include "../sql/my_json_writer.cc"
...@@ -131,11 +134,8 @@ int main(int args, char **argv) ...@@ -131,11 +134,8 @@ int main(int args, char **argv)
{ {
Json_writer w; Json_writer w;
w.start_object(); w.start_object();
w.add_member("name").add_ll(1); w.add_member("name").start_object();
w.start_object();
w.add_member("name").add_ll(2); 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"); ok(!w.invalid_json, "Valid JSON: nested object member name is the same");
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment