summaryrefslogtreecommitdiffstats
path: root/vendor/toml-0.7.5/tests/testsuite/display_tricky.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/toml-0.7.5/tests/testsuite/display_tricky.rs')
-rw-r--r--vendor/toml-0.7.5/tests/testsuite/display_tricky.rs55
1 files changed, 55 insertions, 0 deletions
diff --git a/vendor/toml-0.7.5/tests/testsuite/display_tricky.rs b/vendor/toml-0.7.5/tests/testsuite/display_tricky.rs
new file mode 100644
index 000000000..379ae9138
--- /dev/null
+++ b/vendor/toml-0.7.5/tests/testsuite/display_tricky.rs
@@ -0,0 +1,55 @@
+use serde::Deserialize;
+use serde::Serialize;
+
+#[derive(Debug, Serialize, Deserialize)]
+pub struct Recipe {
+ pub name: String,
+ pub description: Option<String>,
+ #[serde(default)]
+ pub modules: Vec<Modules>,
+ #[serde(default)]
+ pub packages: Vec<Packages>,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+pub struct Modules {
+ pub name: String,
+ pub version: Option<String>,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+pub struct Packages {
+ pub name: String,
+ pub version: Option<String>,
+}
+
+#[test]
+fn both_ends() {
+ let recipe_works = toml::from_str::<Recipe>(
+ r#"
+ name = "testing"
+ description = "example"
+ modules = []
+
+ [[packages]]
+ name = "base"
+ "#,
+ )
+ .unwrap();
+ toml::to_string(&recipe_works).unwrap();
+
+ let recipe_fails = toml::from_str::<Recipe>(
+ r#"
+ name = "testing"
+ description = "example"
+ packages = []
+
+ [[modules]]
+ name = "base"
+ "#,
+ )
+ .unwrap();
+
+ let recipe_toml = toml::Table::try_from(recipe_fails).unwrap();
+ recipe_toml.to_string();
+}