Files
rust/src/rustdoc-json-types/tests.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
827 B
Rust
Raw Normal View History

2021-03-04 19:08:06 -05:00
use super::*;
#[test]
fn test_struct_info_roundtrip() {
let s = ItemEnum::Struct(Struct {
struct_type: StructType::Plain,
2021-03-04 19:44:09 -05:00
generics: Generics { params: vec![], where_predicates: vec![] },
2021-03-04 19:08:06 -05:00
fields_stripped: false,
fields: vec![],
impls: vec![],
});
let struct_json = serde_json::to_string(&s).unwrap();
let de_s = serde_json::from_str(&struct_json).unwrap();
assert_eq!(s, de_s);
}
#[test]
fn test_union_info_roundtrip() {
let u = ItemEnum::Union(Union {
2021-03-04 19:44:09 -05:00
generics: Generics { params: vec![], where_predicates: vec![] },
2021-03-04 19:08:06 -05:00
fields_stripped: false,
fields: vec![],
impls: vec![],
});
let union_json = serde_json::to_string(&u).unwrap();
let de_u = serde_json::from_str(&union_json).unwrap();
assert_eq!(u, de_u);
2021-03-04 19:44:09 -05:00
}