From b00842a60e85825814b4f1e48e0f222024ae9519 Mon Sep 17 00:00:00 2001 From: iximeow Date: Sun, 26 Nov 2017 22:06:02 -0800 Subject: wrap lines intelligently with respect to ANSI sequences --- src/tw/mod.rs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src/tw/mod.rs') diff --git a/src/tw/mod.rs b/src/tw/mod.rs index ee3b73e..629a6c7 100644 --- a/src/tw/mod.rs +++ b/src/tw/mod.rs @@ -178,17 +178,19 @@ mod tests { use super::*; #[test] fn tweet_id_parse_test() { - assert_eq!(TweetId::parse("12345".to_string()), Some(TweetId::Today(12345))); - assert_eq!(TweetId::parse("20170403:12345".to_string()), Some(TweetId::Dated("20170403".to_string(), 12345))); - assert_eq!(TweetId::parse(":12345".to_string()), Some(TweetId::Bare(12345))); - assert_eq!(TweetId::parse("twitter:12345".to_string()), Some(TweetId::Twitter("12345".to_string()))); - assert_eq!(TweetId::parse("twitter:asdf".to_string()), Some(TweetId::Twitter("asdf".to_string()))); - assert_eq!(TweetId::parse("a2345".to_string()), None); - assert_eq!(TweetId::parse(":".to_string()), None); - assert_eq!(TweetId::parse("::".to_string()), None); - assert_eq!(TweetId::parse("a:13234".to_string()), None); - assert_eq!(TweetId::parse(":a34".to_string()), None); - assert_eq!(TweetId::parse("asdf:34".to_string()), None); + assert_eq!(TweetId::parse("12345".to_string()), Ok(TweetId::Today(12345))); + assert_eq!(TweetId::parse("20170403:12345".to_string()), Ok(TweetId::Dated("20170403".to_string(), 12345))); + assert_eq!(TweetId::parse(":12345".to_string()), Ok(TweetId::Bare(12345))); + assert_eq!(TweetId::parse("twitter:12345".to_string()), Ok(TweetId::Twitter("12345".to_string()))); + assert_eq!(TweetId::parse("twitter:asdf".to_string()), Ok(TweetId::Twitter("asdf".to_string()))); + assert_eq!(TweetId::parse("a2345".to_string()), Err("Unrecognized id string: a2345".to_owned())); + // TODO: clarify + assert_eq!(TweetId::parse(":".to_string()), Err("cannot parse integer from empty string".to_owned())); + // TODO: clarify + assert_eq!(TweetId::parse("::".to_string()), Err("invalid digit found in string".to_owned())); + assert_eq!(TweetId::parse("a:13234".to_string()), Err("Unrecognized id string: a:13234".to_owned())); + assert_eq!(TweetId::parse(":a34".to_string()), Err("invalid digit found in string".to_owned())); + assert_eq!(TweetId::parse("asdf:34".to_string()), Err("Unrecognized id string: asdf:34".to_owned())); } } -- cgit v1.1