Add unit test to validate recipe keys

This commit is contained in:
James Melkonian 2022-10-09 20:49:37 -07:00
parent 160cbbf449
commit 99d547c7c6
2 changed files with 263 additions and 250 deletions

File diff suppressed because it is too large Load Diff

View File

@ -404,6 +404,19 @@ impl RecipeBook {
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn default_recipe_valid_key_check() {
let recipe_book = default_recipe_book().read();
let is_invalid_key =
|input: &str| input.chars().any(|c| c.is_uppercase() || c.is_whitespace());
assert!(!recipe_book.iter().any(|(k, _)| is_invalid_key(k)));
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub enum RawRecipeInput {
Item(String),