mirror of
https://github.com/boostorg/mysql.git
synced 2026-02-21 03:02:18 +00:00
Now text protocol supports invalid dates
Changed text protocol to support invalid dates and datetimes Added tests Now months greater than 12, days greater than 31, years greater than 9999 are always rejected
This commit is contained in:
@@ -129,44 +129,62 @@ INSTANTIATE_TEST_SUITE_P(DOUBLE, DeserializeBinaryValueErrorTest, Values(
|
||||
protocol_field_type::double_)
|
||||
), test_name_generator);
|
||||
|
||||
// Based on correct, regular date {0x04, 0xda, 0x07, 0x03, 0x1c}
|
||||
INSTANTIATE_TEST_SUITE_P(DATE, DeserializeBinaryValueErrorTest, Values(
|
||||
err_binary_value_testcase("empty", {}, protocol_field_type::date, errc::incomplete_message),
|
||||
err_binary_value_testcase("incomplete_year", {0x04, 0xff},
|
||||
err_binary_value_testcase("incomplete_year", {0x04, 0xda},
|
||||
protocol_field_type::date, errc::incomplete_message),
|
||||
err_binary_value_testcase("no_month_day", {0x04, 0x09, 0x27},
|
||||
err_binary_value_testcase("no_month_day", {0x04, 0xda, 0x07},
|
||||
protocol_field_type::date, errc::incomplete_message),
|
||||
err_binary_value_testcase("no_day", {0x04, 0x09, 0x27, 0x01},
|
||||
err_binary_value_testcase("no_day", {0x04, 0xda, 0x07, 0x03},
|
||||
protocol_field_type::date, errc::incomplete_message),
|
||||
err_binary_value_testcase("gt_max", {0x04, 0x10, 0x27, 0x0c, 0x1f}, // year 10000
|
||||
err_binary_value_testcase("invalid_year", {0x04, 0x10, 0x27, 0x03, 0x1c}, // year 10000
|
||||
protocol_field_type::date),
|
||||
err_binary_value_testcase("protocol_max", {0x04, 0xff, 0xff, 0x0c, 0x1f},
|
||||
err_binary_value_testcase("invalid_year_max", {0x04, 0xff, 0xff, 0x03, 0x1c},
|
||||
protocol_field_type::date),
|
||||
err_binary_value_testcase("invalid_month", {0x04, 0xda, 0x07, 13, 0x1c},
|
||||
protocol_field_type::date),
|
||||
err_binary_value_testcase("invalid_month_max", {0x04, 0xda, 0x07, 0xff, 0x1c},
|
||||
protocol_field_type::date),
|
||||
err_binary_value_testcase("invalid_day", {0x04, 0xda, 0x07, 0x03, 32},
|
||||
protocol_field_type::date),
|
||||
err_binary_value_testcase("invalid_day_max", {0x04, 0xda, 0x07, 0x03, 0xff},
|
||||
protocol_field_type::date),
|
||||
err_binary_value_testcase("protocol_max", {0xff, 0xff, 0xff, 0xff, 0xff},
|
||||
protocol_field_type::date)
|
||||
));
|
||||
|
||||
// Based on correct datetime {0x0b, 0xda, 0x07, 0x01, 0x01, 0x17, 0x01, 0x3b, 0x56, 0xc3, 0x0e, 0x00}
|
||||
std::vector<err_binary_value_testcase> make_datetime_cases(
|
||||
protocol_field_type type
|
||||
)
|
||||
{
|
||||
return {
|
||||
{ "empty", {}, type, errc::incomplete_message },
|
||||
{ "incomplete_date", {0x04, 0x09, 0x27, 0x01}, type, errc::incomplete_message },
|
||||
{ "no_hours_mins_secs", {0x07, 0x09, 0x27, 0x01, 0x01}, type, errc::incomplete_message },
|
||||
{ "no_mins_secs", {0x07, 0x09, 0x27, 0x01, 0x01, 0x01}, type, errc::incomplete_message },
|
||||
{ "no_secs", {0x07, 0x09, 0x27, 0x01, 0x01, 0x01, 0x01}, type, errc::incomplete_message },
|
||||
{ "no_micros", {0x0b, 0x09, 0x27, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00},
|
||||
{ "incomplete_date", {0x04, 0xda, 0x07, 0x01}, type, errc::incomplete_message },
|
||||
{ "no_hours_mins_secs", {0x07, 0xda, 0x07, 0x01, 0x01}, type, errc::incomplete_message },
|
||||
{ "no_mins_secs", {0x07, 0xda, 0x07, 0x01, 0x01, 0x17}, type, errc::incomplete_message },
|
||||
{ "no_secs", {0x07, 0xda, 0x07, 0x01, 0x01, 0x17, 0x01}, type, errc::incomplete_message },
|
||||
{ "incomplete_micros", {0x0b, 0xda, 0x07, 0x01, 0x01, 0x17, 0x01, 0x3b, 0x56, 0xc3, 0x0e},
|
||||
type, errc::incomplete_message },
|
||||
{ "date_gt_max", {0x0b, 0xff, 0xff, 0x01, 0x01, 0x17, 0x01, 0x3b, 0x56, 0xc3, 0x0e, 0x00}, type },
|
||||
{ "invalid_hour", {0x0b, 0xda, 0x07, 0x01, 0x01, 24, 0x01, 0x3b, 0x56, 0xc3, 0x0e, 0x00}, type },
|
||||
{ "invalid_hour_max", {0x0b, 0xda, 0x07, 0x01, 0x01, 0xff, 0x01, 0x3b, 0x56, 0xc3, 0x0e, 0x00}, type },
|
||||
{ "invalid_year_d", {0x04, 0x10, 0x27, 0x01, 0x01}, type }, // year 10000
|
||||
{ "invalid_year_hms", {0x07, 0x10, 0x27, 0x01, 0x01, 0x17, 0x01, 0x3b}, type },
|
||||
{ "invalid_year_hmsu", {0x0b, 0x10, 0x27, 0x01, 0x01, 0x17, 0x01, 0x3b, 0x56, 0xc3, 0x0e, 0x00}, type },
|
||||
{ "invalid_year_max_hmsu", {0x0b, 0xff, 0xff, 0x01, 0x01, 0x17, 0x01, 0x3b, 0x56, 0xc3, 0x0e, 0x00}, type },
|
||||
{ "invalid_hour_hms", {0x07, 0xda, 0x07, 0x01, 0x01, 24, 0x01, 0x3b}, type },
|
||||
{ "invalid_hour_hmsu", {0x0b, 0xda, 0x07, 0x01, 0x01, 24, 0x01, 0x3b, 0x56, 0xc3, 0x0e, 0x00}, type },
|
||||
{ "invalid_hour_max_hmsu", {0x0b, 0xda, 0x07, 0x01, 0x01, 0xff, 0x01, 0x3b, 0x56, 0xc3, 0x0e, 0x00}, type },
|
||||
{ "invalid_min_hms", {0x07, 0xda, 0x07, 0x01, 0x01, 0x17, 60, 0x3b}, type },
|
||||
{ "invalid_min_hmsu", {0x0b, 0xda, 0x07, 0x01, 0x01, 0x17, 60, 0x3b, 0x56, 0xc3, 0x0e, 0x00}, type },
|
||||
{ "invalid_min_max_hmsu", {0x0b, 0xda, 0x07, 0x01, 0x01, 0x17, 0xff, 0x3b, 0x56, 0xc3, 0x0e, 0x00}, type },
|
||||
{ "invalid_sec_hms", {0x07, 0xda, 0x07, 0x01, 0x01, 0x17, 0x01, 60}, type },
|
||||
{ "invalid_sec_hmsu", {0x0b, 0xda, 0x07, 0x01, 0x01, 0x17, 0x01, 60, 0x56, 0xc3, 0x0e, 0x00}, type },
|
||||
{ "invalid_sec_max_hmsu", {0x0b, 0xda, 0x07, 0x01, 0x01, 0x17, 0x01, 0xff, 0x56, 0xc3, 0x0e, 0x00}, type },
|
||||
{ "invalid_micro_hmsu", {0x0b, 0xda, 0x07, 0x01, 0x01, 0x17, 0x01, 0x3b, 0x40, 0x42, 0xf4, 0x00}, type }, // 1M
|
||||
{ "invalid_micro_max_hmsu", {0x0b, 0xda, 0x07, 0x01, 0x01, 0x17, 0x01, 0x3b, 0xff, 0xff, 0xff, 0xff}, type },
|
||||
{ "invalid_hour_invalid_date", {0x0b, 0x00, 0x00, 0x00, 0x00, 0xff, 0x01, 0x3b, 0x56, 0xc3, 0x0e, 0x00}, type },
|
||||
{ "invalid_min", {0x0b, 0xda, 0x07, 0x01, 0x01, 0x17, 60, 0x3b, 0x56, 0xc3, 0x0e, 0x00}, type },
|
||||
{ "invalid_min_max", {0x0b, 0xda, 0x07, 0x01, 0x01, 0x17, 0xff, 0x3b, 0x56, 0xc3, 0x0e, 0x00}, type },
|
||||
{ "invalid_min_invalid_date", {0x0b, 0x00, 0x00, 0x00, 0x00, 0x17, 0xff, 0x3b, 0x56, 0xc3, 0x0e, 0x00}, type },
|
||||
{ "invalid_sec", {0x0b, 0xda, 0x07, 0x01, 0x01, 0x17, 0x01, 60, 0x56, 0xc3, 0x0e, 0x00}, type },
|
||||
{ "invalid_sec_max", {0x0b, 0xda, 0x07, 0x01, 0x01, 0x17, 0x01, 0xff, 0x56, 0xc3, 0x0e, 0x00}, type },
|
||||
{ "invalid_sec_invalid_date", {0x0b, 0x00, 0x00, 0x00, 0x00, 0x17, 0x01, 0xff, 0x56, 0xc3, 0x0e, 0x00}, type },
|
||||
{ "invalid_micro", {0x0b, 0xda, 0x07, 0x01, 0x01, 0x17, 0x01, 0x3b, 0x40, 0x42, 0xf4, 0x00}, type }, // 1M
|
||||
{ "invalid_micro_max", {0x0b, 0xda, 0x07, 0x01, 0x01, 0x17, 0x01, 0x3b, 0xff, 0xff, 0xff, 0xff}, type },
|
||||
{ "invalid_micro_invalid_date", {0x0b, 0x00, 0x00, 0x00, 0x00, 0x17, 0x01, 0x3b, 0xff, 0xff, 0xff, 0xff}, type },
|
||||
{ "protocol_max", {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, type }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user