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