make IG test light

This commit is contained in:
Bas Leijdekkers
2016-06-25 15:53:21 +02:00
parent 54d13e4c42
commit 243eeb0364
3 changed files with 32 additions and 23 deletions
@@ -3,7 +3,7 @@ package com.siyeh.igtest.bugs.math_random_cast_to_int;
public class MathRandomCastToInt {
void foo() {
int runs = (int) Math.random() * 1000000 * 2;
long random = (long) Math.random() * 10;
int runs = (int) <warning descr="'Math.random()' cast to 'int' is always rounded down to '0'">Math.random()</warning> * 1000000 * 2;
long random = (long) <warning descr="'Math.random()' cast to 'int' is always rounded down to '0'">Math.random()</warning> * 10;
}
}
@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>MathRandomCastToInt.java</file>
<line>6</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'Math.random()' cast to 'int'</problem_class>
<description>&lt;code&gt;Math.random()&lt;/code&gt; cast to 'int' is always rounded down to '0' #loc</description>
</problem>
<problem>
<file>MathRandomCastToInt.java</file>
<line>7</line>
<description>&lt;code&gt;Math.random()&lt;/code&gt; cast to 'int' is always rounded down to '0' #loc</description>
</problem>
</problems>
@@ -1,10 +1,36 @@
/*
* 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.
*/
package com.siyeh.ig.bugs;
import com.siyeh.ig.IGInspectionTestCase;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.siyeh.ig.LightInspectionTestCase;
import org.jetbrains.annotations.Nullable;
public class MathRandomCastToIntInspectionTest extends IGInspectionTestCase {
/**
* @author Bas Leijdekkers
*/
public class MathRandomCastToIntInspectionTest extends LightInspectionTestCase {
public void test() throws Exception {
doTest("com/siyeh/igtest/bugs/math_random_cast_to_int", new MathRandomCastToIntInspection());
public void testMathRandomCastToInt() {
doTest();
}
@Nullable
@Override
protected InspectionProfileEntry getInspection() {
return new MathRandomCastToIntInspection();
}
}