1 package net.sourceforge.jenesis4java.util;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import net.sourceforge.jenesis4java.CodeWriter;
26 import net.sourceforge.jenesis4java.Declaration;
27 import net.sourceforge.jenesis4java.DocumentationComment;
28 import net.sourceforge.jenesis4java.impl.MCodeWriter;
29 import org.junit.Test;
30
31 import java.io.PrintWriter;
32 import java.io.StringWriter;
33
34 import static net.sourceforge.jenesis4java.util.TestHelper.LS;
35 import static org.junit.Assert.assertNotNull;
36 import static org.junit.Assert.assertSame;
37
38 public abstract class DeclarationBaseTest {
39
40 public abstract Declaration getInstance();
41
42 @Test
43 public void testToCodeReturnsGivenCodeWriter() {
44 Declaration declaration = getInstance();
45
46 CodeWriter cout = new MCodeWriter(new PrintWriter(new StringWriter()));
47 assertSame(cout, declaration.toCode(cout));
48 }
49
50 @Test
51 public void javadoc() {
52 Declaration instance = getInstance();
53 String withoutComment = instance.toString();
54 DocumentationComment comment = instance.javadoc("comment");
55 assertNotNull(comment);
56
57 String expected = "/**" + LS + " * comment" + LS + " */" + LS + withoutComment;
58 CodeGenerationAssertions.assertEqualsIgnoreLineBreaks(expected, instance.toString());
59 }
60
61 }