use of spoon.test.position.testclasses.FooInterface in project spoon by INRIA.
the class PositionTest method testPositionInterface.
@Test
public void testPositionInterface() throws Exception {
final Factory build = build(new File("src/test/java/spoon/test/position/testclasses/"));
final CtType<FooInterface> foo = build.Type().get(FooInterface.class);
String classContent = getClassContent(foo);
BodyHolderSourcePosition position = (BodyHolderSourcePosition) foo.getPosition();
assertEquals(7, position.getLine());
assertEquals(9, position.getEndLine());
assertEquals(96, position.getSourceStart());
assertEquals(169, position.getSourceEnd());
assertEquals("@Deprecated\n" + "@InnerAnnot(value=\"machin\")\n" + "public interface FooInterface {\n" + "\n" + "}", contentAtPosition(classContent, position));
assertEquals("{\n\n}", contentAtPosition(classContent, position.getBodyStart(), position.getBodyEnd()));
assertEquals("FooInterface", contentAtPosition(classContent, position.getNameStart(), position.getNameEnd()));
assertEquals("public", contentAtPosition(classContent, position.getModifierSourceStart(), position.getModifierSourceEnd()));
{
SourcePosition annPosition = foo.getAnnotations().get(0).getPosition();
assertEquals("@Deprecated", contentAtPosition(classContent, annPosition.getSourceStart(), annPosition.getSourceEnd()));
}
{
SourcePosition annPosition = foo.getAnnotations().get(1).getPosition();
assertEquals("@InnerAnnot(value=\"machin\")", contentAtPosition(classContent, annPosition.getSourceStart(), annPosition.getSourceEnd()));
}
}
Aggregations