Move unit tests inside conditionally compiled mod tests { } blocks
Idiomatic rust organizes unit tests into `mod tests { }` blocks
using conditional compilation `[cfg(test)]` to decide whether to
compile the code in that block.
This commit moves "bare" test functions into such blocks, and puts
the block at the bottom of respective file.
This commit is contained in:
@@ -397,25 +397,30 @@ impl Request {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn request_implements_send_and_sync() {
|
||||
let _request: Box<dyn Send> = Box::new(Request::new(
|
||||
Agent::new(),
|
||||
"GET".to_string(),
|
||||
"https://example.com/".to_string(),
|
||||
));
|
||||
let _request: Box<dyn Sync> = Box::new(Request::new(
|
||||
Agent::new(),
|
||||
"GET".to_string(),
|
||||
"https://example.com/".to_string(),
|
||||
));
|
||||
}
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn send_byte_slice() {
|
||||
let bytes = vec![1, 2, 3];
|
||||
crate::agent()
|
||||
.post("http://example.com")
|
||||
.send(&bytes[1..2])
|
||||
.ok();
|
||||
#[test]
|
||||
fn request_implements_send_and_sync() {
|
||||
let _request: Box<dyn Send> = Box::new(Request::new(
|
||||
Agent::new(),
|
||||
"GET".to_string(),
|
||||
"https://example.com/".to_string(),
|
||||
));
|
||||
let _request: Box<dyn Sync> = Box::new(Request::new(
|
||||
Agent::new(),
|
||||
"GET".to_string(),
|
||||
"https://example.com/".to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn send_byte_slice() {
|
||||
let bytes = vec![1, 2, 3];
|
||||
crate::agent()
|
||||
.post("http://example.com")
|
||||
.send(&bytes[1..2])
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user