From a58abae193ad36b48dbe13a4f29c0ee75675d544 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 7 May 2018 11:16:34 -0700 Subject: [PATCH] Test Weak serialize impls --- test_suite/tests/test_ser.rs | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/test_suite/tests/test_ser.rs b/test_suite/tests/test_ser.rs index dbc42da6..d677fe35 100644 --- a/test_suite/tests/test_ser.rs +++ b/test_suite/tests/test_ser.rs @@ -11,11 +11,12 @@ extern crate serde_derive; use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; use std::ffi::CString; +use std::mem; use std::net; use std::num::Wrapping; use std::path::{Path, PathBuf}; -use std::rc::Rc; -use std::sync::Arc; +use std::rc::{Rc, Weak as RcWeak}; +use std::sync::{Arc, Weak as ArcWeak}; use std::time::{Duration, UNIX_EPOCH}; #[cfg(unix)] @@ -398,11 +399,41 @@ declare_tests! { Token::Bool(true), ], } + test_rc_weak_some { + { + let rc = Rc::new(true); + mem::forget(rc.clone()); + Rc::downgrade(&rc) + } => &[ + Token::Some, + Token::Bool(true), + ], + } + test_rc_weak_none { + RcWeak::::new() => &[ + Token::None, + ], + } test_arc { Arc::new(true) => &[ Token::Bool(true), ], } + test_arc_weak_some { + { + let arc = Arc::new(true); + mem::forget(arc.clone()); + Arc::downgrade(&arc) + } => &[ + Token::Some, + Token::Bool(true), + ], + } + test_arc_weak_none { + ArcWeak::::new() => &[ + Token::None, + ], + } test_wrapping { Wrapping(1usize) => &[ Token::U64(1),