From 1639ce2d4dbbf7440f1366b263b95a775db5ac90 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 6 Apr 2016 15:03:25 -0400 Subject: test.rs: Split `build_alias` test into 5 separate tests Instead of putting all our asserts in a single test function, make a function for each assert. This allows us to give our test functions more specific names based on what exactly we're testing, and produces better output from `cargo test`. Also, if one of those fails for whatever reason, it's nice to know it will do so with a meaningful name. --- src/tests.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/tests.rs b/src/tests.rs index f5fb57f..2e43d35 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -1,27 +1,39 @@ use super::build_alias; #[test] -fn test_build_alias() { +fn build_alias_with_only_email() { assert_eq!( "alias producer@765pro.ductions producer@765pro.ductions", build_alias("From: producer@765pro.ductions") ); +} +#[test] +fn build_alias_with_1_name() { assert_eq!( "alias decim Decim ", build_alias("From: Decim ") ); +} +#[test] +fn build_alias_with_2_names() { assert_eq!( "alias farnsworth-hubert Hubert Farnsworth ", build_alias("From: Hubert Farnsworth ") ); +} +#[test] +fn build_alias_with_3_names() { assert_eq!( "alias lab-harvard Harvard Innovation Lab ", build_alias("From: Harvard Innovation Lab ") ); +} +#[test] +fn build_alias_with_special_characters() { assert_eq!( "alias celty-ostrulson \"O'Strulson, Celty\" ", build_alias("From: \"O'Strulson, Celty\" ") -- cgit v1.2.3