diff options
author | Ryan Geary <rtgnj42@gmail.com> | 2019-09-15 21:38:47 -0400 |
---|---|---|
committer | Ryan Geary <rtgnj42@gmail.com> | 2019-09-17 23:40:35 -0400 |
commit | 5703ed02a134ca131cdf212d74431c41bfbddfb6 (patch) | |
tree | cb9a063b16dd7ca304372e11f412541afcb731cf | |
parent | 55ac2acc8e07c6374bedb959fc9857403da91340 (diff) |
Move parse_choice tests into their own test module
-rw-r--r-- | src/choice.rs | 140 |
1 files changed, 73 insertions, 67 deletions
diff --git a/src/choice.rs b/src/choice.rs index 7dbd84a..7cf0980 100644 --- a/src/choice.rs +++ b/src/choice.rs @@ -2,77 +2,83 @@ mod tests { use super::*; - #[test] - fn parse_single_choice() { - let result = Choice::parse_choice("6").unwrap(); - assert_eq!( - 6, - match result { - Choice::Field(x) => x, - _ => panic!(), - } - ) - } - - #[test] - fn parse_none_started_range() { - let result = Choice::parse_choice(":5").unwrap(); - assert_eq!( - (None, Some(5)), - match result { - Choice::FieldRange(x) => x, - _ => panic!(), - } - ) - } - - #[test] - fn parse_none_terminated_range() { - let result = Choice::parse_choice("5:").unwrap(); - assert_eq!( - (Some(5), None), - match result { - Choice::FieldRange(x) => x, - _ => panic!(), - } - ) - } + mod parse_choice_tests { + use super::*; + + #[test] + fn parse_single_choice() { + let result = Choice::parse_choice("6").unwrap(); + assert_eq!( + 6, + match result { + Choice::Field(x) => x, + _ => panic!(), + } + ) + } + + #[test] + fn parse_none_started_range() { + let result = Choice::parse_choice(":5").unwrap(); + assert_eq!( + (None, Some(5)), + match result { + Choice::FieldRange(x) => x, + _ => panic!(), + } + ) + } + + #[test] + fn parse_none_terminated_range() { + let result = Choice::parse_choice("5:").unwrap(); + assert_eq!( + (Some(5), None), + match result { + Choice::FieldRange(x) => x, + _ => panic!(), + } + ) + } + + #[test] + fn parse_full_range() { + let result = Choice::parse_choice("5:7").unwrap(); + assert_eq!( + (Some(5), Some(7)), + match result { + Choice::FieldRange(x) => x, + _ => panic!(), + } + ) + } + + #[test] + fn parse_beginning_to_end_range() { + let result = Choice::parse_choice(":").unwrap(); + assert_eq!( + (None, None), + match result { + Choice::FieldRange(x) => x, + _ => panic!(), + } + ) + } - #[test] - fn parse_full_range() { - let result = Choice::parse_choice("5:7").unwrap(); - assert_eq!( - (Some(5), Some(7)), - match result { - Choice::FieldRange(x) => x, - _ => panic!(), - } - ) + // These tests should pass once parse_choice return errors properly, but until that time makes + // running other tests impossible. + //#[test] + //fn parse_bad_choice() { + //assert!(Choice::parse_choice("d").is_err()); + //} + // + //#[test] + //fn parse_bad_range() { + //assert!(Choice::parse_choice("d:i").is_err()); + //} } - #[test] - fn parse_beginning_to_end_range() { - let result = Choice::parse_choice(":").unwrap(); - assert_eq!( - (None, None), - match result { - Choice::FieldRange(x) => x, - _ => panic!(), - } - ) - } - // These tests should pass once parse_choice return errors properly, but until that time makes - // running other tests impossible. - //#[test] - //fn parse_bad_choice() { - //assert!(Choice::parse_choice("d").is_err()); - //} - // - //#[test] - //fn parse_bad_range() { - //assert!(Choice::parse_choice("d:i").is_err()); - //} } |