Added unit tests to the app module
This commit is contained in:
@@ -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")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user