16 #ifndef FIELD_TEMPORAL_UTILS_INCLUDED
17 #define FIELD_TEMPORAL_UTILS_INCLUDED
20 #include <gtest/gtest.h>
21 #include "test_utils.h"
28 const char *store_value,
const int length,
29 const char *expected_result,
30 const type_conversion_status expect_status,
31 const sql_mode_t test_mode,
32 const uint expected_error_code)
34 THD *thd= field->table->in_use;
35 sql_mode_t save_mode= thd->variables.sql_mode;
36 thd->variables.sql_mode= test_mode;
38 Mock_error_handler error_handler(thd, expected_error_code);
39 type_conversion_status err=
40 field->
store(store_value, length, &my_charset_latin1);
44 field->val_str(&str, &unused);
46 EXPECT_EQ(expect_status, err);
47 EXPECT_STREQ(expected_result, str.ptr());
48 EXPECT_EQ((expected_error_code == 0 ? 0 : 1),
49 error_handler.handle_called());
51 thd->variables.sql_mode= save_mode;
55 const char *store_value,
const int length,
56 const char *expected_result,
57 const int expected_error_no,
58 const type_conversion_status expected_status)
60 char buff[MAX_FIELD_WIDTH];
61 String str(buff,
sizeof(buff), &my_charset_bin);
64 Mock_error_handler error_handler(field->table->in_use, expected_error_no);
65 type_conversion_status err= field->
store(store_value, length,
67 field->val_str(&str, &unused);
68 EXPECT_STREQ(expected_result, str.ptr());
70 EXPECT_FALSE(field->is_null());
71 EXPECT_EQ(expected_status, err);
72 EXPECT_EQ((expected_error_no == 0 ? 0 : 1), error_handler.handle_called());
79 #endif // FIELD_TEMPORAL_UTILS_INCLUDED