Skip to content

Commit

Permalink
✔️ Add tests for PartialEq and From<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
mmstick committed Jan 11, 2019
1 parent 7bb24fb commit 492dcbf
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<String>::new() == sync::OnceCell::new());
assert!(sync::OnceCell::<String>::new() != sync::OnceCell::from("value".to_owned()));
assert!(unsync::OnceCell::<String>::new() == unsync::OnceCell::new());
assert!(unsync::OnceCell::<String>::new() != unsync::OnceCell::from("value".to_owned()));
}

0 comments on commit 492dcbf

Please sign in to comment.