-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathHeaderWriterTest.java
More file actions
54 lines (46 loc) · 1.63 KB
/
HeaderWriterTest.java
File metadata and controls
54 lines (46 loc) · 1.63 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package qimpp;
import org.junit.*;
import static org.junit.Assert.*;
import java.util.*;
import java.io.ByteArrayOutputStream;
import java.io.File;
import qimpp.HeaderWriter;
import xtc.*;
import xtc.tree.GNode;
import xtc.tree.Node;
import xtc.tree.Visitor;
import xtc.tree.Location;
import xtc.tree.Printer;
import xtc.util.Tool;
import java.io.UnsupportedEncodingException;
/**
* @author QIMPP
*/
public class HeaderWriterTest {
ByteArrayOutputStream out = new ByteArrayOutputStream();
Printer printer = new Printer(out);
@Test
public void writeTypeDeclarationTest() {
GNode foo = GNode.create("Declaration", "Struct", "Foo", null);
GNode bar = GNode.create("Declaration", "Struct", "Bar", null);
GNode declarations = GNode.create("Declarations", foo, bar);
new HeaderWriter(printer).dispatch(declarations);
try {
String output = out.toString("UTF8");
String compare = "struct __Foo;\nstruct __Foo_VT;\nstruct __Bar;\nstruct __Bar_VT;";
assert(output.equals(compare));
}
catch(UnsupportedEncodingException e) {
}
}
@Test
public void writeStructTest() {
GNode modifiers = GNode.create("Modifiers");
GNode express = GNode.create("Expression", GNode.create("PrimaryIdentifier", "\"zebra\""), "\"=\"", GNode.create("StringLiteral", "\"In the room\""));
GNode expressionStatement = GNode.create("ExpressionStatement", express);
GNode block = GNode.create("Block", expressionStatement);
GNode constructor = GNode.create("Constructor", null, block);
GNode cd = GNode.create("ClassDeclaration", modifiers, "Foo", constructor);
//hw.generateHeader(cd);
}
}