Permalink
Browse files

30DaysOfTests: check that alnum password generation is alnum

  • Loading branch information...
conradkdotcom committed Aug 24, 2017
1 parent a6f762b commit e853535e31e9bf6d9026490b54e091b6f71d340a
Showing with 15 additions and 1 deletion.
  1. +15 −1 src/generate.rs
View
@@ -95,10 +95,11 @@ pub fn check_password_len(opt: Option<usize>) -> Option<usize> {
#[cfg(test)]
mod test {
use std::ops::Deref;
use generate::PasswordSpec;
#[test]
fn default_password_size_is_32() {
fn test_default_password_size_is_32() {
assert_eq!(
PasswordSpec::new(false, None)
.generate_hard_password()
@@ -114,4 +115,17 @@ mod test {
16
);
}
#[test]
fn test_generate_password_alnum() {
// All alnum
let ps = PasswordSpec::new(true, None);
let pw = ps.generate_hard_password().unwrap();
for c in pw.deref().chars() {
match c {
'a'...'z' | 'A'...'Z' | '0'...'9' => {},
_ => panic!()
}
}
}
}

0 comments on commit e853535

Please sign in to comment.