01: package test.net.sourceforge.pmd.properties;
02:
03: import net.sourceforge.pmd.PropertyDescriptor;
04: import net.sourceforge.pmd.properties.CharacterProperty;
05:
06: /**
07: */
08: public class CharacterPropertyTest extends
09: AbstractPropertyDescriptorTester {
10:
11: private static final char delimiter = '|';
12: private static final char[] charSet = filter(
13: allChars.toCharArray(), delimiter);
14:
15: public CharacterPropertyTest() {
16: super ();
17: }
18:
19: /**
20: * Method createValue.
21: * @param count int
22: * @return Object
23: */
24: protected Object createValue(int count) {
25:
26: if (count == 1)
27: return new Character(randomChar(charSet));
28:
29: Character[] values = new Character[count];
30: for (int i = 0; i < values.length; i++)
31: values[i] = (Character) createValue(1);
32: return values;
33: }
34:
35: /**
36: * Method createProperty.
37: * @param maxCount int
38: * @return PropertyDescriptor
39: */
40: protected PropertyDescriptor createProperty(int maxCount) {
41:
42: return maxCount == 1 ? new CharacterProperty("testCharacter",
43: "Test character property", 'a', 1.0f)
44: : new CharacterProperty("testCharacter",
45: "Test character property", new char[] { 'a',
46: 'b', 'c' }, 1.0f, delimiter);
47: }
48:
49: public static junit.framework.Test suite() {
50: return new junit.framework.JUnit4TestAdapter(
51: CharacterPropertyTest.class);
52: }
53: }
|