summaryrefslogtreecommitdiffstats
path: root/vendor/handlebars/tests/escape.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /vendor/handlebars/tests/escape.rs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/handlebars/tests/escape.rs')
-rw-r--r--vendor/handlebars/tests/escape.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/vendor/handlebars/tests/escape.rs b/vendor/handlebars/tests/escape.rs
new file mode 100644
index 000000000..563ab76b9
--- /dev/null
+++ b/vendor/handlebars/tests/escape.rs
@@ -0,0 +1,43 @@
+extern crate handlebars;
+
+#[macro_use]
+extern crate serde_json;
+
+use handlebars::{handlebars_helper, Handlebars};
+
+#[test]
+fn test_escape_216() {
+ let hbs = Handlebars::new();
+
+ let data = json!({
+ "FOO": "foo",
+ "BAR": "bar"
+ });
+
+ assert_eq!(
+ hbs.render_template(r"\\\\ {{FOO}} {{BAR}} {{FOO}}{{BAR}} {{FOO}}#{{BAR}} {{FOO}}//{{BAR}} {{FOO}}\\{{FOO}} {{FOO}}\\\\{{FOO}}\\\{{FOO}} \\\{{FOO}} \{{FOO}} \{{FOO}}", &data).unwrap(),
+ r"\\\\ foo bar foobar foo#bar foo//bar foo\foo foo\\\foo\\foo \\foo {{FOO}} {{FOO}}"
+ );
+}
+
+#[test]
+fn test_string_no_escape_422() {
+ let mut hbs = Handlebars::new();
+
+ handlebars_helper!(replace: |input: str, from: str, to: str| {
+ input.replace(from, to)
+ });
+ hbs.register_helper("replace", Box::new(replace));
+
+ assert_eq!(
+ r#"some\ path"#,
+ hbs.render_template(r#"{{replace "some/path" "/" "\\ " }}"#, &())
+ .unwrap()
+ );
+
+ assert_eq!(
+ r#"some\path"#,
+ hbs.render_template(r#"{{replace "some/path" "/" "\\" }}"#, &())
+ .unwrap()
+ );
+}