<?xml version="1.0" encoding="UTF-8"?>
<test-data>
  <test-code>
    <description>basic test</description>
    <expected-problems>1</expected-problems>
    <code><![CDATA[
public class PrimitiveType {
  public void downCastPrimitiveType() {
    if(i==1) {
    }
  }
}
    ]]></code>
  </test-code>
  <test-code>
    <description>basic test, part2</description>
    <expected-problems>0</expected-problems>
    <code><![CDATA[
public class PrimitiveType {
  public static final int PRIMITIVE_TYPE = 1;
  public void downCastPrimitiveType() {
    if(i==PRIMITIVE_TYPE) {
    }
  }
}
    ]]></code>
  </test-code>
  <test-code>
    <description>allow null literal</description>
    <expected-problems>0</expected-problems>
    <code><![CDATA[
public class MyClass {
  public void myMethod(Object foo) {
    if(foo != null) {
    }
  }
}
    ]]></code>
  </test-code>
  <test-code>
    <description>#1213 AvoidLiteralsInIfCondition -- switch for integer comparison with 0</description>
    <expected-problems>0</expected-problems>
    <code><![CDATA[
public class Foo {
    public void bar() {
        if( ( flags & Flag.IMPORTANT ) != 0 ) {}
        if (aString.indexOf('.') != -1) {}     // magic number -1, by default ignored
    }
}
    ]]></code>
  </test-code>
  <test-code>
    <description>#1213 AvoidLiteralsInIfCondition -- switch for integer comparison with 0.0</description>
    <expected-problems>0</expected-problems>
    <rule-property name="ignoreMagicNumbers">-1,0,0.0</rule-property>
    <code><![CDATA[
public class Foo {
    public void bar() {
        if (aDouble > 0.0) {}                  // magic number 0.0
        if (aDouble >= Double.MIN_VALUE) {}    // preferred approach
    }
}
    ]]></code>
  </test-code>
  <test-code>
    <description>XPath error: An empty sequence is not allowed as the second argument of index-of()</description>
    <expected-problems>0</expected-problems>
    <code><![CDATA[
public class Foo {
    public void bar() {
        if (true && aDouble > 0.0) {
        }
    }
}
      ]]></code>
  </test-code>
</test-data>
