1 package test.net.sourceforge.pmd.rules;
2
3 import net.sourceforge.pmd.PMD;
4 import net.sourceforge.pmd.rules.SimplifyBooleanReturnsRule;
5
6 public class SimplifyBooleanReturnsRuleTest extends RuleTst {
7
8 private static final String TEST1 =
9 "public class SimplifyBooleanReturns1 {" + PMD.EOL +
10 " public void foo() { " + PMD.EOL +
11 " if (true) {" + PMD.EOL +
12 " return true;" + PMD.EOL +
13 " } else {" + PMD.EOL +
14 " return false;" + PMD.EOL +
15 " }" + PMD.EOL +
16 " }" + PMD.EOL +
17 "}";
18
19 private static final String TEST2 =
20 "public class SimplifyBooleanReturns2 {" + PMD.EOL +
21 " public boolean foo() { " + PMD.EOL +
22 " if (true) " + PMD.EOL +
23 " return true;" + PMD.EOL +
24 " else " + PMD.EOL +
25 " return false;" + PMD.EOL +
26 " }" + PMD.EOL +
27 "}";
28
29 private static final String TEST3 =
30 "public class SimplifyBooleanReturns3 {" + PMD.EOL +
31 " public Object foo() { " + PMD.EOL +
32 " if (!true) {" + PMD.EOL +
33 " return null;" + PMD.EOL +
34 " } else {}" + PMD.EOL +
35 " return null;" + PMD.EOL +
36 " }" + PMD.EOL +
37 "}";
38
39 public void test1() throws Throwable {
40 runTestFromString(TEST1, 1, new SimplifyBooleanReturnsRule());
41 }
42 public void test2() throws Throwable {
43 runTestFromString(TEST2, 1, new SimplifyBooleanReturnsRule());
44 }
45 public void test3() throws Throwable {
46 runTestFromString(TEST3, 0, new SimplifyBooleanReturnsRule());
47 }
48 }
This page was automatically generated by Maven