diff options
author | Alex Crichton <alex@alexcrichton.com> | 2018-05-24 07:25:15 -0700 |
---|---|---|
committer | Alex Crichton <alex@alexcrichton.com> | 2018-05-24 07:25:42 -0700 |
commit | b192b562b49e0de2ff9cbc20a3dd995ad615f78d (patch) | |
tree | f3532b3553bfaa7c307f927d899fa5cb8c2037c1 /test-suite | |
parent | eddcac68781e43905b1e00f1b687bfa1134c2327 (diff) | |
download | milf-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.rs | 15 |
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); +} |