diff --git a/src/format/parse.rs b/src/format/parse.rs index 69cb9a27df..37776017e3 100644 --- a/src/format/parse.rs +++ b/src/format/parse.rs @@ -899,15 +899,15 @@ mod tests { check!("+12:34:5", [fix!(TimezoneOffset)]; TOO_LONG); check!("+12:34:56", [fix!(TimezoneOffset)]; TOO_LONG); check!("+12:34:56:", [fix!(TimezoneOffset)]; TOO_LONG); - check!("+12 34", [fix!(TimezoneOffset)]; offset: 45_240); - check!("+12 34", [fix!(TimezoneOffset)]; offset: 45_240); + check!("+12 34", [fix!(TimezoneOffset)]; INVALID); + check!("+12 34", [fix!(TimezoneOffset)]; INVALID); check!("12:34", [fix!(TimezoneOffset)]; INVALID); check!("12:34:56", [fix!(TimezoneOffset)]; INVALID); - check!("+12::34", [fix!(TimezoneOffset)]; offset: 45_240); - check!("+12: :34", [fix!(TimezoneOffset)]; offset: 45_240); - check!("+12:::34", [fix!(TimezoneOffset)]; offset: 45_240); - check!("+12::::34", [fix!(TimezoneOffset)]; offset: 45_240); - check!("+12::34", [fix!(TimezoneOffset)]; offset: 45_240); + check!("+12::34", [fix!(TimezoneOffset)]; INVALID); + check!("+12: :34", [fix!(TimezoneOffset)]; INVALID); + check!("+12:::34", [fix!(TimezoneOffset)]; INVALID); + check!("+12::::34", [fix!(TimezoneOffset)]; INVALID); + check!("+12::34", [fix!(TimezoneOffset)]; INVALID); check!("+12:34:56", [fix!(TimezoneOffset)]; TOO_LONG); check!("+12:3456", [fix!(TimezoneOffset)]; TOO_LONG); check!("+1234:56", [fix!(TimezoneOffset)]; TOO_LONG); @@ -928,7 +928,7 @@ mod tests { check!("+00:99", [fix!(TimezoneOffset)]; OUT_OF_RANGE); check!("#12:34", [fix!(TimezoneOffset)]; INVALID); check!("+12:34 ", [fix!(TimezoneOffset)]; TOO_LONG); - check!("+12 34 ", [fix!(TimezoneOffset)]; TOO_LONG); + check!("+12 34 ", [fix!(TimezoneOffset)]; INVALID); check!(" +12:34", [fix!(TimezoneOffset)]; offset: 45_240); check!(" -12:34", [fix!(TimezoneOffset)]; offset: -45_240); check!(" −12:34", [fix!(TimezoneOffset)]; offset: -45_240); // MINUS SIGN (U+2212) @@ -936,14 +936,14 @@ mod tests { check!(" +12:34", [fix!(TimezoneOffset)]; offset: 45_240); check!(" -12:34", [fix!(TimezoneOffset)]; offset: -45_240); check!("\t -12:34", [fix!(TimezoneOffset)]; offset: -45_240); - check!("-12: 34", [fix!(TimezoneOffset)]; offset: -45_240); - check!("-12 :34", [fix!(TimezoneOffset)]; offset: -45_240); - check!("-12 : 34", [fix!(TimezoneOffset)]; offset: -45_240); - check!("-12 : 34", [fix!(TimezoneOffset)]; offset: -45_240); - check!("-12 : 34", [fix!(TimezoneOffset)]; offset: -45_240); - check!("-12: 34", [fix!(TimezoneOffset)]; offset: -45_240); - check!("-12 :34", [fix!(TimezoneOffset)]; offset: -45_240); - check!("-12 : 34", [fix!(TimezoneOffset)]; offset: -45_240); + check!("-12: 34", [fix!(TimezoneOffset)]; INVALID); + check!("-12 :34", [fix!(TimezoneOffset)]; INVALID); + check!("-12 : 34", [fix!(TimezoneOffset)]; INVALID); + check!("-12 : 34", [fix!(TimezoneOffset)]; INVALID); + check!("-12 : 34", [fix!(TimezoneOffset)]; INVALID); + check!("-12: 34", [fix!(TimezoneOffset)]; INVALID); + check!("-12 :34", [fix!(TimezoneOffset)]; INVALID); + check!("-12 : 34", [fix!(TimezoneOffset)]; INVALID); check!(" 12:34", [fix!(TimezoneOffset)]; INVALID); check!("", [fix!(TimezoneOffset)]; TOO_SHORT); check!("+", [fix!(TimezoneOffset)]; TOO_SHORT); @@ -989,14 +989,14 @@ mod tests { check!("12345678", [fix!(TimezoneOffsetColon)]; INVALID); check!("+1", [fix!(TimezoneOffsetColon)]; TOO_SHORT); check!("+12", [fix!(TimezoneOffsetColon)]; TOO_SHORT); - check!("+123", [fix!(TimezoneOffsetColon)]; TOO_SHORT); - check!("+1234", [fix!(TimezoneOffsetColon)]; offset: 45_240); - check!("-1234", [fix!(TimezoneOffsetColon)]; offset: -45_240); - check!("−1234", [fix!(TimezoneOffsetColon)]; offset: -45_240); // MINUS SIGN (U+2212) - check!("+12345", [fix!(TimezoneOffsetColon)]; TOO_LONG); - check!("+123456", [fix!(TimezoneOffsetColon)]; TOO_LONG); - check!("+1234567", [fix!(TimezoneOffsetColon)]; TOO_LONG); - check!("+12345678", [fix!(TimezoneOffsetColon)]; TOO_LONG); + check!("+123", [fix!(TimezoneOffsetColon)]; INVALID); + check!("+1234", [fix!(TimezoneOffsetColon)]; INVALID); + check!("-1234", [fix!(TimezoneOffsetColon)]; INVALID); + check!("−1234", [fix!(TimezoneOffsetColon)]; INVALID); // MINUS SIGN (U+2212) + check!("+12345", [fix!(TimezoneOffsetColon)]; INVALID); + check!("+123456", [fix!(TimezoneOffsetColon)]; INVALID); + check!("+1234567", [fix!(TimezoneOffsetColon)]; INVALID); + check!("+12345678", [fix!(TimezoneOffsetColon)]; INVALID); check!("1:", [fix!(TimezoneOffsetColon)]; INVALID); check!("12:", [fix!(TimezoneOffsetColon)]; INVALID); check!("12:3", [fix!(TimezoneOffsetColon)]; INVALID); @@ -1017,24 +1017,24 @@ mod tests { check!("+12:34:56:7", [fix!(TimezoneOffsetColon)]; TOO_LONG); check!("+12:34:56:78", [fix!(TimezoneOffsetColon)]; TOO_LONG); check!("+12:3456", [fix!(TimezoneOffsetColon)]; TOO_LONG); - check!("+1234:56", [fix!(TimezoneOffsetColon)]; TOO_LONG); + check!("+1234:56", [fix!(TimezoneOffsetColon)]; INVALID); check!("−12:34", [fix!(TimezoneOffsetColon)]; offset: -45_240); // MINUS SIGN (U+2212) - check!("−12 : 34", [fix!(TimezoneOffsetColon)]; offset: -45_240); // MINUS SIGN (U+2212) - check!("+12 :34", [fix!(TimezoneOffsetColon)]; offset: 45_240); - check!("+12: 34", [fix!(TimezoneOffsetColon)]; offset: 45_240); - check!("+12 34", [fix!(TimezoneOffsetColon)]; offset: 45_240); - check!("+12: 34", [fix!(TimezoneOffsetColon)]; offset: 45_240); - check!("+12 :34", [fix!(TimezoneOffsetColon)]; offset: 45_240); - check!("+12 : 34", [fix!(TimezoneOffsetColon)]; offset: 45_240); - check!("-12 : 34", [fix!(TimezoneOffsetColon)]; offset: -45_240); - check!("+12 : 34", [fix!(TimezoneOffsetColon)]; offset: 45_240); - check!("+12 : 34", [fix!(TimezoneOffsetColon)]; offset: 45_240); - check!("+12 : 34", [fix!(TimezoneOffsetColon)]; offset: 45_240); - check!("+12::34", [fix!(TimezoneOffsetColon)]; offset: 45_240); - check!("+12: :34", [fix!(TimezoneOffsetColon)]; offset: 45_240); - check!("+12:::34", [fix!(TimezoneOffsetColon)]; offset: 45_240); - check!("+12::::34", [fix!(TimezoneOffsetColon)]; offset: 45_240); - check!("+12::34", [fix!(TimezoneOffsetColon)]; offset: 45_240); + check!("−12 : 34", [fix!(TimezoneOffsetColon)]; INVALID); // MINUS SIGN (U+2212) + check!("+12 :34", [fix!(TimezoneOffsetColon)]; INVALID); + check!("+12: 34", [fix!(TimezoneOffsetColon)]; INVALID); + check!("+12 34", [fix!(TimezoneOffsetColon)]; INVALID); + check!("+12: 34", [fix!(TimezoneOffsetColon)]; INVALID); + check!("+12 :34", [fix!(TimezoneOffsetColon)]; INVALID); + check!("+12 : 34", [fix!(TimezoneOffsetColon)]; INVALID); + check!("-12 : 34", [fix!(TimezoneOffsetColon)]; INVALID); + check!("+12 : 34", [fix!(TimezoneOffsetColon)]; INVALID); + check!("+12 : 34", [fix!(TimezoneOffsetColon)]; INVALID); + check!("+12 : 34", [fix!(TimezoneOffsetColon)]; INVALID); + check!("+12::34", [fix!(TimezoneOffsetColon)]; INVALID); + check!("+12: :34", [fix!(TimezoneOffsetColon)]; INVALID); + check!("+12:::34", [fix!(TimezoneOffsetColon)]; INVALID); + check!("+12::::34", [fix!(TimezoneOffsetColon)]; INVALID); + check!("+12::34", [fix!(TimezoneOffsetColon)]; INVALID); check!("#1234", [fix!(TimezoneOffsetColon)]; INVALID); check!("#12:34", [fix!(TimezoneOffsetColon)]; INVALID); check!("+12:34 ", [fix!(TimezoneOffsetColon)]; TOO_LONG); @@ -1046,7 +1046,7 @@ mod tests { check!("", [fix!(TimezoneOffsetColon)]; TOO_SHORT); check!("+", [fix!(TimezoneOffsetColon)]; TOO_SHORT); check!(":", [fix!(TimezoneOffsetColon)]; INVALID); - check!("+12345", [fix!(TimezoneOffsetColon), num!(Day)]; offset: 45_240, day: 5); + check!("+12345", [fix!(TimezoneOffsetColon), num!(Day)]; INVALID); check!("+12:345", [fix!(TimezoneOffsetColon), num!(Day)]; offset: 45_240, day: 5); check!("+12:34:", [fix!(TimezoneOffsetColon), lit!(":")]; offset: 45_240); check!("Z", [fix!(TimezoneOffsetColon)]; INVALID); @@ -1104,21 +1104,21 @@ mod tests { check!("+12:34:56:", [fix!(TimezoneOffsetZ)]; TOO_LONG); check!("+12:34:56:7", [fix!(TimezoneOffsetZ)]; TOO_LONG); check!("+12:34:56:78", [fix!(TimezoneOffsetZ)]; TOO_LONG); - check!("+12::34", [fix!(TimezoneOffsetZ)]; offset: 45_240); + check!("+12::34", [fix!(TimezoneOffsetZ)]; INVALID); check!("+12:3456", [fix!(TimezoneOffsetZ)]; TOO_LONG); check!("+1234:56", [fix!(TimezoneOffsetZ)]; TOO_LONG); - check!("+12 34", [fix!(TimezoneOffsetZ)]; offset: 45_240); - check!("+12 34", [fix!(TimezoneOffsetZ)]; offset: 45_240); - check!("+12: 34", [fix!(TimezoneOffsetZ)]; offset: 45_240); - check!("+12 :34", [fix!(TimezoneOffsetZ)]; offset: 45_240); - check!("+12 : 34", [fix!(TimezoneOffsetZ)]; offset: 45_240); - check!("+12 : 34", [fix!(TimezoneOffsetZ)]; offset: 45_240); - check!("+12 : 34", [fix!(TimezoneOffsetZ)]; offset: 45_240); - check!("+12 : 34", [fix!(TimezoneOffsetZ)]; offset: 45_240); + check!("+12 34", [fix!(TimezoneOffsetZ)]; INVALID); + check!("+12 34", [fix!(TimezoneOffsetZ)]; INVALID); + check!("+12: 34", [fix!(TimezoneOffsetZ)]; INVALID); + check!("+12 :34", [fix!(TimezoneOffsetZ)]; INVALID); + check!("+12 : 34", [fix!(TimezoneOffsetZ)]; INVALID); + check!("+12 : 34", [fix!(TimezoneOffsetZ)]; INVALID); + check!("+12 : 34", [fix!(TimezoneOffsetZ)]; INVALID); + check!("+12 : 34", [fix!(TimezoneOffsetZ)]; INVALID); check!("12:34 ", [fix!(TimezoneOffsetZ)]; INVALID); check!(" 12:34", [fix!(TimezoneOffsetZ)]; INVALID); check!("+12:34 ", [fix!(TimezoneOffsetZ)]; TOO_LONG); - check!("+12 34 ", [fix!(TimezoneOffsetZ)]; TOO_LONG); + check!("+12 34 ", [fix!(TimezoneOffsetZ)]; INVALID); check!(" +12:34", [fix!(TimezoneOffsetZ)]; offset: 45_240); check!("+12345", [fix!(TimezoneOffsetZ), num!(Day)]; offset: 45_240, day: 5); check!("+12:345", [fix!(TimezoneOffsetZ), num!(Day)]; offset: 45_240, day: 5); @@ -1165,7 +1165,7 @@ mod tests { check!("12345678", [internal_fix!(TimezoneOffsetPermissive)]; INVALID); check!("+1", [internal_fix!(TimezoneOffsetPermissive)]; TOO_SHORT); check!("+12", [internal_fix!(TimezoneOffsetPermissive)]; offset: 43_200); - check!("+123", [internal_fix!(TimezoneOffsetPermissive)]; TOO_SHORT); + check!("+123", [internal_fix!(TimezoneOffsetPermissive)]; TOO_LONG); check!("+1234", [internal_fix!(TimezoneOffsetPermissive)]; offset: 45_240); check!("-1234", [internal_fix!(TimezoneOffsetPermissive)]; offset: -45_240); check!("−1234", [internal_fix!(TimezoneOffsetPermissive)]; offset: -45_240); // MINUS SIGN (U+2212) @@ -1181,8 +1181,8 @@ mod tests { check!("12:34:5", [internal_fix!(TimezoneOffsetPermissive)]; INVALID); check!("12:34:56", [internal_fix!(TimezoneOffsetPermissive)]; INVALID); check!("+1:", [internal_fix!(TimezoneOffsetPermissive)]; INVALID); - check!("+12:", [internal_fix!(TimezoneOffsetPermissive)]; offset: 43_200); - check!("+12:3", [internal_fix!(TimezoneOffsetPermissive)]; TOO_SHORT); + check!("+12:", [internal_fix!(TimezoneOffsetPermissive)]; TOO_LONG); + check!("+12:3", [internal_fix!(TimezoneOffsetPermissive)]; TOO_LONG); check!("+12:34", [internal_fix!(TimezoneOffsetPermissive)]; offset: 45_240); check!("-12:34", [internal_fix!(TimezoneOffsetPermissive)]; offset: -45_240); check!("−12:34", [internal_fix!(TimezoneOffsetPermissive)]; offset: -45_240); // MINUS SIGN (U+2212) @@ -1192,23 +1192,23 @@ mod tests { check!("+12:34:56:", [internal_fix!(TimezoneOffsetPermissive)]; TOO_LONG); check!("+12:34:56:7", [internal_fix!(TimezoneOffsetPermissive)]; TOO_LONG); check!("+12:34:56:78", [internal_fix!(TimezoneOffsetPermissive)]; TOO_LONG); - check!("+12 34", [internal_fix!(TimezoneOffsetPermissive)]; offset: 45_240); - check!("+12 34", [internal_fix!(TimezoneOffsetPermissive)]; offset: 45_240); - check!("+12 :34", [internal_fix!(TimezoneOffsetPermissive)]; offset: 45_240); - check!("+12: 34", [internal_fix!(TimezoneOffsetPermissive)]; offset: 45_240); - check!("+12 : 34", [internal_fix!(TimezoneOffsetPermissive)]; offset: 45_240); - check!("+12 :34", [internal_fix!(TimezoneOffsetPermissive)]; offset: 45_240); - check!("+12: 34", [internal_fix!(TimezoneOffsetPermissive)]; offset: 45_240); - check!("+12 : 34", [internal_fix!(TimezoneOffsetPermissive)]; offset: 45_240); - check!("+12::34", [internal_fix!(TimezoneOffsetPermissive)]; offset: 45_240); - check!("+12 ::34", [internal_fix!(TimezoneOffsetPermissive)]; offset: 45_240); - check!("+12: :34", [internal_fix!(TimezoneOffsetPermissive)]; offset: 45_240); - check!("+12:: 34", [internal_fix!(TimezoneOffsetPermissive)]; offset: 45_240); - check!("+12 ::34", [internal_fix!(TimezoneOffsetPermissive)]; offset: 45_240); - check!("+12: :34", [internal_fix!(TimezoneOffsetPermissive)]; offset: 45_240); - check!("+12:: 34", [internal_fix!(TimezoneOffsetPermissive)]; offset: 45_240); - check!("+12:::34", [internal_fix!(TimezoneOffsetPermissive)]; offset: 45_240); - check!("+12::::34", [internal_fix!(TimezoneOffsetPermissive)]; offset: 45_240); + check!("+12 34", [internal_fix!(TimezoneOffsetPermissive)]; TOO_LONG); + check!("+12 34", [internal_fix!(TimezoneOffsetPermissive)]; TOO_LONG); + check!("+12 :34", [internal_fix!(TimezoneOffsetPermissive)]; TOO_LONG); + check!("+12: 34", [internal_fix!(TimezoneOffsetPermissive)]; TOO_LONG); + check!("+12 : 34", [internal_fix!(TimezoneOffsetPermissive)]; TOO_LONG); + check!("+12 :34", [internal_fix!(TimezoneOffsetPermissive)]; TOO_LONG); + check!("+12: 34", [internal_fix!(TimezoneOffsetPermissive)]; TOO_LONG); + check!("+12 : 34", [internal_fix!(TimezoneOffsetPermissive)]; TOO_LONG); + check!("+12::34", [internal_fix!(TimezoneOffsetPermissive)]; TOO_LONG); + check!("+12 ::34", [internal_fix!(TimezoneOffsetPermissive)]; TOO_LONG); + check!("+12: :34", [internal_fix!(TimezoneOffsetPermissive)]; TOO_LONG); + check!("+12:: 34", [internal_fix!(TimezoneOffsetPermissive)]; TOO_LONG); + check!("+12 ::34", [internal_fix!(TimezoneOffsetPermissive)]; TOO_LONG); + check!("+12: :34", [internal_fix!(TimezoneOffsetPermissive)]; TOO_LONG); + check!("+12:: 34", [internal_fix!(TimezoneOffsetPermissive)]; TOO_LONG); + check!("+12:::34", [internal_fix!(TimezoneOffsetPermissive)]; TOO_LONG); + check!("+12::::34", [internal_fix!(TimezoneOffsetPermissive)]; TOO_LONG); check!("12:34 ", [internal_fix!(TimezoneOffsetPermissive)]; INVALID); check!(" 12:34", [internal_fix!(TimezoneOffsetPermissive)]; INVALID); check!("+12:34 ", [internal_fix!(TimezoneOffsetPermissive)]; TOO_LONG); @@ -1220,7 +1220,7 @@ mod tests { check!("+12:34:", [internal_fix!(TimezoneOffsetPermissive), lit!(":")]; offset: 45_240); check!("🤠+12:34", [internal_fix!(TimezoneOffsetPermissive)]; INVALID); check!("+12:34🤠", [internal_fix!(TimezoneOffsetPermissive)]; TOO_LONG); - check!("+12:🤠34", [internal_fix!(TimezoneOffsetPermissive)]; INVALID); + check!("+12:🤠34", [internal_fix!(TimezoneOffsetPermissive)]; TOO_LONG); check!("+12:34🤠", [internal_fix!(TimezoneOffsetPermissive), lit!("🤠")]; offset: 45_240); check!("🤠+12:34", [lit!("🤠"), internal_fix!(TimezoneOffsetPermissive)]; offset: 45_240); check!("Z", [internal_fix!(TimezoneOffsetPermissive)]; offset: 0); @@ -1362,8 +1362,8 @@ mod tests { ("Tue, 20 Jan 2015 17:35:20Z", Err(INVALID)), // bad offset: zulu not allowed ("Tue, 20 Jan 2015 17:35:20 Zulu", Err(NOT_ENOUGH)), // bad offset: zulu not allowed ("Tue, 20 Jan 2015 17:35:20 ZULU", Err(NOT_ENOUGH)), // bad offset: zulu not allowed - ("Tue, 20 Jan 2015 17:35:20 −0800", Err(INVALID)), // bad offset: timezone offset using MINUS SIGN (U+2212), not specified for RFC 2822 - ("Tue, 20 Jan 2015 17:35:20 0800", Err(INVALID)), // missing offset sign + ("Tue, 20 Jan 2015 17:35:20 −0800", Ok("Tue, 20 Jan 2015 17:35:20 -0800")), // timezone offset using MINUS SIGN (U+2212) + ("Tue, 20 Jan 2015 17:35:20 0800", Err(INVALID)), // missing offset sign ("Tue, 20 Jan 2015 17:35:20 HAS", Err(NOT_ENOUGH)), // bad named timezone ("Tue, 20 Jan 2015😈17:35:20 -0800", Err(INVALID)), // bad character! ];