### Question:
PEStringUtils { public static boolean toBoolean(String value) { try { if (value != null && value.length() > 0 && (value.equalsIgnoreCase("true") || value.equalsIgnoreCase(PEConstants.YES) || value.equalsIgnoreCase("on") || Integer.parseInt(value) > 0)) return true; } catch (NumberFormatException nfe) { } return false; } private  PEStringUtils(); static String buildPath(String dir, String sep, String name); static StringBuffer toString(StringBuffer sb, String name, Collection<? extends Object> values); static StringBuffer toArrayString(StringBuffer sb, Collection<? extends Object> values); static String toString(String name, Collection<? extends Object> values); static String toString(Class<T> theClass, Collection<? extends Object> values); static StringBuffer toString(StringBuffer sb, String name, Map<K, V> values); static String toString(String name, Map<K, V> values); static String[] toArray(Collection<String> values); static String trimToInt(final String numeric); static String normalizePrefix(String prefix); static String toString(Throwable e); static Pattern buildSQLPattern(String likeExpr); static String singleQuote(final String value); static boolean isQuoted(final String value); static String dequote(final String in); static String escapeSingleQuoteIfNecessary(String t); static boolean toBoolean(String value); static boolean isHexNumber(final String value); static String getIndented(final String value); static String getIndented(final String value, final int numIndents); static String getIndented(final String value, final String indent, final int numIndents); static String buildIndent(final int numIndents); static String buildIndent(final String indent, final int numIndents); static final String FILE_SEP; }### Answer:
@Test public void toBooleanTest() { String[][] testValues = { { "true", "true" }, { "True", "true" }, { "TRUE", "true" }, { "truE", "true" }, { "on", "true" }, { "On", "true" }, { "ON", "true" }, { "oN", "true" }, { "yes", "true" }, { "Yes", "true" }, { "YES", "true" }, { "yEs", "true" }, { "1", "true" }, { "11", "true" }, { "23", "true" }, { "0", "false" }, { "-0", "false" }, { "-1", "false" }, { "-10", "false" }, { null, "false" }, { "false", "false" }, { "False", "false" }, { "faLse", "false" }, { "falsely", "false" }, { "off", "false" }, { "Off", "false" }, { "OFF", "false" }, { "oFf", "false" }, { "offfff", "false" }, { "Yessir", "false" }, { "YESmostly", "false" }, }; for (String[] testValue : testValues) { String string = testValue[0]; boolean expected = Boolean.parseBoolean(testValue[1]); assertEquals("Should find the right 'boolean' for value '" + string + "'", expected, PEStringUtils.toBoolean(string)); } }