use of spoon.test.position.testclasses.FooClazz in project spoon by INRIA.
the class PositionTest method testPositionClass.
@Test
public void testPositionClass() throws Exception {
final Factory build = build(new File("src/test/java/spoon/test/position/testclasses/"));
final CtType<FooClazz> foo = build.Type().get(FooClazz.class);
String classContent = getClassContent(foo);
BodyHolderSourcePosition position = (BodyHolderSourcePosition) foo.getPosition();
assertEquals(4, position.getLine());
assertEquals(6, position.getEndLine());
assertEquals(42, position.getSourceStart());
assertEquals(79, position.getSourceEnd());
assertEquals("@Deprecated\n" + "public class FooClazz {\n" + "\n" + "}", contentAtPosition(classContent, position));
assertEquals("{\n\n}", contentAtPosition(classContent, position.getBodyStart(), position.getBodyEnd()));
// this specifies that getLine starts at name (and not at Javadoc or annotation)
final CtType<FooClazz> foo2 = build.Type().get(FooClazz2.class);
assertEquals(42, foo2.getPosition().getSourceStart());
assertEquals(4, foo2.getPosition().getLine());
assertEquals(4, foo2.getPosition().getEndLine());
assertEquals("FooClazz", contentAtPosition(classContent, position.getNameStart(), position.getNameEnd()));
assertEquals("public", contentAtPosition(classContent, position.getModifierSourceStart(), position.getModifierSourceEnd()));
}
Aggregations