Skip to content

Commit

Permalink
test: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sdanialraza committed Mar 1, 2024
1 parent 65901ce commit 2a76bb7
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl RandomPassword {

#[cfg(test)]
mod tests {
use super::{PasswordGeneratorOptions, RandomPassword};
use crate::types::{PasswordGeneratorOptions, RandomPassword};

#[test]
fn it_generates_lowercase_only_password() {
Expand All @@ -85,7 +85,7 @@ mod tests {
include_uppercase: false,
include_numbers: false,
include_special_characters: false,
length: 10,
..Default::default()
};

let random_password = RandomPassword::new(options);
Expand All @@ -102,7 +102,7 @@ mod tests {
include_uppercase: true,
include_numbers: false,
include_special_characters: false,
length: 10,
..Default::default()
};

let random_password = RandomPassword::new(options);
Expand All @@ -119,7 +119,7 @@ mod tests {
include_uppercase: false,
include_numbers: true,
include_special_characters: false,
length: 10,
..Default::default()
};

let random_password = RandomPassword::new(options);
Expand All @@ -136,7 +136,7 @@ mod tests {
include_uppercase: false,
include_numbers: false,
include_special_characters: true,
length: 10,
..Default::default()
};

let random_password = RandomPassword::new(options);
Expand All @@ -148,22 +148,20 @@ mod tests {

#[test]
fn it_generates_lower_upper_numbers_special_characters_password() {
let options = PasswordGeneratorOptions::default();

let random_password = RandomPassword::new(options);
let random_password = RandomPassword::default();

for character in random_password.password.chars() {
assert!(character.is_ascii_alphanumeric() || character.is_ascii_punctuation());
}

assert_eq!(random_password.password.len(), 10);
assert_eq!(random_password.password.len(), 16);
}

#[test]
fn it_generates_random_password_with_length() {
let options = PasswordGeneratorOptions {
length: 30,
..PasswordGeneratorOptions::default()
..Default::default()
};

let random_password = RandomPassword::new(options);
Expand Down

0 comments on commit 2a76bb7

Please sign in to comment.