1 package net.sourceforge.pmd.properties;
2
3 import net.sourceforge.pmd.PropertyDescriptor;
4 import net.sourceforge.pmd.lang.rule.properties.CharacterMultiProperty;
5 import net.sourceforge.pmd.lang.rule.properties.CharacterProperty;
6
7 import org.junit.Test;
8
9
10
11
12
13
14
15 public class CharacterPropertyTest extends AbstractPropertyDescriptorTester {
16
17 private static final char delimiter = '|';
18 private static final char[] charSet = filter(allChars.toCharArray(), delimiter);
19
20 public CharacterPropertyTest() {
21 super();
22 }
23
24
25
26
27
28
29 protected Object createValue(int count) {
30
31 if (count == 1) return new Character(randomChar(charSet));
32
33 Character[] values = new Character[count];
34 for (int i=0; i<values.length; i++) values[i] = (Character)createValue(1);
35 return values;
36 }
37
38
39
40
41
42
43 protected Object createBadValue(int count) {
44
45 if (count == 1) return null;
46
47 Character[] values = new Character[count];
48 for (int i=0; i<values.length; i++) values[i] = (Character)createBadValue(1);
49 return values;
50 }
51
52 @Test
53 public void testErrorForBad() { }
54
55
56
57
58
59
60
61 protected PropertyDescriptor createProperty(boolean multiValue) {
62
63 return multiValue ?
64 new CharacterMultiProperty("testCharacter", "Test character property", new Character[] {'a', 'b', 'c'}, 1.0f, delimiter) :
65 new CharacterProperty("testCharacter", "Test character property", 'a', 1.0f);
66 }
67
68
69
70
71
72
73
74
75 protected PropertyDescriptor createBadProperty(boolean multiValue) {
76
77 return multiValue ?
78 new CharacterMultiProperty("testCharacter", "Test character property", new Character[] {'a', 'b', 'c'}, 1.0f, delimiter) :
79 new CharacterProperty("", "Test character property", 'a', 1.0f);
80 }
81
82 public static junit.framework.Test suite() {
83 return new junit.framework.JUnit4TestAdapter(CharacterPropertyTest.class);
84 }
85 }