summaryrefslogtreecommitdiffstats
path: root/src/rustdoc-json-types/tests.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/rustdoc-json-types/tests.rs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/rustdoc-json-types/tests.rs')
-rw-r--r--src/rustdoc-json-types/tests.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/rustdoc-json-types/tests.rs b/src/rustdoc-json-types/tests.rs
new file mode 100644
index 000000000..e7f6447ed
--- /dev/null
+++ b/src/rustdoc-json-types/tests.rs
@@ -0,0 +1,34 @@
+use super::*;
+
+#[test]
+fn test_struct_info_roundtrip() {
+ let s = ItemEnum::Struct(Struct {
+ struct_type: StructType::Plain,
+ generics: Generics { params: vec![], where_predicates: vec![] },
+ 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 {
+ generics: Generics { params: vec![], where_predicates: vec![] },
+ 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);
+}