use of com.github.javaparser.ast.visitor.ObjectIdentityEqualsVisitor in project javaparser by javaparser.
the class VisitorListTest method visitorListRemoveAll.
@Test
public void visitorListRemoveAll() {
List<CompilationUnit> list = new ArrayList<>();
list.add(JavaParser.parse("class X{}"));
list.add(JavaParser.parse("class X{}"));
VisitorList<CompilationUnit> vList = new VisitorList<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
vList.addAll(list);
vList.removeAll(list);
assertTrue(vList.size() == 0);
}
use of com.github.javaparser.ast.visitor.ObjectIdentityEqualsVisitor in project javaparser by javaparser.
the class VisitorListTest method visitorAddAll.
@Test
public void visitorAddAll() {
List<CompilationUnit> list = new ArrayList<>();
list.add(JavaParser.parse("class X{}"));
list.add(JavaParser.parse("class X{}"));
VisitorList<CompilationUnit> vList = new VisitorList<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
vList.addAll(list);
for (int i = 0; i < list.size(); i++) assertEquals(list.get(i), vList.get(i));
}
use of com.github.javaparser.ast.visitor.ObjectIdentityEqualsVisitor in project javaparser by javaparser.
the class VisitorListTest method visitorAddAllAtIndex.
@Test
public void visitorAddAllAtIndex() {
List<CompilationUnit> list = new ArrayList<>();
list.add(JavaParser.parse("class X{}"));
list.add(JavaParser.parse("class Y{}"));
VisitorList<CompilationUnit> vList = new VisitorList<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
vList.add(JavaParser.parse("class A{}"));
vList.add(JavaParser.parse("class B{}"));
vList.addAll(2, list);
vList.add(JavaParser.parse("class C{}"));
for (int i = 0; i < list.size(); i++) assertEquals(list.get(i), vList.get(2 + i));
}
use of com.github.javaparser.ast.visitor.ObjectIdentityEqualsVisitor in project javaparser by javaparser.
the class VisitorListTest method visitorListToArray.
@Test
public void visitorListToArray() {
List<CompilationUnit> list = new ArrayList<>();
list.add(JavaParser.parse("class X{}"));
list.add(JavaParser.parse("class X{}"));
List<CompilationUnit> vList = new VisitorList<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
vList.addAll(list);
for (CompilationUnit u : vList.toArray(new CompilationUnit[2])) assertTrue(vList.contains(u));
}
use of com.github.javaparser.ast.visitor.ObjectIdentityEqualsVisitor in project javaparser by javaparser.
the class VisitorListTest method visitorListSubList.
@Test
public void visitorListSubList() {
VisitorList<CompilationUnit> list = new VisitorList<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
list.add(JavaParser.parse("class X{}"));
list.add(JavaParser.parse("class X{}"));
list.add(JavaParser.parse("class X{}"));
list.add(JavaParser.parse("class X{}"));
assertTrue(list.size() == 4);
List<CompilationUnit> subLst = list.subList(1, 3);
assertTrue(subLst.size() == 2);
subLst.add(JavaParser.parse("class X{}"));
assertTrue(subLst.size() == 3);
assertTrue(list.size() == 5);
}
Aggregations