Skip to content

Commit

Permalink
Add tests for DnsNameRef traits.
Browse files Browse the repository at this point in the history
  • Loading branch information
briansmith committed Apr 22, 2021
1 parent 81bd1e3 commit b31b588
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/name_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use ring::test::{compile_time_assert_send, compile_time_assert_sync};
use webpki::DnsNameRef;

#[test]
fn test_dns_name_ref_traits() {
compile_time_assert_send::<DnsNameRef>();
compile_time_assert_sync::<DnsNameRef>();

let a = DnsNameRef::try_from_ascii(b"example.com").unwrap();

// `Copy`
{
let _b = a;
let _c = a;
}

// `Clone`
#[allow(clippy::clone_on_copy)]
let _ = a.clone();
// TODO: verify the clone is the same as `a`.

// TODO: Don't require `alloc` for these.
#[cfg(feature = "alloc")]
{
// `Debug`.
assert_eq!(format!("{:?}", &a), "DnsNameRef(\"example.com\")");
}
}

0 comments on commit b31b588

Please sign in to comment.