Libraries

Articles in Section

  • itertools

    Itertools library

  • rand

    Random numbers library

  • serde

    Serialization / Deserialization Library

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