1 package com.atlassian.sal.core.pluginsettings;
2
3 import org.junit.Test;
4
5 import static org.junit.Assert.assertEquals;
6
7 public class TestEscapeUtils
8 {
9 @Test
10 public void testNoEscape()
11 {
12 String value = "this is the value";
13 assertEquals(value, EscapeUtils.escape(value));
14 }
15
16 @Test
17 public void testEscape()
18 {
19 String value = "this is \fthe \nvalue";
20 assertEquals("this is \\fthe \\nvalue", EscapeUtils.escape(value));
21 }
22
23 @Test
24 public void testUnescape()
25 {
26 String value = "this \\fis \\nthe value";
27 assertEquals("this \fis \nthe value", EscapeUtils.unescape(value));
28 }
29
30 @Test
31 public void testUnescapeNonescape()
32 {
33 String value = "this \nis the \fvalue";
34 assertEquals(value, EscapeUtils.unescape(value));
35 }
36
37 @Test
38 public void testFullCycle()
39 {
40 runCheckFullCycle("this \nis the \fvalue");
41 runCheckFullCycle("this \\nis the \\fvalue");
42 }
43
44 private void runCheckFullCycle(String value)
45 {
46 assertEquals(value, EscapeUtils.unescape(EscapeUtils.escape(value)));
47 }
48 }