extern crate fastobo_syntax; use fastobo_syntax::OboLexer; use fastobo_syntax::Rule; macro_rules! test_parse { ($rule:ident, $input:literal) => {{ match OboLexer::tokenize(Rule::$rule, $input) { Ok(mut pairs) => assert_eq!(pairs.next().unwrap().as_str(), $input), Err(e) => panic!("could not parse {:?}:\n{}", $input, e), } }}; } #[test] fn iso_datetime_utc() { test_parse!(ISO8601_DateTime, "2018-09-05T09:48:03Z"); test_parse!(ISO8601_DateTime, "2018-09-05T09:48:03.106Z"); } #[test] fn iso_datetime_offset() { test_parse!(ISO8601_DateTime, "2018-09-05T09:48:03+01:00"); test_parse!(ISO8601_DateTime, "2018-09-05T09:48:03-03:30"); test_parse!(ISO8601_DateTime, "2018-09-05T09:48:03−03:30"); } #[test] fn iso_datetime_compact() { test_parse!(ISO8601_DateTime, "20180905T094803Z"); } #[test] fn creation_date_datetime() { test_parse!(TypedefClause, "creation_date: 2018-09-05T09:48:03Z"); test_parse!( TermFrame, "[Term]\nid: TST:001\n creation_date: 2015-08-11T15:05:12Z\n" ); } #[test] fn creation_date_date() { test_parse!(TypedefClause, "creation_date: 2018-09-05"); test_parse!( TermFrame, "[Term]\nid: TST:001\n creation_date: 2015-08-11\n" ); }