Skip to content

Commit 8d359e4

Browse files
committed
Move some Encodable/Decodable tests.
Round-trip encoding/decoding of many types is tested in `compiler/rustc_serialize/tests/opaque.rs`. There is also a small amount of encoding/decoding testing in three files in `tests/ui-fulldeps`. There is no obvious reason why these three files are necessary. They were originally added in 2014. Maybe it wasn't possible for a proc macro to run in a unit test back then? This commit just moves the testing from those three files into the unit test.
1 parent b4ba2f0 commit 8d359e4

File tree

4 files changed

+39
-111
lines changed

4 files changed

+39
-111
lines changed

compiler/rustc_serialize/tests/opaque.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,3 +251,42 @@ fn test_tuples() {
251251
check_round_trip(vec![(1234567isize, 100000000000000u64, 99999999999999i64)]);
252252
check_round_trip(vec![(String::new(), "some string".to_string())]);
253253
}
254+
255+
#[test]
256+
fn test_unit_like_struct() {
257+
#[derive(Encodable, Decodable, PartialEq, Debug)]
258+
struct UnitLikeStruct;
259+
260+
check_round_trip(vec![UnitLikeStruct]);
261+
}
262+
263+
#[test]
264+
fn test_box() {
265+
#[derive(Encodable, Decodable, PartialEq, Debug)]
266+
struct A {
267+
foo: Box<[bool]>,
268+
}
269+
270+
let obj = A { foo: Box::new([true, false]) };
271+
check_round_trip(vec![obj]);
272+
}
273+
274+
#[test]
275+
fn test_cell() {
276+
use std::cell::{Cell, RefCell};
277+
278+
#[derive(Encodable, Decodable, PartialEq, Debug)]
279+
struct A {
280+
baz: isize,
281+
}
282+
283+
#[derive(Encodable, Decodable, PartialEq, Debug)]
284+
struct B {
285+
foo: Cell<bool>,
286+
bar: RefCell<A>,
287+
}
288+
289+
let obj = B { foo: Cell::new(true), bar: RefCell::new(A { baz: 2 }) };
290+
check_round_trip(vec![obj]);
291+
}
292+

tests/ui-fulldeps/deriving-encodable-decodable-box.rs

Lines changed: 0 additions & 34 deletions
This file was deleted.

tests/ui-fulldeps/deriving-encodable-decodable-cell-refcell.rs

Lines changed: 0 additions & 44 deletions
This file was deleted.

tests/ui-fulldeps/issue-14021.rs

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)