[infer][tests] More complete test cases for the models of the Java Integer class

Summary: Originially, there was a missing package declaration meaning that the generated class was ending in a different place. I also added a test for equality of Integer to complement the test of no equality, which could be always true.

Reviewed By: sblackshear

Differential Revision: D4263676

fbshipit-source-id: 86ab0d3
master
Jeremy Dubreil 8 years ago committed by Facebook Github Bot
parent 0972c8d262
commit 7b884144b5

@ -69,6 +69,7 @@ codetoanalyze/java/infer/GuardedByExample.java, void GuardedByExample.writeFBad(
codetoanalyze/java/infer/GuardedByExample.java, void GuardedByExample.writeFBadWrongLock(), 2, UNSAFE_GUARDED_BY_ACCESS, [start of procedure writeFBadWrongLock()]
codetoanalyze/java/infer/HashMapExample.java, int HashMapExample.getOneIntegerWithoutCheck(), 6, NULL_DEREFERENCE, [start of procedure getOneIntegerWithoutCheck()]
codetoanalyze/java/infer/HashMapExample.java, void HashMapExample.getTwoIntegersWithOneCheck(Integer,Integer), 11, NULL_DEREFERENCE, [start of procedure getTwoIntegersWithOneCheck(...),Taking true branch,Taking true branch]
codetoanalyze/java/infer/IntegerExample.java, void IntegerExample.testIntegerEqualsBad(), 6, NULL_DEREFERENCE, [start of procedure testIntegerEqualsBad(),Taking true branch]
codetoanalyze/java/infer/InvokeDynamic.java, int InvokeDynamic.lambda$npeInLambdaBad$1(String,String), 1, NULL_DEREFERENCE, [start of procedure lambda$npeInLambdaBad$1(...)]
codetoanalyze/java/infer/InvokeDynamic.java, void InvokeDynamic.invokeDynamicThenNpeBad(List), 5, NULL_DEREFERENCE, [start of procedure invokeDynamicThenNpeBad(...)]
codetoanalyze/java/infer/NullPointerExceptions.java, String NullPointerExceptions.hashmapNPE(HashMap,Object), 1, NULL_DEREFERENCE, [start of procedure hashmapNPE(...)]

@ -69,6 +69,7 @@ infer/tests/codetoanalyze/java/infer/GuardedByExample.java, void GuardedByExampl
infer/tests/codetoanalyze/java/infer/GuardedByExample.java, void GuardedByExample.writeFBadWrongLock(), 2, UNSAFE_GUARDED_BY_ACCESS, [start of procedure writeFBadWrongLock()]
infer/tests/codetoanalyze/java/infer/HashMapExample.java, int HashMapExample.getOneIntegerWithoutCheck(), 6, NULL_DEREFERENCE, [start of procedure getOneIntegerWithoutCheck()]
infer/tests/codetoanalyze/java/infer/HashMapExample.java, void HashMapExample.getTwoIntegersWithOneCheck(Integer,Integer), 11, NULL_DEREFERENCE, [start of procedure getTwoIntegersWithOneCheck(...),Taking true branch,Taking true branch]
infer/tests/codetoanalyze/java/infer/IntegerExample.java, void IntegerExample.testIntegerEqualsBad(), 6, NULL_DEREFERENCE, [start of procedure testIntegerEqualsBad(),Taking true branch]
infer/tests/codetoanalyze/java/infer/InvokeDynamic.java, int InvokeDynamic.lambda$npeInLambdaBad$1(String,String), 1, NULL_DEREFERENCE, [start of procedure lambda$npeInLambdaBad$1(...)]
infer/tests/codetoanalyze/java/infer/InvokeDynamic.java, void InvokeDynamic.invokeDynamicThenNpeBad(List), 5, NULL_DEREFERENCE, [start of procedure invokeDynamicThenNpeBad(...)]
infer/tests/codetoanalyze/java/infer/NullPointerExceptions.java, String NullPointerExceptions.hashmapNPE(HashMap,Object), 1, NULL_DEREFERENCE, [start of procedure hashmapNPE(...)]

@ -7,11 +7,13 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
package codetoanalyze.java.infer;
import java.util.HashMap;
public class IntegerExample {
private static void testIntegerEquals() {
private static void testIntegerEqualsGood() {
Integer a = new Integer(42);
Integer b = new Integer(42);
Integer c = null;
@ -25,4 +27,26 @@ public class IntegerExample {
}
}
private static void testIntegerEqualsBad() {
Integer a = new Integer(42);
Integer b = new Integer(42);
Integer c = null;
if (a.equals(b)) {
c.intValue();
}
}
private static void testIntegerEqualsFN() {
Integer a = new Integer(42);
Integer b = new Integer(42);
Integer c = null;
if (a == b) {
c.intValue();
}
}
}

@ -144,6 +144,7 @@ codetoanalyze/java/infer/HashMapExample.java, void HashMapExample.putIntegerTwic
codetoanalyze/java/infer/HashMapExample.java, void HashMapExample.putIntegerTwiceThenGetTwice(HashMap), 7, RETURN_VALUE_IGNORED, [start of procedure putIntegerTwiceThenGetTwice(...)]
codetoanalyze/java/infer/HashMapExample.java, void HashMapExample.putIntegerTwiceThenGetTwice(HashMap), 12, RETURN_VALUE_IGNORED, [start of procedure putIntegerTwiceThenGetTwice(...)]
codetoanalyze/java/infer/HashMapExample.java, void HashMapExample.putIntegerTwiceThenGetTwice(HashMap), 13, RETURN_VALUE_IGNORED, [start of procedure putIntegerTwiceThenGetTwice(...)]
codetoanalyze/java/infer/IntegerExample.java, void IntegerExample.testIntegerEqualsBad(), 6, NULL_DEREFERENCE, [start of procedure testIntegerEqualsBad(),Taking true branch]
codetoanalyze/java/infer/InvokeDynamic.java, int InvokeDynamic.lambda$npeInLambdaBad$1(String,String), 1, NULL_DEREFERENCE, [start of procedure lambda$npeInLambdaBad$1(...)]
codetoanalyze/java/infer/InvokeDynamic.java, void InvokeDynamic.invokeDynamicThenNpeBad(List), 5, NULL_DEREFERENCE, [start of procedure invokeDynamicThenNpeBad(...)]
codetoanalyze/java/infer/JunitAssertion.java, void JunitAssertion.consistentAssertion(JunitAssertion$A), 1, PRECONDITION_NOT_MET, [start of procedure consistentAssertion(...),Taking false branch]

Loading…
Cancel
Save