Skip to content

Commit

Permalink
Corrected logic in in ElementHelper.areEqual around null args and add…
Browse files Browse the repository at this point in the history
…ed tests #487
  • Loading branch information
spmallette committed May 28, 2014
1 parent d5a20f9 commit 97d2e82
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Expand Up @@ -189,6 +189,8 @@ public static void setProperties(final Element element, final Object... keysValu
* @return Whether the two elements are equal
*/
public static boolean areEqual(final Element a, final Object b) {
if (null == a && b != null)
return false;
if (a == b)
return true;
if (null == b)
Expand Down
Expand Up @@ -156,4 +156,34 @@ public void testSetPropertiesVarArgs() {
}

}

public void testAreEqualNullFirstArg() {
Graph graph = new TinkerGraph();
Vertex vertex = graph.addVertex(null);

ElementHelper.areEqual(null, vertex);
}

public void testAreEqualNullSecondArg() {
Graph graph = new TinkerGraph();
Vertex vertex = graph.addVertex(null);

ElementHelper.areEqual(vertex, null);
}

public void testAreEqualValid() {
Graph graph = new TinkerGraph();
Vertex vertex = graph.addVertex(null);

ElementHelper.areEqual(vertex, vertex);
}

public void testAreEqualInvalid() {
Graph graph = new TinkerGraph();
Vertex vertex1 = graph.addVertex(null);
Vertex vertex2 = graph.addVertex(null);

ElementHelper.areEqual(vertex2, vertex1);
}

}

0 comments on commit 97d2e82

Please sign in to comment.