18 #include "my_config.h"
19 #include <gtest/gtest.h>
21 #include "mock_create_field.h"
22 #include "test_utils.h"
23 #include "mock_field_timestamp.h"
25 #include "sql_class.h"
26 #include "rpl_handler.h"
27 #include "sql_table.h"
29 namespace sql_table_unittest {
40 virtual void SetUp() { initializer.SetUp(); }
41 virtual void TearDown() { initializer.TearDown(); }
43 THD *get_thd() {
return initializer.thd(); }
59 column_1_definition.flags|= NOT_NULL_FLAG;
60 column_2_definition.flags|= NOT_NULL_FLAG;
62 definitions.push_front(&column_1_definition);
63 definitions.push_back(&column_2_definition);
64 promote_first_timestamp_column(&definitions);
65 EXPECT_EQ(Field::TIMESTAMP_DNUN_FIELD, column_1_definition.unireg_check);
66 EXPECT_EQ(Field::NONE, column_2_definition.unireg_check);
77 TEST_F(SqlTableTest, PromoteFirstTimestampColumn2)
81 column_1_definition.flags|= NOT_NULL_FLAG;
82 column_2_definition.flags|= NOT_NULL_FLAG;
84 definitions.push_front(&column_1_definition);
85 definitions.push_back(&column_2_definition);
86 promote_first_timestamp_column(&definitions);
87 EXPECT_EQ(Field::TIMESTAMP_DNUN_FIELD, column_1_definition.unireg_check);
88 EXPECT_EQ(Field::NONE, column_2_definition.unireg_check);
97 TEST_F(SqlTableTest, PromoteFirstTimestampColumn3)
102 column_2_definition.flags|= NOT_NULL_FLAG;
104 definitions.push_front(&column_1_definition);
105 definitions.push_back(&column_2_definition);
106 promote_first_timestamp_column(&definitions);
107 EXPECT_EQ(Field::NONE, column_1_definition.unireg_check);
108 EXPECT_EQ(Field::NONE, column_2_definition.unireg_check);
119 TEST_F(SqlTableTest, FileNameToTableName)
128 memcpy(foo.str,
"-@", 3);
129 MEM_NOACCESS(&foo.foo1, 1);
130 MEM_NOACCESS(&foo.foo2, 1);
132 const char test_filename[] =
"-@";
133 char test_tablename[
sizeof test_filename
138 name_length= filename_to_tablename(test_filename,
140 sizeof(test_tablename)
145 EXPECT_EQ((
sizeof(test_tablename)) - 1, name_length);
148 name_length= filename_to_tablename(foo.str,
150 sizeof(test_tablename)
155 EXPECT_EQ((
sizeof(test_tablename)) - 1, name_length);