Refactor test case

This commit is contained in:
Chris Tsang 2021-08-23 01:11:36 +08:00
parent e5f290380a
commit 4c3bc32fd8

View File

@ -353,22 +353,25 @@ mod tests {
fn test_col_from_str() { fn test_col_from_str() {
use std::str::FromStr; use std::str::FromStr;
match fruit::Column::from_str("id") { assert!(matches!(
Ok(col) => assert!(matches!(col, fruit::Column::Id)), fruit::Column::from_str("id"),
Err(_) => panic!("fruit from_str fails"), Ok(fruit::Column::Id)
} ));
match fruit::Column::from_str("name") { assert!(matches!(
Ok(col) => assert!(matches!(col, fruit::Column::Name)), fruit::Column::from_str("name"),
Err(_) => panic!("fruit from_str fails"), Ok(fruit::Column::Name)
} ));
match fruit::Column::from_str("cake_id") { assert!(matches!(
Ok(col) => assert!(matches!(col, fruit::Column::CakeId)), fruit::Column::from_str("cake_id"),
Err(_) => panic!("fruit from_str fails"), Ok(fruit::Column::CakeId)
} ));
match fruit::Column::from_str("cakeId") { assert!(matches!(
Ok(col) => assert!(matches!(col, fruit::Column::CakeId)), fruit::Column::from_str("cakeId"),
Err(_) => panic!("fruit from_str fails"), Ok(fruit::Column::CakeId)
} ));
assert!(matches!(fruit::Column::from_str("does_not_exist"), Err(_))); assert!(matches!(
fruit::Column::from_str("does_not_exist"),
Err(crate::ColumnFromStrErr(_))
));
} }
} }