Skip to content

Commit

Permalink
Test Weak serialize impls
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed May 7, 2018
1 parent 0362816 commit bcb7019
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions test_suite/tests/test_ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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::<bool>::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::<bool>::new() => &[
Token::None,
],
}
test_wrapping {
Wrapping(1usize) => &[
Token::U64(1),
Expand Down

0 comments on commit bcb7019

Please sign in to comment.