Added 1st simple rkyv serializer test

This commit is contained in:
Teknique 2023-05-23 11:03:46 -07:00
parent 4994f54039
commit 1654d03ad2
5 changed files with 32 additions and 0 deletions

View File

@ -12,3 +12,4 @@ use super::*;
pub use common::*; pub use common::*;
pub use crypto::tests::*; pub use crypto::tests::*;
pub use network_manager::tests::*; pub use network_manager::tests::*;
pub use veilid_api::tests::*;

View File

@ -3,6 +3,7 @@
use crate::crypto::tests::*; use crate::crypto::tests::*;
use crate::network_manager::tests::*; use crate::network_manager::tests::*;
use crate::tests::common::*; use crate::tests::common::*;
use crate::veilid_api::tests::*;
use crate::*; use crate::*;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -163,5 +164,14 @@ cfg_if! {
}) })
} }
#[test]
#[serial]
fn run_test_serialize_rkyv() {
setup();
block_on(async {
test_serialize_rkyv::test_all().await;
})
}
} }
} }

View File

@ -7,6 +7,8 @@ mod routing_context;
mod serialize_helpers; mod serialize_helpers;
mod types; mod types;
pub mod tests;
pub use api::*; pub use api::*;
pub use debug::*; pub use debug::*;
pub use error::*; pub use error::*;

View File

@ -0,0 +1,3 @@
pub mod test_serialize_rkyv;
use super::*;

View File

@ -0,0 +1,16 @@
use crate::*;
pub async fn test_simple_string() {
let plain = "basic string".to_string();
let serialized = b"basic string\x0c\x00\x00\x00\xf4\xff\xff\xff".to_vec();
let a = to_rkyv(&plain);
assert_eq!(a.unwrap(), serialized);
let b = from_rkyv::<String>(serialized);
assert_eq!(b.unwrap(), plain);
}
pub async fn test_all() {
test_simple_string().await;
}