Skip to content

Commit 1b77ca6

Browse files
committed
added tests
1 parent 9756e7a commit 1b77ca6

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

jbbp/src/test/java/com/igormaznitsa/jbbp/compiler/conversion/JBBPToJBBPToJava6ConverterCompilationTest.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,27 @@ public void testForceAbstract() throws Exception {
5656
assertTrue(JBBPToJava6Converter.makeBuilder(parser).setMainClassName(CLASS_NAME).setDoMainClassAbstract(true).build().convert().contains("abstract"));
5757
}
5858

59+
@Test
60+
public void testMapSubstructToSuperclassesInterface() throws Exception {
61+
final JBBPParser parser = JBBPParser.prepare("a { b { c [_] { byte d;}} }");
62+
final String text = JBBPToJava6Converter.makeBuilder(parser)
63+
.setMainClassName(CLASS_NAME)
64+
.setAddGettersSetters(true)
65+
.setMapSubClassesSuperclasses(
66+
makeMap(
67+
"a.b","com.igormaznitsa.Impl",
68+
"a.b.c", "com.igormaznitsa.Impl2"
69+
)
70+
)
71+
.build()
72+
.convert();
73+
assertTrue(text.contains("public static class B extends com.igormaznitsa.Impl"));
74+
assertTrue(text.contains("public static class C extends com.igormaznitsa.Impl2"));
75+
assertTrue(text.contains("public B getB() { return this.b;}"));
76+
assertTrue(text.contains("public C [] getC() { return this.c;}"));
77+
System.out.println(text);
78+
}
79+
5980
@Test
6081
public void testMapSubstructToInterface() throws Exception {
6182
final JBBPParser parser = JBBPParser.prepare("a { b { c [_] { byte d;}} }");
@@ -312,4 +333,20 @@ public JBBPAbstractField readCustomFieldType(JBBPBitInputStream in, JBBPBitOrder
312333
assertCompilation(makeSources(parser, null, true));
313334
}
314335

336+
@Test
337+
public void testStaticInternalClasses() throws Exception {
338+
String text = JBBPToJava6Converter.makeBuilder(JBBPParser.prepare("somestruct {int a;}"))
339+
.setMainClassPackage(PACKAGE_NAME).setMainClassName(CLASS_NAME)
340+
.build().convert();
341+
assertTrue(text.contains(" static class SOMESTRUCT {"));
342+
343+
text = JBBPToJava6Converter.makeBuilder(JBBPParser.prepare("somestruct {int a;}"))
344+
.setMainClassPackage(PACKAGE_NAME).setMainClassName(CLASS_NAME)
345+
.doInternalClassesNonStatic()
346+
.build().convert();
347+
assertFalse(text.contains(" static class SOMESTRUCT {"));
348+
assertTrue(text.contains(" class SOMESTRUCT {"));
349+
}
350+
351+
315352
}

0 commit comments

Comments
 (0)