aboutsummaryrefslogtreecommitdiff
path: root/test-suite
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2018-05-24 07:25:15 -0700
committerAlex Crichton <alex@alexcrichton.com>2018-05-24 07:25:42 -0700
commitb192b562b49e0de2ff9cbc20a3dd995ad615f78d (patch)
treef3532b3553bfaa7c307f927d899fa5cb8c2037c1 /test-suite
parenteddcac68781e43905b1e00f1b687bfa1134c2327 (diff)
downloadmilf-rs-b192b562b49e0de2ff9cbc20a3dd995ad615f78d.tar.gz
milf-rs-b192b562b49e0de2ff9cbc20a3dd995ad615f78d.zip
Support fixed-length arrays
Turns out these are deserialized/serialized as tuples! While we're at it add support for tuple variants and tuple structs through the same paths. Closes #244
Diffstat (limited to 'test-suite')
-rw-r--r--test-suite/tests/serde.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/test-suite/tests/serde.rs b/test-suite/tests/serde.rs
index 57fa5db..446cd7a 100644
--- a/test-suite/tests/serde.rs
+++ b/test-suite/tests/serde.rs
@@ -569,10 +569,23 @@ fn table_structs_empty() {
expected.insert("bar".to_string(), CanBeEmpty::default());
expected.insert("baz".to_string(), CanBeEmpty::default());
expected.insert(
- "bazv".to_string(),
+ "bazv".to_string(),
CanBeEmpty {a: Some("foo".to_string()), b: None},
);
expected.insert("foo".to_string(), CanBeEmpty::default());
assert_eq!(value, expected);
assert_eq!(toml::to_string(&value).unwrap(), text);
}
+
+#[test]
+fn fixed_size_array() {
+ #[derive(Serialize, PartialEq, Eq, Deserialize, Debug)]
+ struct Entity {
+ pos: [i32; 2]
+ }
+ let text = "pos = [1, 2]\n";
+ let value: Entity = toml::from_str(text).unwrap();
+ let expected = Entity { pos: [1, 2] };
+ assert_eq!(value, expected);
+ assert_eq!(toml::to_string(&value).unwrap(), text);
+}