Extend cdc_datatypes test

The test now also creates TIME type values and checks that they are
converted correctly. Also added NULL value tests for all values and made
required adjustments to the code.
This commit is contained in:
Markus Mäkelä
2018-02-01 12:55:30 +02:00
parent 2c04adafd1
commit 943c82b33b
2 changed files with 32 additions and 6 deletions

View File

@ -28,6 +28,7 @@ static const char* integer_values[] =
"-1", "-1",
"20", "20",
"-20", "-20",
"NULL",
NULL NULL
}; };
@ -47,6 +48,7 @@ static const char* decimal_values[] =
"-1.5", "-1.5",
"20.5", "20.5",
"-20.5", "-20.5",
"NULL",
NULL NULL
}; };
@ -65,7 +67,7 @@ static const char* string_values[] =
{ {
"\"Hello world!\"", "\"Hello world!\"",
"\"The quick brown fox jumps over the lazy dog\"", "\"The quick brown fox jumps over the lazy dog\"",
// "\"The Unicode should work: äöåǢ\"", "NULL",
NULL NULL
}; };
@ -85,26 +87,27 @@ static const char* binary_values[] =
"\"Hello world!\"", "\"Hello world!\"",
"\"The quick brown fox jumps over the lazy dog\"", "\"The quick brown fox jumps over the lazy dog\"",
"NULL", "NULL",
// "\"The Unicode should work: äöåǢ\"",
// "\"These should work for binary types: ⦿☏☃☢😤😂\"",
NULL NULL
}; };
static const char* datetime_types[] = static const char* datetime_types[] =
{ {
"DATETIME",
"DATETIME(1)", "DATETIME(1)",
"DATETIME(2)", "DATETIME(2)",
"DATETIME(3)", "DATETIME(3)",
"DATETIME(4)", "DATETIME(4)",
"DATETIME(5)", "DATETIME(5)",
"DATETIME(6)", "DATETIME(6)",
"TIMESTAMP", // TODO: Fix test setup to use same timezone
// "TIMESTAMP",
NULL NULL
}; };
static const char* datetime_values[] = static const char* datetime_values[] =
{ {
"'2018-01-01 11:11:11'", "'2018-01-01 11:11:11'",
"NULL",
NULL NULL
}; };
@ -117,6 +120,26 @@ static const char* date_types[] =
static const char* date_values[] = static const char* date_values[] =
{ {
"'2018-01-01'", "'2018-01-01'",
"NULL",
NULL
};
static const char* time_types[] =
{
"TIME",
"TIME(1)",
"TIME(2)",
"TIME(3)",
"TIME(4)",
"TIME(5)",
"TIME(6)",
NULL
};
static const char* time_values[] =
{
"'12:00:00'",
"NULL",
NULL NULL
}; };
@ -132,6 +155,7 @@ struct
{ binary_types, binary_values }, { binary_types, binary_values },
{ datetime_types, datetime_values }, { datetime_types, datetime_values },
{ date_types, date_values }, { date_types, date_values },
{ time_types, time_values },
{ 0 } { 0 }
}; };

View File

@ -39,8 +39,10 @@ public:
bool operator ==(const TestOutput& output) const bool operator ==(const TestOutput& output) const
{ {
return m_value == output.getValue() || return m_value == output.getValue() ||
(m_type.find("BLOB") != std::string::npos && (m_type.find("BLOB") != std::string::npos && output.getValue().length() == 0) ||
output.getValue().length() == 0); // A NULL timestamp appears to be inserted as NOW() by default in 10.2, a NULL INT is
// inserted as 0 and a NULL string gets converted into an empty string by the CDC system
(m_value == "NULL" && (output.getValue().empty() || m_type == "TIMESTAMP" || output.getValue() == "0"));
} }
bool operator !=(const TestOutput& output) const bool operator !=(const TestOutput& output) const