From 492dcbf5f08823058f53794d2e69b574311e79e1 Mon Sep 17 00:00:00 2001 From: Michael Aaron Murphy Date: Fri, 11 Jan 2019 15:46:56 -0700 Subject: [PATCH] :heavy_check_mark: Add tests for PartialEq and From --- tests/test.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/test.rs b/tests/test.rs index 49e011e..c678eac 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -237,3 +237,24 @@ fn unsync_clone() { let c = s.clone(); assert_eq!(c.get().map(String::as_str), Some("hello")); } + +#[test] +fn from_impl() { + assert_eq!(sync::OnceCell::from("value".to_owned()).get(), Some(&"value".to_owned())); + assert_eq!(unsync::OnceCell::from("value".to_owned()).get(), Some(&"value".to_owned())); + assert_ne!(sync::OnceCell::from("foo".to_owned()).get(), Some(&"bar".to_owned())); + assert_ne!(unsync::OnceCell::from("foo".to_owned()).get(), Some(&"bar".to_owned())); +} + +#[test] +fn partialeq_impl() { + assert!(sync::OnceCell::from("value".to_owned()) == sync::OnceCell::from("value".to_owned())); + assert!(sync::OnceCell::from("foo".to_owned()) != sync::OnceCell::from("bar".to_owned())); + assert!(unsync::OnceCell::from("value".to_owned()) == unsync::OnceCell::from("value".to_owned())); + assert!(unsync::OnceCell::from("foo".to_owned()) != unsync::OnceCell::from("bar".to_owned())); + + assert!(sync::OnceCell::::new() == sync::OnceCell::new()); + assert!(sync::OnceCell::::new() != sync::OnceCell::from("value".to_owned())); + assert!(unsync::OnceCell::::new() == unsync::OnceCell::new()); + assert!(unsync::OnceCell::::new() != unsync::OnceCell::from("value".to_owned())); +} \ No newline at end of file