Skip to content

Commit d063f37

Browse files
committed
add struct array/tuple unittests
#59 by jordy25519
1 parent e23289a commit d063f37

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/de/mod.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,46 @@ mod tests {
10921092
);
10931093
}
10941094

1095+
#[test]
1096+
fn struct_with_array_field() {
1097+
#[derive(Debug, Deserialize, PartialEq)]
1098+
struct Test {
1099+
status: bool,
1100+
point: [u32; 3],
1101+
}
1102+
1103+
assert_eq!(
1104+
crate::from_str(r#"{ "status": true, "point": [1, 2, 3] }"#),
1105+
Ok((
1106+
Test {
1107+
status: true,
1108+
point: [1, 2, 3]
1109+
},
1110+
38
1111+
))
1112+
);
1113+
}
1114+
1115+
#[test]
1116+
fn struct_with_tuple_field() {
1117+
#[derive(Debug, Deserialize, PartialEq)]
1118+
struct Test {
1119+
status: bool,
1120+
point: (u32, u32, u32),
1121+
}
1122+
1123+
assert_eq!(
1124+
crate::from_str(r#"{ "status": true, "point": [1, 2, 3] }"#),
1125+
Ok((
1126+
Test {
1127+
status: true,
1128+
point: (1, 2, 3)
1129+
},
1130+
38
1131+
))
1132+
);
1133+
}
1134+
10951135
#[test]
10961136
fn ignoring_extra_fields() {
10971137
#[derive(Debug, Deserialize, PartialEq)]

0 commit comments

Comments
 (0)