Added unit tests to the app module

This commit is contained in:
2023-08-08 10:50:05 -06:00
parent 0f9dc639a8
commit 3af3eddf71
6 changed files with 800 additions and 27 deletions
+29
View File
@@ -40,3 +40,32 @@ pub fn strip_non_alphanumeric_characters(input: &str) -> String {
.replace_all(&input.to_lowercase(), "")
.to_string()
}
#[cfg(test)]
mod tests {
use pretty_assertions::assert_eq;
use crate::utils::{convert_runtime, convert_to_gb, strip_non_alphanumeric_characters};
#[test]
fn test_convert_to_gb() {
assert_eq!(convert_to_gb(2147483648), 2f64);
assert_eq!(convert_to_gb(2662879723), 2.4799999995157123);
}
#[test]
fn test_convert_runtime() {
let (hours, minutes) = convert_runtime(154);
assert_eq!(hours, 2);
assert_eq!(minutes, 34);
}
#[test]
fn test_strop_non_alphanumeric_characters() {
assert_eq!(
strip_non_alphanumeric_characters("Te$t S7r!ng::'~-_}"),
String::from("tet s7rng")
)
}
}