aboutsummaryrefslogtreecommitdiff
path: root/test-suite
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2018-10-29 09:09:57 -0700
committerGitHub <noreply@github.com>2018-10-29 09:09:57 -0700
commit2fbcf8623acda16ae633dbec41cad28f3bbf9ab4 (patch)
treefa514155ffcc2b17919215e6a8a378371a952460 /test-suite
parent3aec5a918a6cb39fa32e8a56725a3c2fc0ed6bc2 (diff)
parent93c0eaf24e33ab376ce9a5197ac759d37c3fcdf1 (diff)
downloadmilf-rs-2fbcf8623acda16ae633dbec41cad28f3bbf9ab4.tar.gz
milf-rs-2fbcf8623acda16ae633dbec41cad28f3bbf9ab4.zip
Merge pull request #272 from hcpl/tuple-support
Support tuple Serde types for `Value`
Diffstat (limited to 'test-suite')
-rw-r--r--test-suite/tests/serde.rs60
1 files changed, 54 insertions, 6 deletions
diff --git a/test-suite/tests/serde.rs b/test-suite/tests/serde.rs
index b97937f..c1b6d78 100644
--- a/test-suite/tests/serde.rs
+++ b/test-suite/tests/serde.rs
@@ -580,15 +580,63 @@ fn table_structs_empty() {
#[test]
fn fixed_size_array() {
- #[derive(Serialize, PartialEq, Eq, Deserialize, Debug)]
+ #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
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);
+
+ equivalent! {
+ Entity { pos: [1, 2] },
+ Table(map! {
+ pos: Array(vec![
+ Integer(1),
+ Integer(2),
+ ])
+ }),
+ }
+}
+
+#[test]
+fn homogeneous_tuple() {
+ #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
+ struct Collection {
+ elems: (i64, i64, i64),
+ }
+
+ equivalent! {
+ Collection { elems: (0, 1, 2) },
+ Table(map! {
+ elems: Array(vec![
+ Integer(0),
+ Integer(1),
+ Integer(2),
+ ])
+ }),
+ }
+}
+
+#[test]
+fn homogeneous_tuple_struct() {
+ #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
+ struct Object(Vec<String>, Vec<String>, Vec<String>);
+
+ equivalent! {
+ map! {
+ obj: Object(vec!["foo".to_string()], vec![], vec!["bar".to_string(), "baz".to_string()])
+ },
+ Table(map! {
+ obj: Array(vec![
+ Array(vec![
+ Value::String("foo".to_string()),
+ ]),
+ Array(vec![]),
+ Array(vec![
+ Value::String("bar".to_string()),
+ Value::String("baz".to_string()),
+ ]),
+ ])
+ }),
+ }
}
#[test]