Improve code coverage
This commit is contained in:
parent
78a1cb5320
commit
9c3adbdba3
|
|
@ -43,10 +43,12 @@ public final class Utils
|
|||
/** Map of all created regular expressions **/
|
||||
private static final Map CREATED_RES = new HashMap();
|
||||
|
||||
///CLOVER:ON
|
||||
/** stop instances being created **/
|
||||
private Utils()
|
||||
{
|
||||
}
|
||||
///CLOVER:OFF
|
||||
|
||||
/**
|
||||
* Returns whether the specified string contains only whitespace up to the
|
||||
|
|
@ -129,21 +131,6 @@ public final class Utils
|
|||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Conditionally add a String to a set of properties.
|
||||
* @param aProps the Properties to add to
|
||||
* @param aKey the key to add the property under
|
||||
* @param aValue if not null, then the value to add the property with
|
||||
*/
|
||||
public static void addObjectString(Properties aProps,
|
||||
String aKey,
|
||||
Object aValue)
|
||||
{
|
||||
if (aValue != null) {
|
||||
aProps.put(aKey, aValue.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the contents of a file in a String array.
|
||||
* @return the lines in the file
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.puppycrawl.tools.checkstyle;
|
|||
import java.util.Properties;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.commons.beanutils.ConversionException;
|
||||
import org.apache.regexp.RE;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
|
||||
|
|
@ -100,6 +101,17 @@ public class UtilsTest
|
|||
}
|
||||
}
|
||||
|
||||
public void testBadRegex()
|
||||
{
|
||||
try {
|
||||
Utils.createRE("[");
|
||||
fail("expected to get conversion exception");
|
||||
}
|
||||
catch (ConversionException e) {
|
||||
; // what is expected
|
||||
}
|
||||
}
|
||||
|
||||
private Properties initProperties()
|
||||
{
|
||||
final Properties props = new Properties();
|
||||
|
|
|
|||
Loading…
Reference in New Issue