Skip to content

Commit

Permalink
More tests for VisitorMap
Browse files Browse the repository at this point in the history
  • Loading branch information
Lebouc Romain committed Aug 24, 2017
1 parent bafd397 commit afa8c65
Showing 1 changed file with 33 additions and 0 deletions.
Expand Up @@ -10,6 +10,7 @@
import java.util.Map;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class VisitorMapTest {
@Test
Expand All @@ -33,4 +34,36 @@ public void objectIdentityEqualsDoesShallowCompare() {
normalMap.put(x2, 2);
assertEquals(2, normalMap.size());
}

@Test
public void visitorMapGet(){
CompilationUnit x1 = JavaParser.parse("class X{}");

Map<CompilationUnit, Integer> normalMap = new VisitorMap<>(new HashMap<>(), new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
normalMap.put(x1, 1);
assertEquals(1, (int)normalMap.get(x1));
}

@Test
public void visitorMapContainsKey(){
CompilationUnit x1 = JavaParser.parse("class X{}");

Map<CompilationUnit, Integer> normalMap = new VisitorMap<>(new HashMap<>(), new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
normalMap.put(x1, 1);
assertTrue(normalMap.containsKey(x1));
}

@Test
public void visitorMapPutAll(){
CompilationUnit x1 = JavaParser.parse("class X{}");
CompilationUnit x2 = JavaParser.parse("class Y{}");
Map<CompilationUnit, Integer> normalMap = new HashMap<>();
normalMap.put(x1, 1);
normalMap.put(x2, 2);
Map<CompilationUnit, Integer> visitorMap = new VisitorMap<>(new HashMap<>(), new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
visitorMap.putAll(normalMap);
assertEquals(2, visitorMap.size());
}


}

0 comments on commit afa8c65

Please sign in to comment.