From d5239ecb8415c380748adba56e1dbc88e27da566 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Thu, 1 Mar 2018 12:01:44 +0100 Subject: [PATCH] IG: add more testcases & formatting (IDEA-CR-29673) --- .../UnnecessaryBoxingInspection.java | 4 +-- .../migration/UnnecessaryBoxingFixTest.java | 28 +++++++++---------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/UnnecessaryBoxingInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/UnnecessaryBoxingInspection.java index 4679b524e9a4..f40d287e9d1d 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/UnnecessaryBoxingInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/UnnecessaryBoxingInspection.java @@ -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)) { diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/migration/UnnecessaryBoxingFixTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/migration/UnnecessaryBoxingFixTest.java index a2d0f96aebe4..a073cc06f175 100644 --- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/migration/UnnecessaryBoxingFixTest.java +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/migration/UnnecessaryBoxingFixTest.java @@ -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(); }