use of com.github.javaparser.ast.visitor.ObjectIdentityHashCodeVisitor in project javaparser by javaparser.
the class VisitorSetTest method visitorSetToArray.
@Test
public void visitorSetToArray() {
List<CompilationUnit> list = new ArrayList<>();
list.add(JavaParser.parse("class X{}"));
list.add(JavaParser.parse("class X{}"));
Set<CompilationUnit> set = new VisitorSet<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
set.addAll(list);
for (CompilationUnit u : set.toArray(new CompilationUnit[2])) assertTrue(set.contains(u));
}
use of com.github.javaparser.ast.visitor.ObjectIdentityHashCodeVisitor in project javaparser by javaparser.
the class VisitorSetTest method objectIdentityEqualsDoesShallowCompare.
@Test
public void objectIdentityEqualsDoesShallowCompare() {
Set<CompilationUnit> set = new VisitorSet<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
set.add(JavaParser.parse("class X{}"));
set.add(JavaParser.parse("class X{}"));
assertEquals(2, set.size());
}
use of com.github.javaparser.ast.visitor.ObjectIdentityHashCodeVisitor in project javaparser by javaparser.
the class VisitorMapTest method objectIdentityEqualsDoesShallowCompare.
@Test
public void objectIdentityEqualsDoesShallowCompare() {
CompilationUnit x1 = JavaParser.parse("class X{}");
CompilationUnit x2 = JavaParser.parse("class X{}");
Map<CompilationUnit, Integer> map = new VisitorMap<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
map.put(x1, 1);
map.put(x2, 2);
assertEquals(2, map.size());
}
use of com.github.javaparser.ast.visitor.ObjectIdentityHashCodeVisitor in project javaparser by javaparser.
the class VisitorMapTest method remove.
@Test
public void remove() {
CompilationUnit x1 = JavaParser.parse("class X{}");
VisitorMap<CompilationUnit, Integer> map = new VisitorMap<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
map.put(x1, 1);
assertTrue(map.containsKey(x1));
map.remove(x1);
assertFalse(map.containsKey(x1));
}
Aggregations