mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
fixed tests and double escaping of escape symbols
This commit is contained in:
parent
580eac4b09
commit
1cce7d8a61
@ -31,7 +31,8 @@ public class BindingEscapingTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEscapedBindings() {
|
public void testEscapedBindings() {
|
||||||
DataMapper<String> mapper = VirtData.getMapper("Template('\"-{}-\"Func(234)\\\"\\)',NumberNameToString());'",String.class);
|
DataMapper<String> mapper = VirtData.getMapper("Template('\"-{}-\"Func(234)\\\\\"\\\\)',NumberNameToString())" +
|
||||||
|
";'",String.class);
|
||||||
String s = mapper.get(234);
|
String s = mapper.get(234);
|
||||||
assertThat(s).isEqualTo("\"-two hundred and thirty four-\"Func(234)\\\"\\)");
|
assertThat(s).isEqualTo("\"-two hundred and thirty four-\"Func(234)\\\"\\)");
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ public class Template implements LongFunction<String> {
|
|||||||
public String unescape(String partial) {
|
public String unescape(String partial) {
|
||||||
StringBuilder unescaped = new StringBuilder();
|
StringBuilder unescaped = new StringBuilder();
|
||||||
try {
|
try {
|
||||||
Pattern escapes = Pattern.compile("\\\\[^\\\\]");
|
Pattern escapes = Pattern.compile("\\\\.");
|
||||||
Matcher m = escapes.matcher(partial);
|
Matcher m = escapes.matcher(partial);
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
|
@ -64,4 +64,13 @@ public class TemplateTest {
|
|||||||
assertThat(unescaped2).isEqualTo("' one ' two '");
|
assertThat(unescaped2).isEqualTo("' one ' two '");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBackslashUnescaping() {
|
||||||
|
String escaped="front \\\\\" back";
|
||||||
|
LongFunction<String> func = String::valueOf;
|
||||||
|
Template template = new Template("{} extra", func);
|
||||||
|
String unescaped = template.unescape(escaped);
|
||||||
|
assertThat(unescaped).isEqualTo("front \\\" back");
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user