mod file_setup; #[cfg(test)] mod tests { use query::BinaryQuery; use crate::file_setup; #[test] fn test_yes_no_query() { let mut file_handle = file_setup::setup_yn_answer().unwrap(); let user_query = BinaryQuery::new("This is a test query. Do you copy?", "yes", "no", &mut file_handle); assert_eq!("yes".to_string(), user_query.unwrap().answer); let user_query = BinaryQuery::new("Do you like old bread?", "yes", "no", &mut file_handle); assert_eq!("no".to_string(), user_query.unwrap().answer); } #[test] fn test_numeric_query() { let mut file_handle = file_setup::setup_numeric_answer().unwrap(); let user_query = BinaryQuery::new("What is 2 + 2?", "4", "an egg", &mut file_handle); let user_answer = user_query.unwrap().answer; assert_eq!("4".to_string(), user_answer); assert_ne!("5".to_string(), user_answer); } }