blob: 506566984ef151a1d1aa2e8eedb659068ebdf6c6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
package com.github.javaparser.ast.visitor;
import com.github.javaparser.JavaParser;
import com.github.javaparser.ast.CompilationUnit;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
public class NoCommentHashCodeVisitorTest {
@Test
public void testEquals() {
CompilationUnit p1 = JavaParser.parse("class X { }");
CompilationUnit p2 = JavaParser.parse("class X { }");
assertEquals(p1.hashCode(), p2.hashCode());
}
@Test
public void testEqualsWithDifferentComments() {
CompilationUnit p1 = JavaParser.parse("/* a */ class X { /** b */} //c");
CompilationUnit p2 = JavaParser.parse("/* b */ class X { } //c");
assertEquals(p1.hashCode(), p2.hashCode());
assertEquals(p1.getComments().size(), 3);
assertEquals(p2.getComments().size(), 2);
}
@Test
public void testNotEquals() {
CompilationUnit p1 = JavaParser.parse("class X { }");
CompilationUnit p2 = JavaParser.parse("class Y { }");
assertNotEquals(p1.hashCode(), p2.hashCode());
}
}
|