Skip to content

Commit a3b26da

Browse files
committed
test: remove format_code reference in tests
1 parent d03d4b8 commit a3b26da

File tree

2 files changed

+10
-21
lines changed

2 files changed

+10
-21
lines changed

src/otp/algorithms/hotp_maker.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,16 @@ mod tests {
8686
#[test]
8787
fn test_hotp() {
8888
assert_eq!(
89-
format_code(generate_hotp::<Sha1>("BASE32SECRET3232", 0).unwrap(), 6),
90-
"260182"
91-
);
92-
assert_eq!(
93-
format_code(generate_hotp::<Sha1>("BASE32SECRET3232", 1).unwrap(), 6),
94-
"055283"
89+
455260182,
90+
generate_hotp::<Sha1>("BASE32SECRET3232", 0).unwrap()
9591
);
9692
}
9793

98-
fn format_code(value: u32, digits: u32) -> String {
99-
// Get the formatted code
100-
let s = (value % 10_u32.pow(digits)).to_string();
101-
"0".repeat(digits as usize - s.chars().count()) + s.as_str()
94+
#[test]
95+
fn test_hotp_2() {
96+
assert_eq!(
97+
1617055283,
98+
generate_hotp::<Sha1>("BASE32SECRET3232", 1).unwrap()
99+
);
102100
}
103101
}

src/otp/algorithms/totp_maker.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,8 @@ mod tests {
3030
#[test]
3131
fn test_totp() {
3232
assert_eq!(
33-
format_code(
34-
generate_totp("BASE32SECRET3232", OTPAlgorithm::Sha1, 0, 30, 0).unwrap(),
35-
6
36-
),
37-
"260182"
33+
455260182,
34+
generate_totp("BASE32SECRET3232", OTPAlgorithm::Sha1, 0, 30, 0).unwrap()
3835
);
3936
}
40-
41-
fn format_code(value: u32, digits: u32) -> String {
42-
// Get the formatted code
43-
let s = (value % 10_u32.pow(digits)).to_string();
44-
"0".repeat(digits as usize - s.chars().count()) + s.as_str()
45-
}
4637
}

0 commit comments

Comments
 (0)