|
@@ -0,0 +1,70 @@
|
|
1
|
+/*
|
|
2
|
+ * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
|
|
3
|
+ *
|
|
4
|
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+ * of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+ * in the Software without restriction, including without limitation the rights
|
|
7
|
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+ * copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+ * furnished to do so, subject to the following conditions:
|
|
10
|
+ *
|
|
11
|
+ * The above copyright notice and this permission notice shall be included in
|
|
12
|
+ * all copies or substantial portions of the Software.
|
|
13
|
+ *
|
|
14
|
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+ * SOFTWARE.
|
|
21
|
+ */
|
|
22
|
+
|
|
23
|
+package com.dmdirc.ui.messages;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+import java.util.Arrays;
|
|
27
|
+import java.util.List;
|
|
28
|
+
|
|
29
|
+import org.junit.Test;
|
|
30
|
+import org.junit.runner.RunWith;
|
|
31
|
+import org.junit.runners.Parameterized;
|
|
32
|
+import static org.junit.Assert.*;
|
|
33
|
+
|
|
34
|
+@RunWith(Parameterized.class)
|
|
35
|
+public class StyliserIndicesTest {
|
|
36
|
+
|
|
37
|
+ protected String input, output;
|
|
38
|
+ protected int start, end;
|
|
39
|
+
|
|
40
|
+ public StyliserIndicesTest(String input, int start, int end, String output) {
|
|
41
|
+ this.input = input;
|
|
42
|
+ this.start = start;
|
|
43
|
+ this.end = end;
|
|
44
|
+ this.output = output;
|
|
45
|
+ }
|
|
46
|
+
|
|
47
|
+ @Test
|
|
48
|
+ public void testStyle() {
|
|
49
|
+ assertEquals(output, Styliser.getStyledText(input, start, end));
|
|
50
|
+ }
|
|
51
|
+
|
|
52
|
+ @Parameterized.Parameters
|
|
53
|
+ public static List<Object[]> data() {
|
|
54
|
+ final Object[][] tests = {
|
|
55
|
+ // No style
|
|
56
|
+ {"Blah blah blah", 0, 1, "B"},
|
|
57
|
+ {"Blah blah blah", 0, 4, "Blah"},
|
|
58
|
+ {Styliser.CODE_BOLD + "Blah blah blah", 0, 4, Styliser.CODE_BOLD + "Blah"},
|
|
59
|
+ {Styliser.CODE_BOLD + "Bl" + Styliser.CODE_BOLD + "ah blah blah",
|
|
60
|
+ 0, 4, Styliser.CODE_BOLD + "Bl" + Styliser.CODE_BOLD + "ah"},
|
|
61
|
+ {"Blah" + Styliser.CODE_BOLD + " blah blah",
|
|
62
|
+ 0, 4, "Blah"},
|
|
63
|
+ {"Blah" + Styliser.CODE_COLOUR + "4,0RED blah blah",
|
|
64
|
+ 4, 7, Styliser.CODE_COLOUR + "4,0RED"},
|
|
65
|
+ };
|
|
66
|
+
|
|
67
|
+ return Arrays.asList(tests);
|
|
68
|
+ }
|
|
69
|
+
|
|
70
|
+}
|