Libraries
Articles in Section
Library Unit-tests
ΠΡΠΈΠΌΠ΅ΡΡ:
pub fn greet_user(name: &str) -> String {
format!("Hello {name}")
}
pub fn login(username: &str, password: &str) -> bool {
username == "admin" && password == "P@ssw0rd"
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_greet_user() {
assert_eq!("Hello Alex", greet_user("Alex"));
}
#[test]
fn test_login() {
assert!(login("admin", "P@ssw0rd"));
}
}
ΠΠ°ΠΏΡΡΠΊ ΡΠ΅ΡΡΠΎΠ² - ΠΊΠΎΠΌΠ°Π½Π΄ΠΎΠΉ cargo test