| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
#include <aws/common/date_time.h> |
| 6 |
|
| 7 |
#include <aws/common/byte_buf.h> |
| 8 |
|
| 9 |
#include <aws/testing/aws_test_harness.h> |
| 10 |
|
| 11 |
static int s_test_rfc822_utc_parsing_fn(struct aws_allocator *allocator, void *ctx) { |
| 12 |
(void)allocator; |
| 13 |
(void)ctx; |
| 14 |
|
| 15 |
const char *valid_utc_dates[] = { |
| 16 |
"Wed, 02 Oct 2002 08:05:09 GMT", |
| 17 |
"Wed, 02 Oct 2002 08:05:09 UT", |
| 18 |
"Wed, 02 Oct 2002 08:05:09 Z", |
| 19 |
"Wed, 02 Oct 2002 08:05:09 UTC", |
| 20 |
}; |
| 21 |
|
| 22 |
for (size_t i = 0; i < AWS_ARRAY_SIZE(valid_utc_dates); ++i) { |
| 23 |
struct aws_date_time date_time; |
| 24 |
const char *date_str = valid_utc_dates[i]; |
| 25 |
struct aws_byte_buf date_buf = aws_byte_buf_from_c_str(date_str); |
| 26 |
|
| 27 |
ASSERT_SUCCESS(aws_date_time_init_from_str(&date_time, &date_buf, AWS_DATE_FORMAT_RFC822)); |
| 28 |
ASSERT_INT_EQUALS(AWS_DATE_DAY_OF_WEEK_WEDNESDAY, aws_date_time_day_of_week(&date_time, false)); |
| 29 |
ASSERT_UINT_EQUALS(2, aws_date_time_month_day(&date_time, false)); |
| 30 |
ASSERT_UINT_EQUALS(AWS_DATE_MONTH_OCTOBER, aws_date_time_month(&date_time, false)); |
| 31 |
ASSERT_UINT_EQUALS(2002, aws_date_time_year(&date_time, false)); |
| 32 |
ASSERT_UINT_EQUALS(8, aws_date_time_hour(&date_time, false)); |
| 33 |
ASSERT_UINT_EQUALS(5, aws_date_time_minute(&date_time, false)); |
| 34 |
ASSERT_UINT_EQUALS(9, aws_date_time_second(&date_time, false)); |
| 35 |
|
| 36 |
uint8_t date_output[AWS_DATE_TIME_STR_MAX_LEN]; |
| 37 |
AWS_ZERO_ARRAY(date_output); |
| 38 |
struct aws_byte_buf str_output = aws_byte_buf_from_array(date_output, sizeof(date_output)); |
| 39 |
str_output.len = 0; |
| 40 |
ASSERT_SUCCESS(aws_date_time_to_utc_time_str(&date_time, AWS_DATE_FORMAT_RFC822, &str_output)); |
| 41 |
|
| 42 |
const char *expected_long_str = "Wed, 02 Oct 2002 08:05:09 GMT"; |
| 43 |
struct aws_byte_buf expected_long_buf = aws_byte_buf_from_c_str(expected_long_str); |
| 44 |
|
| 45 |
ASSERT_BIN_ARRAYS_EQUALS(expected_long_buf.buffer, expected_long_buf.len, str_output.buffer, str_output.len); |
| 46 |
|
| 47 |
AWS_ZERO_ARRAY(date_output); |
| 48 |
str_output.len = 0; |
| 49 |
ASSERT_SUCCESS(aws_date_time_to_utc_time_short_str(&date_time, AWS_DATE_FORMAT_RFC822, &str_output)); |
| 50 |
|
| 51 |
const char *expected_short_str = "Wed, 02 Oct 2002"; |
| 52 |
struct aws_byte_buf expected_short_buf = aws_byte_buf_from_c_str(expected_short_str); |
| 53 |
|
| 54 |
ASSERT_BIN_ARRAYS_EQUALS(expected_short_buf.buffer, expected_short_buf.len, str_output.buffer, str_output.len); |
| 55 |
} |
| 56 |
|
| 57 |
return AWS_OP_SUCCESS; |
| 58 |
} |
| 59 |
|
| 60 |
AWS_TEST_CASE(rfc822_utc_parsing, s_test_rfc822_utc_parsing_fn) |
| 61 |
|
| 62 |
static int s_test_rfc822_utc_parsing_auto_detect_fn(struct aws_allocator *allocator, void *ctx) { |
| 63 |
(void)allocator; |
| 64 |
(void)ctx; |
| 65 |
|
| 66 |
struct aws_date_time date_time; |
| 67 |
const char *date_str = "Wed, 02 Oct 2002 08:05:09 GMT"; |
| 68 |
struct aws_byte_buf date_buf = aws_byte_buf_from_c_str(date_str); |
| 69 |
|
| 70 |
ASSERT_SUCCESS(aws_date_time_init_from_str(&date_time, &date_buf, AWS_DATE_FORMAT_AUTO_DETECT)); |
| 71 |
ASSERT_INT_EQUALS(AWS_DATE_DAY_OF_WEEK_WEDNESDAY, aws_date_time_day_of_week(&date_time, false)); |
| 72 |
ASSERT_UINT_EQUALS(2, aws_date_time_month_day(&date_time, false)); |
| 73 |
ASSERT_UINT_EQUALS(AWS_DATE_MONTH_OCTOBER, aws_date_time_month(&date_time, false)); |
| 74 |
ASSERT_UINT_EQUALS(2002, aws_date_time_year(&date_time, false)); |
| 75 |
ASSERT_UINT_EQUALS(8, aws_date_time_hour(&date_time, false)); |
| 76 |
ASSERT_UINT_EQUALS(5, aws_date_time_minute(&date_time, false)); |
| 77 |
ASSERT_UINT_EQUALS(9, aws_date_time_second(&date_time, false)); |
| 78 |
|
| 79 |
uint8_t date_output[AWS_DATE_TIME_STR_MAX_LEN]; |
| 80 |
AWS_ZERO_ARRAY(date_output); |
| 81 |
struct aws_byte_buf str_output = aws_byte_buf_from_array(date_output, sizeof(date_output)); |
| 82 |
str_output.len = 0; |
| 83 |
ASSERT_SUCCESS(aws_date_time_to_utc_time_str(&date_time, AWS_DATE_FORMAT_RFC822, &str_output)); |
| 84 |
|
| 85 |
ASSERT_BIN_ARRAYS_EQUALS(date_buf.buffer, date_buf.len, str_output.buffer, str_output.len); |
| 86 |
|
| 87 |
return AWS_OP_SUCCESS; |
| 88 |
} |
| 89 |
|
| 90 |
AWS_TEST_CASE(rfc822_utc_parsing_auto_detect, s_test_rfc822_utc_parsing_auto_detect_fn) |
| 91 |
|
| 92 |
static int s_test_rfc822_local_time_east_of_gmt_parsing_fn(struct aws_allocator *allocator, void *ctx) { |
| 93 |
(void)allocator; |
| 94 |
(void)ctx; |
| 95 |
|
| 96 |
struct aws_date_time date_time; |
| 97 |
const char *date_str = "Wed, 02 Oct 2002 09:35:09 +0130"; |
| 98 |
struct aws_byte_buf date_buf = aws_byte_buf_from_c_str(date_str); |
| 99 |
|
| 100 |
ASSERT_SUCCESS(aws_date_time_init_from_str(&date_time, &date_buf, AWS_DATE_FORMAT_RFC822)); |
| 101 |
ASSERT_INT_EQUALS(AWS_DATE_DAY_OF_WEEK_WEDNESDAY, aws_date_time_day_of_week(&date_time, false)); |
| 102 |
ASSERT_UINT_EQUALS(2, aws_date_time_month_day(&date_time, false)); |
| 103 |
ASSERT_UINT_EQUALS(AWS_DATE_MONTH_OCTOBER, aws_date_time_month(&date_time, false)); |
| 104 |
ASSERT_UINT_EQUALS(2002, aws_date_time_year(&date_time, false)); |
| 105 |
ASSERT_UINT_EQUALS(8, aws_date_time_hour(&date_time, false)); |
| 106 |
ASSERT_UINT_EQUALS(5, aws_date_time_minute(&date_time, false)); |
| 107 |
ASSERT_UINT_EQUALS(9, aws_date_time_second(&date_time, false)); |
| 108 |
|
| 109 |
uint8_t date_output[AWS_DATE_TIME_STR_MAX_LEN]; |
| 110 |
AWS_ZERO_ARRAY(date_output); |
| 111 |
struct aws_byte_buf str_output = aws_byte_buf_from_array(date_output, sizeof(date_output)); |
| 112 |
str_output.len = 0; |
| 113 |
ASSERT_SUCCESS(aws_date_time_to_utc_time_str(&date_time, AWS_DATE_FORMAT_RFC822, &str_output)); |
| 114 |
|
| 115 |
const char *expected_str = "Wed, 02 Oct 2002 08:05:09 GMT"; |
| 116 |
struct aws_byte_buf expected_buf = aws_byte_buf_from_c_str(expected_str); |
| 117 |
|
| 118 |
ASSERT_BIN_ARRAYS_EQUALS(expected_buf.buffer, expected_buf.len, str_output.buffer, str_output.len); |
| 119 |
|
| 120 |
return AWS_OP_SUCCESS; |
| 121 |
} |
| 122 |
|
| 123 |
AWS_TEST_CASE(rfc822_local_time_east_of_gmt_parsing, s_test_rfc822_local_time_east_of_gmt_parsing_fn) |
| 124 |
|
| 125 |
static int s_test_rfc822_local_time_west_of_gmt_parsing_fn(struct aws_allocator *allocator, void *ctx) { |
| 126 |
(void)allocator; |
| 127 |
(void)ctx; |
| 128 |
|
| 129 |
struct aws_date_time date_time; |
| 130 |
const char *date_str = "Wed, 02 Oct 2002 07:05:09 -0100"; |
| 131 |
struct aws_byte_buf date_buf = aws_byte_buf_from_c_str(date_str); |
| 132 |
|
| 133 |
ASSERT_SUCCESS(aws_date_time_init_from_str(&date_time, &date_buf, AWS_DATE_FORMAT_RFC822)); |
| 134 |
ASSERT_INT_EQUALS(AWS_DATE_DAY_OF_WEEK_WEDNESDAY, aws_date_time_day_of_week(&date_time, false)); |
| 135 |
ASSERT_UINT_EQUALS(2, aws_date_time_month_day(&date_time, false)); |
| 136 |
ASSERT_UINT_EQUALS(AWS_DATE_MONTH_OCTOBER, aws_date_time_month(&date_time, false)); |
| 137 |
ASSERT_UINT_EQUALS(2002, aws_date_time_year(&date_time, false)); |
| 138 |
ASSERT_UINT_EQUALS(8, aws_date_time_hour(&date_time, false)); |
| 139 |
ASSERT_UINT_EQUALS(5, aws_date_time_minute(&date_time, false)); |
| 140 |
ASSERT_UINT_EQUALS(9, aws_date_time_second(&date_time, false)); |
| 141 |
|
| 142 |
uint8_t date_output[AWS_DATE_TIME_STR_MAX_LEN]; |
| 143 |
AWS_ZERO_ARRAY(date_output); |
| 144 |
struct aws_byte_buf str_output = aws_byte_buf_from_array(date_output, sizeof(date_output)); |
| 145 |
str_output.len = 0; |
| 146 |
ASSERT_SUCCESS(aws_date_time_to_utc_time_str(&date_time, AWS_DATE_FORMAT_RFC822, &str_output)); |
| 147 |
|
| 148 |
const char *expected_str = "Wed, 02 Oct 2002 08:05:09 GMT"; |
| 149 |
struct aws_byte_buf expected_buf = aws_byte_buf_from_c_str(expected_str); |
| 150 |
|
| 151 |
ASSERT_BIN_ARRAYS_EQUALS(expected_buf.buffer, expected_buf.len, str_output.buffer, str_output.len); |
| 152 |
|
| 153 |
return AWS_OP_SUCCESS; |
| 154 |
} |
| 155 |
|
| 156 |
AWS_TEST_CASE(rfc822_local_time_west_of_gmt_parsing, s_test_rfc822_local_time_west_of_gmt_parsing_fn) |
| 157 |
|
| 158 |
static int s_test_rfc822_utc_two_digit_year_parsing_fn(struct aws_allocator *allocator, void *ctx) { |
| 159 |
(void)allocator; |
| 160 |
(void)ctx; |
| 161 |
|
| 162 |
struct aws_date_time date_time; |
| 163 |
const char *date_str = "Wed, 02 Oct 02 08:05:09 GMT"; |
| 164 |
struct aws_byte_buf date_buf = aws_byte_buf_from_c_str(date_str); |
| 165 |
|
| 166 |
ASSERT_SUCCESS(aws_date_time_init_from_str(&date_time, &date_buf, AWS_DATE_FORMAT_RFC822)); |
| 167 |
ASSERT_INT_EQUALS(AWS_DATE_DAY_OF_WEEK_WEDNESDAY, aws_date_time_day_of_week(&date_time, false)); |
| 168 |
ASSERT_UINT_EQUALS(2, aws_date_time_month_day(&date_time, false)); |
| 169 |
ASSERT_UINT_EQUALS(AWS_DATE_MONTH_OCTOBER, aws_date_time_month(&date_time, false)); |
| 170 |
ASSERT_UINT_EQUALS(2002, aws_date_time_year(&date_time, false)); |
| 171 |
ASSERT_UINT_EQUALS(8, aws_date_time_hour(&date_time, false)); |
| 172 |
ASSERT_UINT_EQUALS(5, aws_date_time_minute(&date_time, false)); |
| 173 |
ASSERT_UINT_EQUALS(9, aws_date_time_second(&date_time, false)); |
| 174 |
|
| 175 |
uint8_t date_output[AWS_DATE_TIME_STR_MAX_LEN]; |
| 176 |
AWS_ZERO_ARRAY(date_output); |
| 177 |
struct aws_byte_buf str_output = aws_byte_buf_from_array(date_output, sizeof(date_output)); |
| 178 |
str_output.len = 0; |
| 179 |
ASSERT_SUCCESS(aws_date_time_to_utc_time_str(&date_time, AWS_DATE_FORMAT_RFC822, &str_output)); |
| 180 |
|
| 181 |
const char *expected_date_str = "Wed, 02 Oct 2002 08:05:09 GMT"; |
| 182 |
struct aws_byte_buf expected_date_buf = aws_byte_buf_from_c_str(expected_date_str); |
| 183 |
ASSERT_BIN_ARRAYS_EQUALS(expected_date_buf.buffer, expected_date_buf.len, str_output.buffer, str_output.len); |
| 184 |
|
| 185 |
return AWS_OP_SUCCESS; |
| 186 |
} |
| 187 |
|
| 188 |
AWS_TEST_CASE(rfc822_utc_two_digit_year_parsing, s_test_rfc822_utc_two_digit_year_parsing_fn) |
| 189 |
|
| 190 |
static int s_test_rfc822_utc_no_dow_parsing_fn(struct aws_allocator *allocator, void *ctx) { |
| 191 |
(void)allocator; |
| 192 |
(void)ctx; |
| 193 |
|
| 194 |
struct aws_date_time date_time; |
| 195 |
const char *date_str = "02 Oct 02 08:05:09 GMT"; |
| 196 |
struct aws_byte_buf date_buf = aws_byte_buf_from_c_str(date_str); |
| 197 |
|
| 198 |
ASSERT_SUCCESS(aws_date_time_init_from_str(&date_time, &date_buf, AWS_DATE_FORMAT_RFC822)); |
| 199 |
ASSERT_INT_EQUALS(AWS_DATE_DAY_OF_WEEK_WEDNESDAY, aws_date_time_day_of_week(&date_time, false)); |
| 200 |
ASSERT_UINT_EQUALS(2, aws_date_time_month_day(&date_time, false)); |
| 201 |
ASSERT_UINT_EQUALS(AWS_DATE_MONTH_OCTOBER, aws_date_time_month(&date_time, false)); |
| 202 |
ASSERT_UINT_EQUALS(2002, aws_date_time_year(&date_time, false)); |
| 203 |
ASSERT_UINT_EQUALS(8, aws_date_time_hour(&date_time, false)); |
| 204 |
ASSERT_UINT_EQUALS(5, aws_date_time_minute(&date_time, false)); |
| 205 |
ASSERT_UINT_EQUALS(9, aws_date_time_second(&date_time, false)); |
| 206 |
|
| 207 |
uint8_t date_output[AWS_DATE_TIME_STR_MAX_LEN]; |
| 208 |
AWS_ZERO_ARRAY(date_output); |
| 209 |
struct aws_byte_buf str_output = aws_byte_buf_from_array(date_output, sizeof(date_output)); |
| 210 |
str_output.len = 0; |
| 211 |
ASSERT_SUCCESS(aws_date_time_to_utc_time_str(&date_time, AWS_DATE_FORMAT_RFC822, &str_output)); |
| 212 |
|
| 213 |
const char *expected_date_str = "Wed, 02 Oct 2002 08:05:09 GMT"; |
| 214 |
struct aws_byte_buf expected_date_buf = aws_byte_buf_from_c_str(expected_date_str); |
| 215 |
ASSERT_BIN_ARRAYS_EQUALS(expected_date_buf.buffer, expected_date_buf.len, str_output.buffer, str_output.len); |
| 216 |
|
| 217 |
return AWS_OP_SUCCESS; |
| 218 |
} |
| 219 |
|
| 220 |
AWS_TEST_CASE(rfc822_utc_no_dow_parsing, s_test_rfc822_utc_no_dow_parsing_fn) |
| 221 |
|
| 222 |
static int s_test_rfc822_utc_dos_prevented_fn(struct aws_allocator *allocator, void *ctx) { |
| 223 |
(void)allocator; |
| 224 |
(void)ctx; |
| 225 |
|
| 226 |
struct aws_date_time date_time; |
| 227 |
const char *date_str = "Weddkasdiweijbnawei8eriojngsdgasdgsdf1gasd8asdgfasdfgsdikweisdfksdnsdksdklas" |
| 228 |
"dfsdklasdfdfsdfsdfsdfsadfasdafsdfgjjfgghdfgsdfsfsdfsdfasdfsdfasdfsdfasdfsdf"; |
| 229 |
struct aws_byte_buf date_buf = aws_byte_buf_from_c_str(date_str); |
| 230 |
|
| 231 |
ASSERT_ERROR( |
| 232 |
AWS_ERROR_OVERFLOW_DETECTED, aws_date_time_init_from_str(&date_time, &date_buf, AWS_DATE_FORMAT_RFC822)); |
| 233 |
|
| 234 |
return AWS_OP_SUCCESS; |
| 235 |
} |
| 236 |
|
| 237 |
AWS_TEST_CASE(rfc822_utc_dos_prevented, s_test_rfc822_utc_dos_prevented_fn) |
| 238 |
|
| 239 |
static int s_test_rfc822_invalid_format_fn(struct aws_allocator *allocator, void *ctx) { |
| 240 |
(void)allocator; |
| 241 |
(void)ctx; |
| 242 |
|
| 243 |
struct aws_date_time date_time; |
| 244 |
const char *date_str = "Wed, 02 Oct 2002"; |
| 245 |
struct aws_byte_buf date_buf = aws_byte_buf_from_c_str(date_str); |
| 246 |
|
| 247 |
ASSERT_ERROR( |
| 248 |
AWS_ERROR_INVALID_DATE_STR, aws_date_time_init_from_str(&date_time, &date_buf, AWS_DATE_FORMAT_RFC822)); |
| 249 |
|
| 250 |
return AWS_OP_SUCCESS; |
| 251 |
} |
| 252 |
|
| 253 |
AWS_TEST_CASE(rfc822_invalid_format, s_test_rfc822_invalid_format_fn) |
| 254 |
|
| 255 |
static int s_test_rfc822_invalid_tz_fn(struct aws_allocator *allocator, void *ctx) { |
| 256 |
(void)allocator; |
| 257 |
(void)ctx; |
| 258 |
|
| 259 |
struct aws_date_time date_time; |
| 260 |
const char *date_str = "Wed, 02 Oct 2002 08:05:09 DST"; |
| 261 |
struct aws_byte_buf date_buf = aws_byte_buf_from_c_str(date_str); |
| 262 |
|
| 263 |
ASSERT_ERROR( |
| 264 |
AWS_ERROR_INVALID_DATE_STR, aws_date_time_init_from_str(&date_time, &date_buf, AWS_DATE_FORMAT_RFC822)); |
| 265 |
|
| 266 |
return AWS_OP_SUCCESS; |
| 267 |
} |
| 268 |
|
| 269 |
AWS_TEST_CASE(rfc822_invalid_tz, s_test_rfc822_invalid_tz_fn) |
| 270 |
|
| 271 |
static int s_test_rfc822_invalid_auto_format_fn(struct aws_allocator *allocator, void *ctx) { |
| 272 |
(void)allocator; |
| 273 |
(void)ctx; |
| 274 |
|
| 275 |
struct aws_date_time date_time; |
| 276 |
const char *date_str = "Wed, 02 Oct 2002"; |
| 277 |
struct aws_byte_buf date_buf = aws_byte_buf_from_c_str(date_str); |
| 278 |
|
| 279 |
ASSERT_ERROR( |
| 280 |
AWS_ERROR_INVALID_DATE_STR, aws_date_time_init_from_str(&date_time, &date_buf, AWS_DATE_FORMAT_AUTO_DETECT)); |
| 281 |
|
| 282 |
return AWS_OP_SUCCESS; |
| 283 |
} |
| 284 |
|
| 285 |
AWS_TEST_CASE(rfc822_invalid_auto_format, s_test_rfc822_invalid_auto_format_fn) |
| 286 |
|
| 287 |
static int s_test_iso8601_parsing_fn(struct aws_allocator *allocator, void *ctx) { |
| 288 |
(void)allocator; |
| 289 |
(void)ctx; |
| 290 |
|
| 291 |
|
| 292 |
const char *valid_dates[][2] = { |
| 293 |
{"2002-10-02T08:05:09.000Z", "extended format"}, |
| 294 |
{"2002-10-02t08:05:09.000z", "lowercase T and Z"}, |
| 295 |
{"2002-10-02 08:05:09Z", "space instead of T"}, |
| 296 |
{"2002-10-02T08:05:09+00:00", "offset instead of Z"}, |
| 297 |
{"2002-10-01T19:31:09-12:34", "western offset"}, |
| 298 |
{"2002-10-02T20:39:09+12:34", "eastern offset"}, |
| 299 |
{"2002-10-02T08:05:09.000+00:00", "fractional seconds and offset"}, |
| 300 |
{"20021002T080509.000Z", "basic format"}, |
| 301 |
{"20021002T203909+1234", "basic format with fractional seconds"}, |
| 302 |
{"2002-10-02T080509.000Z", "weird mix of extended date but basic time"}, |
| 303 |
{"20021002T08:05:09.000Z", "weird mix of basic date but extended time"}, |
| 304 |
{"2002-10-02T20:39:09+1234", "weird mix of extended date and time but basic fractional seconds"}, |
| 305 |
}; |
| 306 |
|
| 307 |
for (size_t i = 0; i < AWS_ARRAY_SIZE(valid_dates); ++i) { |
| 308 |
const char *date_str = valid_dates[i][0]; |
| 309 |
const char *description = valid_dates[i][1]; |
| 310 |
printf("checking date[%zu] \"%s\" (%s)\n", i, date_str, description); |
| 311 |
|
| 312 |
struct aws_date_time date_time; |
| 313 |
struct aws_byte_buf date_buf = aws_byte_buf_from_c_str(date_str); |
| 314 |
|
| 315 |
ASSERT_SUCCESS(aws_date_time_init_from_str(&date_time, &date_buf, AWS_DATE_FORMAT_ISO_8601)); |
| 316 |
ASSERT_INT_EQUALS(AWS_DATE_DAY_OF_WEEK_WEDNESDAY, aws_date_time_day_of_week(&date_time, false)); |
| 317 |
ASSERT_UINT_EQUALS(2, aws_date_time_month_day(&date_time, false)); |
| 318 |
ASSERT_UINT_EQUALS(AWS_DATE_MONTH_OCTOBER, aws_date_time_month(&date_time, false)); |
| 319 |
ASSERT_UINT_EQUALS(2002, aws_date_time_year(&date_time, false)); |
| 320 |
ASSERT_UINT_EQUALS(8, aws_date_time_hour(&date_time, false)); |
| 321 |
ASSERT_UINT_EQUALS(5, aws_date_time_minute(&date_time, false)); |
| 322 |
ASSERT_UINT_EQUALS(9, aws_date_time_second(&date_time, false)); |
| 323 |
|
| 324 |
uint8_t date_output[AWS_DATE_TIME_STR_MAX_LEN]; |
| 325 |
AWS_ZERO_ARRAY(date_output); |
| 326 |
struct aws_byte_buf str_output = aws_byte_buf_from_array(date_output, sizeof(date_output)); |
| 327 |
str_output.len = 0; |
| 328 |
ASSERT_SUCCESS(aws_date_time_to_utc_time_str(&date_time, AWS_DATE_FORMAT_ISO_8601, &str_output)); |
| 329 |
|
| 330 |
const char *expected_date_str = "2002-10-02T08:05:09Z"; |
| 331 |
struct aws_byte_buf expected_date_buf = aws_byte_buf_from_c_str(expected_date_str); |
| 332 |
ASSERT_BIN_ARRAYS_EQUALS(expected_date_buf.buffer, expected_date_buf.len, str_output.buffer, str_output.len); |
| 333 |
|
| 334 |
AWS_ZERO_ARRAY(date_output); |
| 335 |
str_output.len = 0; |
| 336 |
ASSERT_SUCCESS(aws_date_time_to_utc_time_short_str(&date_time, AWS_DATE_FORMAT_ISO_8601, &str_output)); |
| 337 |
|
| 338 |
const char *expected_short_str = "2002-10-02"; |
| 339 |
struct aws_byte_buf expected_short_buf = aws_byte_buf_from_c_str(expected_short_str); |
| 340 |
|
| 341 |
ASSERT_BIN_ARRAYS_EQUALS(expected_short_buf.buffer, expected_short_buf.len, str_output.buffer, str_output.len); |
| 342 |
} |
| 343 |
return AWS_OP_SUCCESS; |
| 344 |
} |
| 345 |
|
| 346 |
AWS_TEST_CASE(iso8601_parsing, s_test_iso8601_parsing_fn) |
| 347 |
|
| 348 |
static int s_test_iso8601_basic_utc_parsing_fn(struct aws_allocator *allocator, void *ctx) { |
| 349 |
(void)allocator; |
| 350 |
(void)ctx; |
| 351 |
|
| 352 |
struct aws_date_time date_time; |
| 353 |
const char *date_str = "20021002T080509.000Z"; |
| 354 |
struct aws_byte_buf date_buf = aws_byte_buf_from_c_str(date_str); |
| 355 |
|
| 356 |
ASSERT_SUCCESS(aws_date_time_init_from_str(&date_time, &date_buf, AWS_DATE_FORMAT_ISO_8601_BASIC)); |
| 357 |
ASSERT_INT_EQUALS(AWS_DATE_DAY_OF_WEEK_WEDNESDAY, aws_date_time_day_of_week(&date_time, false)); |
| 358 |
ASSERT_UINT_EQUALS(2, aws_date_time_month_day(&date_time, false)); |
| 359 |
ASSERT_UINT_EQUALS(AWS_DATE_MONTH_OCTOBER, aws_date_time_month(&date_time, false)); |
| 360 |
ASSERT_UINT_EQUALS(2002, aws_date_time_year(&date_time, false)); |
| 361 |
ASSERT_UINT_EQUALS(8, aws_date_time_hour(&date_time, false)); |
| 362 |
ASSERT_UINT_EQUALS(5, aws_date_time_minute(&date_time, false)); |
| 363 |
ASSERT_UINT_EQUALS(9, aws_date_time_second(&date_time, false)); |
| 364 |
|
| 365 |
uint8_t date_output[AWS_DATE_TIME_STR_MAX_LEN]; |
| 366 |
AWS_ZERO_ARRAY(date_output); |
| 367 |
struct aws_byte_buf str_output = aws_byte_buf_from_array(date_output, sizeof(date_output)); |
| 368 |
str_output.len = 0; |
| 369 |
ASSERT_SUCCESS(aws_date_time_to_utc_time_str(&date_time, AWS_DATE_FORMAT_ISO_8601_BASIC, &str_output)); |
| 370 |
|
| 371 |
const char *expected_date_str = "20021002T080509Z"; |
| 372 |
struct aws_byte_buf expected_date_buf = aws_byte_buf_from_c_str(expected_date_str); |
| 373 |
ASSERT_BIN_ARRAYS_EQUALS(expected_date_buf.buffer, expected_date_buf.len, str_output.buffer, str_output.len); |
| 374 |
|
| 375 |
AWS_ZERO_ARRAY(date_output); |
| 376 |
str_output.len = 0; |
| 377 |
ASSERT_SUCCESS(aws_date_time_to_utc_time_short_str(&date_time, AWS_DATE_FORMAT_ISO_8601_BASIC, &str_output)); |
| 378 |
|
| 379 |
const char *expected_short_str = "20021002"; |
| 380 |
struct aws_byte_buf expected_short_buf = aws_byte_buf_from_c_str(expected_short_str); |
| 381 |
|
| 382 |
ASSERT_BIN_ARRAYS_EQUALS(expected_short_buf.buffer, expected_short_buf.len, str_output.buffer, str_output.len); |
| 383 |
return AWS_OP_SUCCESS; |
| 384 |
} |
| 385 |
|
| 386 |
AWS_TEST_CASE(iso8601_basic_utc_parsing, s_test_iso8601_basic_utc_parsing_fn) |
| 387 |
|
| 388 |
static int s_test_iso8601_utc_parsing_auto_detect_fn(struct aws_allocator *allocator, void *ctx) { |
| 389 |
(void)allocator; |
| 390 |
(void)ctx; |
| 391 |
|
| 392 |
struct aws_date_time date_time; |
| 393 |
const char *date_str = "2002-10-02T08:05:09.000Z"; |
| 394 |
struct aws_byte_buf date_buf = aws_byte_buf_from_c_str(date_str); |
| 395 |
|
| 396 |
ASSERT_SUCCESS(aws_date_time_init_from_str(&date_time, &date_buf, AWS_DATE_FORMAT_AUTO_DETECT)); |
| 397 |
ASSERT_INT_EQUALS(AWS_DATE_DAY_OF_WEEK_WEDNESDAY, aws_date_time_day_of_week(&date_time, false)); |
| 398 |
ASSERT_UINT_EQUALS(2, aws_date_time_month_day(&date_time, false)); |
| 399 |
ASSERT_UINT_EQUALS(AWS_DATE_MONTH_OCTOBER, aws_date_time_month(&date_time, false)); |
| 400 |
ASSERT_UINT_EQUALS(2002, aws_date_time_year(&date_time, false)); |
| 401 |
ASSERT_UINT_EQUALS(8, aws_date_time_hour(&date_time, false)); |
| 402 |
ASSERT_UINT_EQUALS(5, aws_date_time_minute(&date_time, false)); |
| 403 |
ASSERT_UINT_EQUALS(9, aws_date_time_second(&date_time, false)); |
| 404 |
|
| 405 |
uint8_t date_output[AWS_DATE_TIME_STR_MAX_LEN]; |
| 406 |
AWS_ZERO_ARRAY(date_output); |
| 407 |
struct aws_byte_buf str_output = aws_byte_buf_from_array(date_output, sizeof(date_output)); |
| 408 |
str_output.len = 0; |
| 409 |
ASSERT_SUCCESS(aws_date_time_to_utc_time_str(&date_time, AWS_DATE_FORMAT_ISO_8601, &str_output)); |
| 410 |
|
| 411 |
const char *expected_date_str = "2002-10-02T08:05:09Z"; |
| 412 |
struct aws_byte_buf expected_date_buf = aws_byte_buf_from_c_str(expected_date_str); |
| 413 |
ASSERT_BIN_ARRAYS_EQUALS(expected_date_buf.buffer, expected_date_buf.len, str_output.buffer, str_output.len); |
| 414 |
|
| 415 |
return AWS_OP_SUCCESS; |
| 416 |
} |
| 417 |
|
| 418 |
AWS_TEST_CASE(iso8601_utc_parsing_auto_detect, s_test_iso8601_utc_parsing_auto_detect_fn) |
| 419 |
|
| 420 |
static int s_test_iso8601_basic_utc_parsing_auto_detect_fn(struct aws_allocator *allocator, void *ctx) { |
| 421 |
(void)allocator; |
| 422 |
(void)ctx; |
| 423 |
|
| 424 |
struct aws_date_time date_time; |
| 425 |
const char *date_str = "20021002T080509,000Z"; |
| 426 |
struct aws_byte_buf date_buf = aws_byte_buf_from_c_str(date_str); |
| 427 |
|
| 428 |
ASSERT_SUCCESS(aws_date_time_init_from_str(&date_time, &date_buf, AWS_DATE_FORMAT_AUTO_DETECT)); |
| 429 |
ASSERT_INT_EQUALS(AWS_DATE_DAY_OF_WEEK_WEDNESDAY, aws_date_time_day_of_week(&date_time, false)); |
| 430 |
ASSERT_UINT_EQUALS(2, aws_date_time_month_day(&date_time, false)); |
| 431 |
ASSERT_UINT_EQUALS(AWS_DATE_MONTH_OCTOBER, aws_date_time_month(&date_time, false)); |
| 432 |
ASSERT_UINT_EQUALS(2002, aws_date_time_year(&date_time, false)); |
| 433 |
ASSERT_UINT_EQUALS(8, aws_date_time_hour(&date_time, false)); |
| 434 |
ASSERT_UINT_EQUALS(5, aws_date_time_minute(&date_time, false)); |
| 435 |
ASSERT_UINT_EQUALS(9, aws_date_time_second(&date_time, false)); |
| 436 |
|
| 437 |
uint8_t date_output[AWS_DATE_TIME_STR_MAX_LEN]; |
| 438 |
AWS_ZERO_ARRAY(date_output); |
| 439 |
struct aws_byte_buf str_output = aws_byte_buf_from_array(date_output, sizeof(date_output)); |
| 440 |
str_output.len = 0; |
| 441 |
ASSERT_SUCCESS(aws_date_time_to_utc_time_str(&date_time, AWS_DATE_FORMAT_ISO_8601_BASIC, &str_output)); |
| 442 |
|
| 443 |
const char *expected_date_str = "20021002T080509Z"; |
| 444 |
struct aws_byte_buf expected_date_buf = aws_byte_buf_from_c_str(expected_date_str); |
| 445 |
ASSERT_BIN_ARRAYS_EQUALS(expected_date_buf.buffer, expected_date_buf.len, str_output.buffer, str_output.len); |
| 446 |
|
| 447 |
return AWS_OP_SUCCESS; |
| 448 |
} |
| 449 |
|
| 450 |
AWS_TEST_CASE(iso8601_basic_utc_parsing_auto_detect, s_test_iso8601_basic_utc_parsing_auto_detect_fn) |
| 451 |
|
| 452 |
static int s_test_iso8601_date_only_parsing_fn(struct aws_allocator *allocator, void *ctx) { |
| 453 |
(void)allocator; |
| 454 |
(void)ctx; |
| 455 |
|
| 456 |
struct aws_date_time date_time; |
| 457 |
const char *date_str = "2002-10-02"; |
| 458 |
struct aws_byte_buf date_buf = aws_byte_buf_from_c_str(date_str); |
| 459 |
|
| 460 |
ASSERT_SUCCESS(aws_date_time_init_from_str(&date_time, &date_buf, AWS_DATE_FORMAT_ISO_8601)); |
| 461 |
ASSERT_INT_EQUALS(AWS_DATE_DAY_OF_WEEK_WEDNESDAY, aws_date_time_day_of_week(&date_time, false)); |
| 462 |
ASSERT_UINT_EQUALS(2, aws_date_time_month_day(&date_time, false)); |
| 463 |
ASSERT_UINT_EQUALS(AWS_DATE_MONTH_OCTOBER, aws_date_time_month(&date_time, false)); |
| 464 |
ASSERT_UINT_EQUALS(2002, aws_date_time_year(&date_time, false)); |
| 465 |
ASSERT_UINT_EQUALS(0, aws_date_time_hour(&date_time, false)); |
| 466 |
ASSERT_UINT_EQUALS(0, aws_date_time_minute(&date_time, false)); |
| 467 |
ASSERT_UINT_EQUALS(0, aws_date_time_second(&date_time, false)); |
| 468 |
|
| 469 |
uint8_t date_output[AWS_DATE_TIME_STR_MAX_LEN]; |
| 470 |
AWS_ZERO_ARRAY(date_output); |
| 471 |
struct aws_byte_buf str_output = aws_byte_buf_from_array(date_output, sizeof(date_output)); |
| 472 |
str_output.len = 0; |
| 473 |
ASSERT_SUCCESS(aws_date_time_to_utc_time_str(&date_time, AWS_DATE_FORMAT_ISO_8601, &str_output)); |
| 474 |
|
| 475 |
const char *expected_date_str = "2002-10-02T00:00:00Z"; |
| 476 |
struct aws_byte_buf expected_date_buf = aws_byte_buf_from_c_str(expected_date_str); |
| 477 |
ASSERT_BIN_ARRAYS_EQUALS(expected_date_buf.buffer, expected_date_buf.len, str_output.buffer, str_output.len); |
| 478 |
|
| 479 |
return AWS_OP_SUCCESS; |
| 480 |
} |
| 481 |
|
| 482 |
AWS_TEST_CASE(iso8601_date_only_parsing, s_test_iso8601_date_only_parsing_fn) |
| 483 |
|
| 484 |
static int s_test_iso8601_basic_date_only_parsing_fn(struct aws_allocator *allocator, void *ctx) { |
| 485 |
(void)allocator; |
| 486 |
(void)ctx; |
| 487 |
|
| 488 |
struct aws_date_time date_time; |
| 489 |
const char *date_str = "20021002"; |
| 490 |
struct aws_byte_buf date_buf = aws_byte_buf_from_c_str(date_str); |
| 491 |
|
| 492 |
ASSERT_SUCCESS(aws_date_time_init_from_str(&date_time, &date_buf, AWS_DATE_FORMAT_ISO_8601_BASIC)); |
| 493 |
ASSERT_INT_EQUALS(AWS_DATE_DAY_OF_WEEK_WEDNESDAY, aws_date_time_day_of_week(&date_time, false)); |
| 494 |
ASSERT_UINT_EQUALS(2, aws_date_time_month_day(&date_time, false)); |
| 495 |
ASSERT_UINT_EQUALS(AWS_DATE_MONTH_OCTOBER, aws_date_time_month(&date_time, false)); |
| 496 |
ASSERT_UINT_EQUALS(2002, aws_date_time_year(&date_time, false)); |
| 497 |
ASSERT_UINT_EQUALS(0, aws_date_time_hour(&date_time, false)); |
| 498 |
ASSERT_UINT_EQUALS(0, aws_date_time_minute(&date_time, false)); |
| 499 |
ASSERT_UINT_EQUALS(0, aws_date_time_second(&date_time, false)); |
| 500 |
|
| 501 |
uint8_t date_output[AWS_DATE_TIME_STR_MAX_LEN]; |
| 502 |
AWS_ZERO_ARRAY(date_output); |
| 503 |
struct aws_byte_buf str_output = aws_byte_buf_from_array(date_output, sizeof(date_output)); |
| 504 |
str_output.len = 0; |
| 505 |
ASSERT_SUCCESS(aws_date_time_to_utc_time_str(&date_time, AWS_DATE_FORMAT_ISO_8601_BASIC, &str_output)); |
| 506 |
|
| 507 |
const char *expected_date_str = "20021002T000000Z"; |
| 508 |
struct aws_byte_buf expected_date_buf = aws_byte_buf_from_c_str(expected_date_str); |
| 509 |
ASSERT_BIN_ARRAYS_EQUALS(expected_date_buf.buffer, expected_date_buf.len, str_output.buffer, str_output.len); |
| 510 |
|
| 511 |
return AWS_OP_SUCCESS; |
| 512 |
} |
| 513 |
|
| 514 |
AWS_TEST_CASE(iso8601_basic_date_only_parsing, s_test_iso8601_basic_date_only_parsing_fn) |
| 515 |
|
| 516 |
static int s_test_iso8601_utc_dos_prevented_fn(struct aws_allocator *allocator, void *ctx) { |
| 517 |
(void)allocator; |
| 518 |
(void)ctx; |
| 519 |
|
| 520 |
struct aws_date_time date_time; |
| 521 |
const char *date_str = "Weddkasdiweijbnawei8eriojngsdgasdgsdf1gasd8asdgfasdfgsdikweisdfksdnsdksdklas" |
| 522 |
"dfsdklasdfdfsdfsdfsdfsadfasdafsdfgjjfgghdfgsdfsfsdfsdfasdfsdfasdfsdfasdfsdf"; |
| 523 |
struct aws_byte_buf date_buf = aws_byte_buf_from_c_str(date_str); |
| 524 |
|
| 525 |
ASSERT_ERROR( |
| 526 |
AWS_ERROR_OVERFLOW_DETECTED, aws_date_time_init_from_str(&date_time, &date_buf, AWS_DATE_FORMAT_ISO_8601)); |
| 527 |
|
| 528 |
return AWS_OP_SUCCESS; |
| 529 |
} |
| 530 |
|
| 531 |
AWS_TEST_CASE(iso8601_utc_dos_prevented, s_test_iso8601_utc_dos_prevented_fn) |
| 532 |
|
| 533 |
static int s_test_iso8601_invalid_format_fn(struct aws_allocator *allocator, void *ctx) { |
| 534 |
(void)allocator; |
| 535 |
(void)ctx; |
| 536 |
|
| 537 |
struct aws_date_time date_time; |
| 538 |
const char *date_str = "2002-10-02T"; |
| 539 |
struct aws_byte_buf date_buf = aws_byte_buf_from_c_str(date_str); |
| 540 |
|
| 541 |
ASSERT_ERROR( |
| 542 |
AWS_ERROR_INVALID_DATE_STR, aws_date_time_init_from_str(&date_time, &date_buf, AWS_DATE_FORMAT_ISO_8601)); |
| 543 |
|
| 544 |
return AWS_OP_SUCCESS; |
| 545 |
} |
| 546 |
|
| 547 |
AWS_TEST_CASE(iso8601_invalid_format, s_test_iso8601_invalid_format_fn) |
| 548 |
|
| 549 |
static int s_test_iso8601_invalid_auto_format_fn(struct aws_allocator *allocator, void *ctx) { |
| 550 |
(void)allocator; |
| 551 |
(void)ctx; |
| 552 |
|
| 553 |
struct aws_date_time date_time; |
| 554 |
const char *date_str = "2002-10-02T"; |
| 555 |
struct aws_byte_buf date_buf = aws_byte_buf_from_c_str(date_str); |
| 556 |
|
| 557 |
ASSERT_ERROR( |
| 558 |
AWS_ERROR_INVALID_DATE_STR, aws_date_time_init_from_str(&date_time, &date_buf, AWS_DATE_FORMAT_AUTO_DETECT)); |
| 559 |
|
| 560 |
return AWS_OP_SUCCESS; |
| 561 |
} |
| 562 |
|
| 563 |
AWS_TEST_CASE(iso8601_invalid_auto_format, s_test_iso8601_invalid_auto_format_fn) |
| 564 |
|
| 565 |
static int s_test_unix_epoch_parsing_fn(struct aws_allocator *allocator, void *ctx) { |
| 566 |
(void)allocator; |
| 567 |
(void)ctx; |
| 568 |
|
| 569 |
struct aws_date_time date_time; |
| 570 |
|
| 571 |
|
| 572 |
aws_date_time_init_epoch_secs(&date_time, 1033545909.0); |
| 573 |
ASSERT_INT_EQUALS(AWS_DATE_DAY_OF_WEEK_WEDNESDAY, aws_date_time_day_of_week(&date_time, false)); |
| 574 |
ASSERT_UINT_EQUALS(2, aws_date_time_month_day(&date_time, false)); |
| 575 |
ASSERT_UINT_EQUALS(AWS_DATE_MONTH_OCTOBER, aws_date_time_month(&date_time, false)); |
| 576 |
ASSERT_UINT_EQUALS(2002, aws_date_time_year(&date_time, false)); |
| 577 |
ASSERT_UINT_EQUALS(8, aws_date_time_hour(&date_time, false)); |
| 578 |
ASSERT_UINT_EQUALS(5, aws_date_time_minute(&date_time, false)); |
| 579 |
ASSERT_UINT_EQUALS(9, aws_date_time_second(&date_time, false)); |
| 580 |
ASSERT_UINT_EQUALS(0U, date_time.milliseconds); |
| 581 |
|
| 582 |
|
| 583 |
aws_date_time_init_epoch_secs(&date_time, 1033545909.50542123); |
| 584 |
ASSERT_INT_EQUALS(AWS_DATE_DAY_OF_WEEK_WEDNESDAY, aws_date_time_day_of_week(&date_time, false)); |
| 585 |
ASSERT_UINT_EQUALS(2, aws_date_time_month_day(&date_time, false)); |
| 586 |
ASSERT_UINT_EQUALS(AWS_DATE_MONTH_OCTOBER, aws_date_time_month(&date_time, false)); |
| 587 |
ASSERT_UINT_EQUALS(2002, aws_date_time_year(&date_time, false)); |
| 588 |
ASSERT_UINT_EQUALS(8, aws_date_time_hour(&date_time, false)); |
| 589 |
ASSERT_UINT_EQUALS(5, aws_date_time_minute(&date_time, false)); |
| 590 |
ASSERT_UINT_EQUALS(9, aws_date_time_second(&date_time, false)); |
| 591 |
ASSERT_UINT_EQUALS(505U, date_time.milliseconds); |
| 592 |
|
| 593 |
uint8_t date_output[AWS_DATE_TIME_STR_MAX_LEN]; |
| 594 |
AWS_ZERO_ARRAY(date_output); |
| 595 |
struct aws_byte_buf str_output = aws_byte_buf_from_array(date_output, sizeof(date_output)); |
| 596 |
str_output.len = 0; |
| 597 |
ASSERT_SUCCESS(aws_date_time_to_utc_time_str(&date_time, AWS_DATE_FORMAT_ISO_8601, &str_output)); |
| 598 |
|
| 599 |
const char *expected_date_str = "2002-10-02T08:05:09Z"; |
| 600 |
struct aws_byte_buf expected_date_buf = aws_byte_buf_from_c_str(expected_date_str); |
| 601 |
ASSERT_BIN_ARRAYS_EQUALS(expected_date_buf.buffer, expected_date_buf.len, str_output.buffer, str_output.len); |
| 602 |
|
| 603 |
return AWS_OP_SUCCESS; |
| 604 |
} |
| 605 |
|
| 606 |
AWS_TEST_CASE(unix_epoch_parsing, s_test_unix_epoch_parsing_fn) |
| 607 |
|
| 608 |
static int s_test_millis_parsing_fn(struct aws_allocator *allocator, void *ctx) { |
| 609 |
(void)allocator; |
| 610 |
(void)ctx; |
| 611 |
|
| 612 |
struct aws_date_time date_time; |
| 613 |
|
| 614 |
|
| 615 |
aws_date_time_init_epoch_millis(&date_time, 1033545909000); |
| 616 |
ASSERT_INT_EQUALS(AWS_DATE_DAY_OF_WEEK_WEDNESDAY, aws_date_time_day_of_week(&date_time, false)); |
| 617 |
ASSERT_UINT_EQUALS(2, aws_date_time_month_day(&date_time, false)); |
| 618 |
ASSERT_UINT_EQUALS(AWS_DATE_MONTH_OCTOBER, aws_date_time_month(&date_time, false)); |
| 619 |
ASSERT_UINT_EQUALS(2002, aws_date_time_year(&date_time, false)); |
| 620 |
ASSERT_UINT_EQUALS(8, aws_date_time_hour(&date_time, false)); |
| 621 |
ASSERT_UINT_EQUALS(5, aws_date_time_minute(&date_time, false)); |
| 622 |
ASSERT_UINT_EQUALS(9, aws_date_time_second(&date_time, false)); |
| 623 |
ASSERT_UINT_EQUALS(0U, date_time.milliseconds); |
| 624 |
|
| 625 |
|
| 626 |
aws_date_time_init_epoch_millis(&date_time, 1033545909619); |
| 627 |
ASSERT_INT_EQUALS(AWS_DATE_DAY_OF_WEEK_WEDNESDAY, aws_date_time_day_of_week(&date_time, false)); |
| 628 |
ASSERT_UINT_EQUALS(2, aws_date_time_month_day(&date_time, false)); |
| 629 |
ASSERT_UINT_EQUALS(AWS_DATE_MONTH_OCTOBER, aws_date_time_month(&date_time, false)); |
| 630 |
ASSERT_UINT_EQUALS(2002, aws_date_time_year(&date_time, false)); |
| 631 |
ASSERT_UINT_EQUALS(8, aws_date_time_hour(&date_time, false)); |
| 632 |
ASSERT_UINT_EQUALS(5, aws_date_time_minute(&date_time, false)); |
| 633 |
ASSERT_UINT_EQUALS(9, aws_date_time_second(&date_time, false)); |
| 634 |
ASSERT_UINT_EQUALS(619U, date_time.milliseconds); |
| 635 |
|
| 636 |
uint8_t date_output[AWS_DATE_TIME_STR_MAX_LEN]; |
| 637 |
AWS_ZERO_ARRAY(date_output); |
| 638 |
struct aws_byte_buf str_output = aws_byte_buf_from_array(date_output, sizeof(date_output)); |
| 639 |
str_output.len = 0; |
| 640 |
ASSERT_SUCCESS(aws_date_time_to_utc_time_str(&date_time, AWS_DATE_FORMAT_ISO_8601, &str_output)); |
| 641 |
|
| 642 |
const char *expected_date_str = "2002-10-02T08:05:09Z"; |
| 643 |
struct aws_byte_buf expected_date_buf = aws_byte_buf_from_c_str(expected_date_str); |
| 644 |
ASSERT_BIN_ARRAYS_EQUALS(expected_date_buf.buffer, expected_date_buf.len, str_output.buffer, str_output.len); |
| 645 |
|
| 646 |
return AWS_OP_SUCCESS; |
| 647 |
} |
| 648 |
|
| 649 |
AWS_TEST_CASE(millis_parsing, s_test_millis_parsing_fn) |