Skip to content

Commit

Permalink
test(edit): Add more roundtrip testing
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Jul 17, 2024
1 parent c8c42a8 commit 00fb5ee
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions crates/toml_edit/tests/testsuite/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1634,6 +1634,18 @@ fn string_repr_roundtrip() {
str![[r#""triple quote /"/"/" triple quote""#]],
);
assert_string_repr_roundtrip(r#""end quote \"""#, str![[r#""end quote /"""#]]);
assert_string_repr_roundtrip(
r#""quoted \"content\" quoted""#,
str![[r#""quoted /"content/" quoted""#]],
);
assert_string_repr_roundtrip(
r#""squoted 'content' squoted""#,
str![[r#""squoted 'content' squoted""#]],
);
assert_string_repr_roundtrip(
r#""mixed quoted \"start\" 'end'' mixed quote""#,
str![[r#""mixed quoted /"start/" 'end'' mixed quote""#]],
);
}

#[track_caller]
Expand Down Expand Up @@ -1695,6 +1707,18 @@ crlf /r
str![[r#"'triple quote """ triple quote'"#]],
);
assert_string_value_roundtrip(r#""end quote \"""#, str![[r#"'end quote "'"#]]);
assert_string_value_roundtrip(
r#""quoted \"content\" quoted""#,
str![[r#"'quoted "content" quoted'"#]],
);
assert_string_value_roundtrip(
r#""squoted 'content' squoted""#,
str![[r#""squoted 'content' squoted""#]],
);
assert_string_value_roundtrip(
r#""mixed quoted \"start\" 'end'' mixed quote""#,
str![[r#"'''mixed quoted "start" 'end'' mixed quote'''"#]],
);
}

#[track_caller]
Expand Down Expand Up @@ -1743,6 +1767,18 @@ fn key_repr_roundtrip() {
str![[r#""triple quote /"/"/" triple quote""#]],
);
assert_key_repr_roundtrip(r#""end quote \"""#, str![[r#""end quote /"""#]]);
assert_key_repr_roundtrip(
r#""quoted \"content\" quoted""#,
str![[r#""quoted /"content/" quoted""#]],
);
assert_key_repr_roundtrip(
r#""squoted 'content' squoted""#,
str![[r#""squoted 'content' squoted""#]],
);
assert_key_repr_roundtrip(
r#""mixed quoted \"start\" 'end'' mixed quote""#,
str![[r#""mixed quoted /"start/" 'end'' mixed quote""#]],
);
}

#[track_caller]
Expand Down Expand Up @@ -1790,6 +1826,20 @@ fn key_value_roundtrip() {
str![[r#"'triple quote """ triple quote'"#]],
);
assert_key_value_roundtrip(r#""end quote \"""#, str![[r#"'end quote "'"#]]);
assert_key_value_roundtrip(
r#""quoted \"content\" quoted""#,
str![[r#"'quoted "content" quoted'"#]],
);
assert_key_value_roundtrip(
r#""squoted 'content' squoted""#,
str![[r#""squoted 'content' squoted""#]],
);
/*
assert_key_value_roundtrip(
r#""mixed quoted \"start\" 'end'' mixed quote""#,
str![[r#""squoted 'content' squoted""#]],
);
*/
}

#[track_caller]
Expand Down

0 comments on commit 00fb5ee

Please sign in to comment.