Lines 54-60
Link Here
|
54 |
super(name); |
54 |
super(name); |
55 |
} |
55 |
} |
56 |
|
56 |
|
57 |
public void testContainsForIndexOf1() throws Exception { |
57 |
public void testContainsForIndexOf_EqualsMinusOne() throws Exception { |
58 |
HintTest.create() |
58 |
HintTest.create() |
59 |
.input("package test;\n" + |
59 |
.input("package test;\n" + |
60 |
"public class Test {\n" + |
60 |
"public class Test {\n" + |
Lines 73-76
Link Here
|
73 |
" }\n" + |
73 |
" }\n" + |
74 |
"}\n"); |
74 |
"}\n"); |
75 |
} |
75 |
} |
|
|
76 |
public void testContainsForIndexOf_NotEqualsOne() throws Exception { |
77 |
HintTest.create() |
78 |
.input("package test;\n" + |
79 |
"public class Test {\n" + |
80 |
" private boolean test(String str) {\n" + |
81 |
" return str.indexOf(\"sub\") != (-1);\n" + |
82 |
" }\n" + |
83 |
"}\n") |
84 |
.run(Tiny.class) |
85 |
.findWarning("3:15-3:41:verifier:" + Bundle.FIX_containsForIndexOf()) |
86 |
.applyFix() |
87 |
.assertCompilable() |
88 |
.assertOutput("package test;\n" + |
89 |
"public class Test {\n" + |
90 |
" private boolean test(String str) {\n" + |
91 |
" return str.contains(\"sub\");\n" + |
92 |
" }\n" + |
93 |
"}\n"); |
76 |
} |
94 |
} |
|
|
95 |
public void testContainsForIndexOf_GreaterThanMinusOne() throws Exception { |
96 |
HintTest.create() |
97 |
.input("package test;\n" + |
98 |
"public class Test {\n" + |
99 |
" private boolean test(String str) {\n" + |
100 |
" return str.indexOf(\"sub\") > (-1);\n" + |
101 |
" }\n" + |
102 |
"}\n") |
103 |
.run(Tiny.class) |
104 |
.findWarning("3:15-3:40:verifier:" + Bundle.FIX_containsForIndexOf()) |
105 |
.applyFix() |
106 |
.assertCompilable() |
107 |
.assertOutput("package test;\n" + |
108 |
"public class Test {\n" + |
109 |
" private boolean test(String str) {\n" + |
110 |
" return str.contains(\"sub\");\n" + |
111 |
" }\n" + |
112 |
"}\n"); |
113 |
} |
114 |
public void testContainsForIndexOf_GreaterThanOrEqualZero() throws Exception { |
115 |
HintTest.create() |
116 |
.input("package test;\n" + |
117 |
"public class Test {\n" + |
118 |
" private boolean test(String str) {\n" + |
119 |
" return str.indexOf(\"sub\") >= (0);\n" + |
120 |
" }\n" + |
121 |
"}\n") |
122 |
.run(Tiny.class) |
123 |
.findWarning("3:15-3:40:verifier:" + Bundle.FIX_containsForIndexOf()) |
124 |
.applyFix() |
125 |
.assertCompilable() |
126 |
.assertOutput("package test;\n" + |
127 |
"public class Test {\n" + |
128 |
" private boolean test(String str) {\n" + |
129 |
" return str.contains(\"sub\");\n" + |
130 |
" }\n" + |
131 |
"}\n"); |
132 |
} |
133 |
public void testContainsForIndexOf_EqualsMinusOne_NoParentheses() throws Exception { |
134 |
HintTest.create() |
135 |
.input("package test;\n" + |
136 |
"public class Test {\n" + |
137 |
" private boolean test(String str) {\n" + |
138 |
" return str.indexOf(\"sub\") == -1;\n" + |
139 |
" }\n" + |
140 |
"}\n") |
141 |
.run(Tiny.class) |
142 |
.findWarning("3:15-3:39:verifier:" + Bundle.FIX_containsForIndexOf()) |
143 |
.applyFix() |
144 |
.assertCompilable() |
145 |
.assertOutput("package test;\n" + |
146 |
"public class Test {\n" + |
147 |
" private boolean test(String str) {\n" + |
148 |
" return !str.contains(\"sub\");\n" + |
149 |
" }\n" + |
150 |
"}\n"); |
151 |
} |
152 |
public void testContainsForIndexOf_NotEqualsOne_NoParentheses() throws Exception { |
153 |
HintTest.create() |
154 |
.input("package test;\n" + |
155 |
"public class Test {\n" + |
156 |
" private boolean test(String str) {\n" + |
157 |
" return str.indexOf(\"sub\") != -1;\n" + |
158 |
" }\n" + |
159 |
"}\n") |
160 |
.run(Tiny.class) |
161 |
.findWarning("3:15-3:39:verifier:" + Bundle.FIX_containsForIndexOf()) |
162 |
.applyFix() |
163 |
.assertCompilable() |
164 |
.assertOutput("package test;\n" + |
165 |
"public class Test {\n" + |
166 |
" private boolean test(String str) {\n" + |
167 |
" return str.contains(\"sub\");\n" + |
168 |
" }\n" + |
169 |
"}\n"); |
170 |
} |
171 |
public void testContainsForIndexOf_GreaterThanMinusOne_NoParentheses() throws Exception { |
172 |
HintTest.create() |
173 |
.input("package test;\n" + |
174 |
"public class Test {\n" + |
175 |
" private boolean test(String str) {\n" + |
176 |
" return str.indexOf(\"sub\") > -1;\n" + |
177 |
" }\n" + |
178 |
"}\n") |
179 |
.run(Tiny.class) |
180 |
.findWarning("3:15-3:38:verifier:" + Bundle.FIX_containsForIndexOf()) |
181 |
.applyFix() |
182 |
.assertCompilable() |
183 |
.assertOutput("package test;\n" + |
184 |
"public class Test {\n" + |
185 |
" private boolean test(String str) {\n" + |
186 |
" return str.contains(\"sub\");\n" + |
187 |
" }\n" + |
188 |
"}\n"); |
189 |
} |
190 |
public void testContainsForIndexOf_GreaterThanOrEqualZero_NoParentheses() throws Exception { |
191 |
HintTest.create() |
192 |
.input("package test;\n" + |
193 |
"public class Test {\n" + |
194 |
" private boolean test(String str) {\n" + |
195 |
" return str.indexOf(\"sub\") >= 0;\n" + |
196 |
" }\n" + |
197 |
"}\n") |
198 |
.run(Tiny.class) |
199 |
.findWarning("3:15-3:38:verifier:" + Bundle.FIX_containsForIndexOf()) |
200 |
.applyFix() |
201 |
.assertCompilable() |
202 |
.assertOutput("package test;\n" + |
203 |
"public class Test {\n" + |
204 |
" private boolean test(String str) {\n" + |
205 |
" return str.contains(\"sub\");\n" + |
206 |
" }\n" + |
207 |
"}\n"); |
208 |
} |
209 |
|
210 |
|
211 |
|
212 |
} |