Unit tests (#[cfg(test)] mod tests)
Në shqip: Testet njësi në Rust
ShpjegimiSQ
Në Rust, testet shkruhen në të njëjtin skedar, brenda një moduli #[cfg(test)] mod tests. Çdo funksion me #[test] është një test, dhe cargo test i ekzekuton të gjitha.
EnglishEN
In Rust, tests are written in the same file, inside a #[cfg(test)] mod tests module. Every #[test] function is a test, and cargo test runs them all.
Si ta mendosh
Si fletët e kontrollit të ngjitura në fund të çdo kapitulli.
Lexoje në anglisht
Like check sheets stapled to the end of each chapter.
Shembull kodirust
#[cfg(test)]
mod tests {
use super::*;
#[test] fn mbledhja() { assert_eq!(mblidh(2, 3), 5); }
}