From d6a9e6e46f2c2574ec0665e73b64f0d6c700557a Mon Sep 17 00:00:00 2001 From: gabrielgio Date: Fri, 25 Mar 2022 23:14:04 +0100 Subject: feat: Add extended ASCII Add more chars... --- tests/web.rs | 49 ++++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 19 deletions(-) (limited to 'tests') diff --git a/tests/web.rs b/tests/web.rs index eedd1b4..b5af034 100644 --- a/tests/web.rs +++ b/tests/web.rs @@ -14,50 +14,61 @@ const ATTEMPTS: usize = 5; #[wasm_bindgen_test] fn generate_length() { for x in (0..=100).step_by(5) { - let password = generate(x, true, true, true, true); + let password = generate(x, true, true, true, true, false); assert_eq!(x, password.len()) } } #[wasm_bindgen_test] -fn generate_not_upper_letters() { - let lower_charset = "abcdefghijklmnopqrstuvwxyz"; +fn generate_no_upper_letters() { + let charset = "abcdefghijklmnopqrstuvwxyz"; for _ in 0..ATTEMPTS { - let password = generate(100, false, true, true, true); - for char in String::from(lower_charset).chars().into_iter() { + let password = generate(100, false, true, true, true, true); + for char in String::from(charset).chars().into_iter() { assert!(!password.contains(char)) } } } #[wasm_bindgen_test] -fn generate_not_lower_letters() { - let upper_charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; +fn generate_no_lower_letters() { + let charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; for x in 0..ATTEMPTS { - let password = generate(x, true, false, true, true); - for char in String::from(upper_charset).chars().into_iter() { + let password = generate(x, true, false, true, true, true); + for char in String::from(charset).chars().into_iter() { assert!(!password.contains(char)) } } } #[wasm_bindgen_test] -fn generate_not_number_letters() { - let upper_charset = "1234567890"; +fn generate_no_number_letters() { + let charset = "1234567890"; for x in 0..ATTEMPTS { - let password = generate(x, true, true, false, true); - for char in String::from(upper_charset).chars().into_iter() { + let password = generate(x, true, true, false, true, true); + for char in String::from(charset).chars().into_iter() { assert!(!password.contains(char)) } } } #[wasm_bindgen_test] -fn generate_not_special_letters() { - let upper_charset = "!@#$%^&*()+{}[]><:|+=;-.,'?_~\\/`\""; +fn generate_no_special_letters() { + let charset = "!@#$%^&*()+{}[]><:|+=;-.,'?_~\\/`\""; for x in 0..ATTEMPTS { - let password = generate(x, true, true, true, false); - for char in String::from(upper_charset).chars().into_iter() { + let password = generate(x, true, true, true, false, true); + for char in String::from(charset).chars().into_iter() { + assert!(!password.contains(char)) + } + } +} + +#[wasm_bindgen_test] +fn generate_no_extended_letters() { + let charset = "®û´¢æ«æëàñîêáö½¬èñý¹áúóâªò×ä¸ÿ¦ù°º±¨åûïøí»§÷î¤ã¡òþ¿³óùçâüëíõôéðìö¶þ¾úý·êéãߣüèðµå¥õïà¼øäô©²¯çì"; + for x in 0..ATTEMPTS { + let password = generate(x, true, true, true, true, false); + for char in String::from(charset).chars().into_iter() { assert!(!password.contains(char)) } } @@ -65,12 +76,12 @@ fn generate_not_special_letters() { #[wasm_bindgen_test] fn generate_0_len() { - let password = generate(0, true, true, true, true); + let password = generate(0, true, true, true, true, true); assert_eq!(0, password.len()) } #[wasm_bindgen_test] fn generate_no_letters() { - let password = generate(100, false, false, false, false); + let password = generate(100, false, false, false, false, true); assert_eq!(0, password.len()) } -- cgit v1.2.3