mirror of
https://github.com/ntex-rs/ntex.git
synced 2025-04-03 21:07:39 +03:00
fix tests
This commit is contained in:
parent
8c611466b1
commit
40aa4542ce
10 changed files with 38 additions and 23 deletions
|
@ -34,6 +34,7 @@ fn test_get_u16() {
|
|||
assert_eq!(0x5421, buf.get_u16_le());
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn test_get_u16_buffer_underflow() {
|
||||
|
|
|
@ -217,6 +217,7 @@ fn slice() {
|
|||
assert_eq!(b, b"lo world"[..]);
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn slice_oob_1() {
|
||||
|
@ -224,6 +225,7 @@ fn slice_oob_1() {
|
|||
a.slice(5..(inline_cap() + 1));
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn slice_oob_2() {
|
||||
|
@ -246,6 +248,7 @@ fn split_off() {
|
|||
assert_eq!(world, &b"world"[..]);
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn split_off_oob() {
|
||||
|
@ -385,6 +388,7 @@ fn split_to_2() {
|
|||
drop(b);
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn split_to_oob() {
|
||||
|
@ -392,6 +396,7 @@ fn split_to_oob() {
|
|||
hello.split_to(inline_cap() + 1);
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn split_to_oob_mut() {
|
||||
|
@ -402,6 +407,7 @@ fn split_to_oob_mut() {
|
|||
hello.split_to(inline_cap() + 1);
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn split_to_uninitialized() {
|
||||
|
@ -412,6 +418,7 @@ fn split_to_uninitialized() {
|
|||
let _other = bytes.split_to(128);
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[test]
|
||||
fn split_off_to_at_gt_len() {
|
||||
fn make_bytes() -> Bytes {
|
||||
|
@ -439,7 +446,7 @@ fn split_off_to_at_gt_len() {
|
|||
#[test]
|
||||
fn fns_defined_for_bytes() {
|
||||
let mut bytes = Bytes::from(&b"hello world"[..]);
|
||||
bytes.as_ptr();
|
||||
let _ = bytes.as_ptr();
|
||||
assert_eq!(Borrow::<[u8]>::borrow(&bytes), b"hello world");
|
||||
|
||||
assert!(bytes > "g");
|
||||
|
@ -489,8 +496,8 @@ fn fns_defined_for_bytes() {
|
|||
#[test]
|
||||
fn fns_defined_for_bytes_mut() {
|
||||
let mut bytes = BytesMut::from(&b"hello world"[..]);
|
||||
bytes.as_ptr();
|
||||
bytes.as_mut_ptr();
|
||||
let _ = bytes.as_ptr();
|
||||
let _ = bytes.as_mut_ptr();
|
||||
assert_eq!(Borrow::<[u8]>::borrow(&bytes), b"hello world");
|
||||
assert_eq!(BorrowMut::<[u8]>::borrow_mut(&mut bytes), b"hello world");
|
||||
|
||||
|
@ -551,8 +558,8 @@ fn fns_defined_for_bytes_mut() {
|
|||
fn fns_defined_for_bytes_vec() {
|
||||
// BytesVec
|
||||
let mut bytes = BytesVec::copy_from_slice(&b"hello world"[..]);
|
||||
bytes.as_ptr();
|
||||
bytes.as_mut_ptr();
|
||||
let _ = bytes.as_ptr();
|
||||
let _ = bytes.as_mut_ptr();
|
||||
assert_eq!(Borrow::<[u8]>::borrow(&bytes), b"hello world");
|
||||
assert_eq!(BorrowMut::<[u8]>::borrow_mut(&mut bytes), b"hello world");
|
||||
|
||||
|
@ -787,6 +794,7 @@ fn advance_vec() {
|
|||
assert_eq!(a, b"d zomg wat wat"[..]);
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn advance_past_len() {
|
||||
|
@ -794,6 +802,7 @@ fn advance_past_len() {
|
|||
a.advance(20);
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn advance_past_len_vec() {
|
||||
|
@ -908,6 +917,7 @@ fn slice_ref_empty() {
|
|||
assert_eq!(&sub[..], b"");
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn slice_ref_catches_not_a_subset() {
|
||||
|
@ -917,6 +927,7 @@ fn slice_ref_catches_not_a_subset() {
|
|||
bytes.slice_ref(slice);
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn slice_ref_catches_not_an_empty_subset() {
|
||||
|
@ -926,6 +937,7 @@ fn slice_ref_catches_not_an_empty_subset() {
|
|||
bytes.slice_ref(slice);
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn empty_slice_ref_catches_not_an_empty_subset() {
|
||||
|
|
|
@ -58,3 +58,4 @@ webpki-roots = { version = "0.22", optional = true }
|
|||
[dev-dependencies]
|
||||
rand = "0.8"
|
||||
env_logger = "0.9"
|
||||
ntex = { version = "0.5", features = ["tokio"] }
|
||||
|
|
|
@ -119,12 +119,12 @@ impl<T: Address> Service<Connect<T>> for Connector<T> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::service::{Service, ServiceFactory};
|
||||
use ntex_service::{Service, ServiceFactory};
|
||||
|
||||
#[crate::rt_test]
|
||||
#[ntex::test]
|
||||
async fn test_openssl_connect() {
|
||||
let server = crate::server::test_server(|| {
|
||||
crate::service::fn_service(|_| async { Ok::<_, ()>(()) })
|
||||
let server = ntex::server::test_server(|| {
|
||||
ntex::service::fn_service(|_| async { Ok::<_, ()>(()) })
|
||||
});
|
||||
|
||||
let ssl = SslConnector::builder(SslMethod::tls()).unwrap();
|
||||
|
|
|
@ -135,9 +135,9 @@ impl<T: Address> Service<Connect<T>> for Resolver<T> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::util::lazy;
|
||||
use ntex_util::future::lazy;
|
||||
|
||||
#[crate::rt_test]
|
||||
#[ntex::test]
|
||||
async fn resolver() {
|
||||
let resolver = Resolver::default().clone();
|
||||
assert!(format!("{:?}", resolver).contains("Resolver"));
|
||||
|
|
|
@ -125,13 +125,13 @@ mod tests {
|
|||
use tls_rustls::{OwnedTrustAnchor, RootCertStore};
|
||||
|
||||
use super::*;
|
||||
use crate::service::{Service, ServiceFactory};
|
||||
use crate::util::lazy;
|
||||
use ntex_service::{Service, ServiceFactory};
|
||||
use ntex_util::future::lazy;
|
||||
|
||||
#[crate::rt_test]
|
||||
#[ntex::test]
|
||||
async fn test_rustls_connect() {
|
||||
let server = crate::server::test_server(|| {
|
||||
crate::service::fn_service(|_| async { Ok::<_, ()>(()) })
|
||||
let server = ntex::server::test_server(|| {
|
||||
ntex::service::fn_service(|_| async { Ok::<_, ()>(()) })
|
||||
});
|
||||
|
||||
let mut cert_store = RootCertStore::empty();
|
||||
|
|
|
@ -234,10 +234,10 @@ impl<T: Address> Future for TcpConnectorResponse<T> {
|
|||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[crate::rt_test]
|
||||
#[ntex::test]
|
||||
async fn test_connect() {
|
||||
let server = crate::server::test_server(|| {
|
||||
crate::service::fn_service(|_| async { Ok::<_, ()>(()) })
|
||||
let server = ntex::server::test_server(|| {
|
||||
ntex_service::fn_service(|_| async { Ok::<_, ()>(()) })
|
||||
});
|
||||
|
||||
let srv = Connector::default().memory_pool(PoolId::P5);
|
||||
|
@ -256,11 +256,11 @@ mod tests {
|
|||
.unwrap(),
|
||||
server.addr(),
|
||||
]);
|
||||
let result = crate::connect::connect(msg).await;
|
||||
let result = crate::connect(msg).await;
|
||||
assert!(result.is_ok());
|
||||
|
||||
let msg = Connect::new(server.addr());
|
||||
let result = crate::connect::connect(msg).await;
|
||||
let result = crate::connect(msg).await;
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -408,7 +408,7 @@ impl<'a> Iterator for Iter<'a> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::http::header::CONTENT_TYPE;
|
||||
use crate::header::CONTENT_TYPE;
|
||||
|
||||
#[test]
|
||||
fn test_basics() {
|
||||
|
|
|
@ -809,6 +809,7 @@ mod tests {
|
|||
assert_eq!(&data.lock().unwrap().borrow()[..], &[0, 1]);
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[ntex::test]
|
||||
async fn test_unhandled_data() {
|
||||
let handled = Arc::new(AtomicBool::new(false));
|
||||
|
|
|
@ -430,7 +430,7 @@ mod tests {
|
|||
#[ntex_macros::rt_test2]
|
||||
async fn test_deadline() {
|
||||
let first_time = now();
|
||||
let mut dl = deadline(Millis(1));
|
||||
let dl = deadline(Millis(1));
|
||||
dl.await;
|
||||
let second_time = now();
|
||||
assert!(second_time - first_time >= time::Duration::from_millis(1));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue