IG: add more testcases & formatting (IDEA-CR-29673)

This commit is contained in:
Bas Leijdekkers
2018-03-01 12:01:44 +01:00
parent a1ed1a0c86
commit d5239ecb84
2 changed files with 15 additions and 17 deletions
@@ -139,8 +139,8 @@ public class UnnecessaryBoxingInspection extends BaseInspection {
return text + 'L';
}
else if (!text.startsWith("0")) { // no octal & hex
if (unboxedType.equals(PsiType.FLOAT) && (expressionType.equals(PsiType.INT) || (expressionType.equals(PsiType.DOUBLE)) &&
!StringUtil.endsWithIgnoreCase(text, "d"))) {
if (unboxedType.equals(PsiType.FLOAT) &&
(expressionType.equals(PsiType.INT) || expressionType.equals(PsiType.DOUBLE) && !StringUtil.endsWithIgnoreCase(text, "d"))) {
return text + 'f';
}
else if (unboxedType.equals(PsiType.DOUBLE) && expressionType.equals(PsiType.INT)) {
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.siyeh.ig.fixes.migration;
import com.siyeh.InspectionGadgetsBundle;
@@ -80,12 +66,24 @@ public class UnnecessaryBoxingFixTest extends IGQuickFixesTestCase {
"float f = (float) 0x123;");
}
public void testHexDouble() {
doMemberTest(InspectionGadgetsBundle.message("unnecessary.boxing.remove.quickfix"),
"double f = Double./**/valueOf(0x123);",
"double f = (double) 0x123;");
}
public void testOctal() {
doMemberTest(InspectionGadgetsBundle.message("unnecessary.boxing.remove.quickfix"),
"float f = Float.valueOf/**/(0123);",
"float f = (float) 0123;");
}
public void testOctalDouble() {
doMemberTest(InspectionGadgetsBundle.message("unnecessary.boxing.remove.quickfix"),
"double f = Double.valueOf/**/(0123);",
"double f = (double) 0123;");
}
public void testCast() {
doFixTest();
}