<?xml version="1.0" encoding="UTF-8"?>
<test-data
    xmlns="http://pmd.sourceforge.net/rule-tests"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://pmd.sourceforge.net/rule-tests http://pmd.sourceforge.net/rule-tests_1_0_0.xsd">
    <test-code>
        <description><![CDATA[
failure case
     ]]></description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
 public void bar() {
  if (x != null && foo.getBar().equals(x)) {} 
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
different var, 'tis ok
     ]]></description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
 public void bar() {
  if (x != null && foo.equals(y)) {} 
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
proper usage
     ]]></description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
 public void bar() {
  if (x != null && x.equals(y)) {} 
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
variation of correct usage
     ]]></description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
 public void bar() {
  if (x != null && "Foo".equals(y)) {} 
  if (y.equals(x)) {} 
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
var is not used in equals() call
     ]]></description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
 public void bar() {
  if (c != null && A.b(c).equals(d)) {}
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
[ 1481051 ] false + UnusedNullCheckInEquals
     ]]></description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
 public void bar() {
if(o1!=null && o1[0] != null && o2[0].getName()!=null && o2[0].getName().equals(o1[0].getName()) ){ }
if(o1!=null && o2.equals(o1.getName()) ){ }
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
shouldn't this fail? Yes, it should. Fixed it, so that method calls to equals on variables are considered, too.
     ]]></description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
 public void bar() {
  if (x != null && y.equals(x)) {} 
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
Arrays can't be compared directly but with Arrays.equals().
     ]]></description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
        private static boolean isSame(Object[] a1, Object[] a2) {
                return a1 == a2 || (a1 != null && a2 != null && Arrays.equals(a1, a2));
        }
}
     ]]></code>
    </test-code>
</test-data>
