aboutsummaryrefslogtreecommitdiff
path: root/tests/pretty.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2017-07-28 15:18:18 -0500
committerGitHub <noreply@github.com>2017-07-28 15:18:18 -0500
commitcb14d39f154c4d3cc35ad21db14f35e0e3dfd913 (patch)
tree0a31778707796afe24b418ca1dc7a32d0ca1d84d /tests/pretty.rs
parent1a770fdb229621c1f62c4ea6ea9ab61cb7f0befe (diff)
parentca81a4a291930aa25637cf814b2f760f4e9d487d (diff)
downloadmilf-rs-cb14d39f154c4d3cc35ad21db14f35e0e3dfd913.tar.gz
milf-rs-cb14d39f154c4d3cc35ad21db14f35e0e3dfd913.zip
Merge pull request #201 from vitiral/triple
demonstrate tripple quote problem
Diffstat (limited to 'tests/pretty.rs')
-rw-r--r--tests/pretty.rs58
1 files changed, 52 insertions, 6 deletions
diff --git a/tests/pretty.rs b/tests/pretty.rs
index ae9a839..cceb815 100644
--- a/tests/pretty.rs
+++ b/tests/pretty.rs
@@ -41,11 +41,12 @@ fn disable_pretty() {
const PRETTY_STD: &'static str = "\
[example]
array = [
- \"item 1\",
- \"item 2\",
+ 'item 1',
+ 'item 2',
]
empty = []
-oneline = \"this has no newlines.\"
+one = ['one']
+oneline = 'this has no newlines.'
text = '''
this is the first line
this is the second line
@@ -67,15 +68,21 @@ fn pretty_std() {
const PRETTY_INDENT_2: &'static str = "\
[example]
array = [
- \"item 1\",
- \"item 2\",
+ 'item 1',
+ 'item 2',
]
empty = []
-oneline = \"this has no newlines.\"
+one = ['one']
+oneline = 'this has no newlines.'
text = '''
this is the first line
this is the second line
'''
+three = [
+ 'one',
+ 'two',
+ 'three',
+]
";
#[test]
@@ -88,6 +95,7 @@ fn pretty_indent_2() {
serializer.pretty_array_indent(2);
value.serialize(&mut serializer).unwrap();
}
+ println!(">> Result:\n{}", result);
assert_eq!(toml, &result);
}
@@ -166,3 +174,41 @@ fn pretty_no_string() {
}
assert_eq!(toml, &result);
}
+
+const PRETTY_TRICKY: &'static str = r##"[example]
+f = "\f"
+glass = '''
+Nothing too unusual, except that I can eat glass in:
+- Greek: Μπορώ να φάω σπασμένα γυαλιά χωρίς να πάθω τίποτα.
+- Polish: Mogę jeść szkło, i mi nie szkodzi.
+- Hindi: मैं काँच खा सकता हूँ, मुझे उस से कोई पीडा नहीं होती.
+- Japanese: 私はガラスを食べられます。それは私を傷つけません。
+'''
+r = "\r"
+r_newline = """
+\r
+"""
+single = '''this is a single line but has '' cuz it's tricky'''
+single_tricky = "single line with ''' in it"
+tabs = '''
+this is pretty standard
+ except for some tabs right here
+'''
+text = """
+this is the first line.
+This has a ''' in it and \"\"\" cuz it's tricky yo
+Also ' and \" because why not
+this is the third line
+"""
+"##;
+
+#[test]
+fn pretty_tricky() {
+ let toml = PRETTY_TRICKY;
+ let value: toml::Value = toml::from_str(toml).unwrap();
+ let mut result = String::with_capacity(128);
+ value.serialize(&mut toml::Serializer::pretty(&mut result)).unwrap();
+ println!("EXPECTED:\n{}", toml);
+ println!("\nRESULT:\n{}", result);
+ assert_eq!(toml, &result);
+}