aboutsummaryrefslogtreecommitdiff
path: root/test-suite
diff options
context:
space:
mode:
authorEric Huss <eric@huss.org>2019-01-07 18:52:28 -0800
committerGitHub <noreply@github.com>2019-01-07 18:52:28 -0800
commitd0977ab1dd9720c572b2d54a51196fcdf38f7544 (patch)
treee68d6abaaa3a5e142980b728672915ae8df7a600 /test-suite
parentad5ea1d904d5196fa63b77e826f82c377b604602 (diff)
parent7ee1c1b4798f18135ee618e30ccedfdf1f365451 (diff)
downloadmilf-rs-d0977ab1dd9720c572b2d54a51196fcdf38f7544.tar.gz
milf-rs-d0977ab1dd9720c572b2d54a51196fcdf38f7544.zip
Merge pull request #280 from alexcrichton/fix-duplicate
Fix disallowing duplicate table headers
Diffstat (limited to 'test-suite')
-rw-r--r--test-suite/tests/backcompat.rs24
-rw-r--r--test-suite/tests/invalid.rs2
-rw-r--r--test-suite/tests/invalid/duplicate-table.toml8
3 files changed, 33 insertions, 1 deletions
diff --git a/test-suite/tests/backcompat.rs b/test-suite/tests/backcompat.rs
index 1b3f599..e06eefc 100644
--- a/test-suite/tests/backcompat.rs
+++ b/test-suite/tests/backcompat.rs
@@ -4,7 +4,7 @@ extern crate serde;
use serde::de::Deserialize;
#[test]
-fn main() {
+fn newlines_after_tables() {
let s = "
[a] foo = 1
[[b]] foo = 1
@@ -17,3 +17,25 @@ fn main() {
assert_eq!(value["a"]["foo"].as_integer(), Some(1));
assert_eq!(value["b"][0]["foo"].as_integer(), Some(1));
}
+
+#[test]
+fn allow_duplicate_after_longer() {
+ let s = "
+ [dependencies.openssl-sys]
+ version = 1
+
+ [dependencies]
+ libc = 1
+
+ [dependencies]
+ bitflags = 1
+ ";
+ assert!(s.parse::<toml::Value>().is_err());
+
+ let mut d = toml::de::Deserializer::new(s);
+ d.set_allow_duplicate_after_longer_table(true);
+ let value = toml::Value::deserialize(&mut d).unwrap();
+ assert_eq!(value["dependencies"]["openssl-sys"]["version"].as_integer(), Some(1));
+ assert_eq!(value["dependencies"]["libc"].as_integer(), Some(1));
+ assert_eq!(value["dependencies"]["bitflags"].as_integer(), Some(1));
+}
diff --git a/test-suite/tests/invalid.rs b/test-suite/tests/invalid.rs
index 4679684..9f36e2c 100644
--- a/test-suite/tests/invalid.rs
+++ b/test-suite/tests/invalid.rs
@@ -96,3 +96,5 @@ test!(text_before_array_separator,
include_str!("invalid/text-before-array-separator.toml"));
test!(text_in_array,
include_str!("invalid/text-in-array.toml"));
+test!(duplicate_table,
+ include_str!("invalid/duplicate-table.toml"));
diff --git a/test-suite/tests/invalid/duplicate-table.toml b/test-suite/tests/invalid/duplicate-table.toml
new file mode 100644
index 0000000..5bd2571
--- /dev/null
+++ b/test-suite/tests/invalid/duplicate-table.toml
@@ -0,0 +1,8 @@
+[dependencies.openssl-sys]
+version = "0.5.2"
+
+[dependencies]
+libc = "0.1"
+
+[dependencies]
+bitflags = "0.1.1"