```rust,ignore
#[test]
fn my_test() {
- assert!(2+2 == 4);
+ assert!(2+2 == 4);
}
```
```rust,ignore
mod my_priv_mod {
- fn my_priv_func() -> bool {}
+ fn my_priv_func() -> bool {}
- #[test]
- fn test_priv_func() {
- assert!(my_priv_func());
- }
+ #[test]
+ fn test_priv_func() {
+ assert!(my_priv_func());
+ }
}
```
+
Private items can thus be easily tested without worrying about how to expose
them to any sort of external testing apparatus. This is key to the
ergonomics of testing in Rust. Semantically, however, it's rather odd.
```rust,ignore
mod my_priv_mod {
- fn my_priv_func() -> bool {}
+ fn my_priv_func() -> bool {}
- pub fn test_priv_func() {
- assert!(my_priv_func());
- }
+ pub fn test_priv_func() {
+ assert!(my_priv_func());
+ }
- pub mod __test_reexports {
- pub use super::test_priv_func;
- }
+ pub mod __test_reexports {
+ pub use super::test_priv_func;
+ }
}
```
```rust,ignore
#[main]
pub fn main() {
- extern crate test;
- test::test_main_static(&[&path::to::test1, /*...*/]);
+ extern crate test;
+ test::test_main_static(&[&path::to::test1, /*...*/]);
}
```
#[test]
#[should_panic]
fn foo() {
- panic!("intentional");
+ panic!("intentional");
}
```