use of org.agrona.generation.StringWriterOutputManager in project simple-binary-encoding by real-logic.
the class ConstantCharArrayTest method shouldGenerateConstCharArrayMethods.
@Test
public void shouldGenerateConstCharArrayMethods() throws Exception {
final ParserOptions options = ParserOptions.builder().stopOnError(true).build();
final MessageSchema schema = parse(TestUtil.getLocalResource("issue505.xml"), options);
final IrGenerator irg = new IrGenerator();
final Ir ir = irg.generate(schema);
final StringWriterOutputManager outputManager = new StringWriterOutputManager();
outputManager.setPackageName(ir.applicableNamespace());
final JavaGenerator generator = new JavaGenerator(ir, BUFFER_NAME, READ_ONLY_BUFFER_NAME, false, false, false, outputManager);
generator.generate();
final String sources = outputManager.getSources().toString();
final String expectedOne = " public byte sourceOne()\n" + " {\n" + " return (byte)67;\n" + " }";
assertThat(sources, containsString(expectedOne));
final String expectedTwo = " public byte sourceTwo()\n" + " {\n" + " return (byte)68;\n" + " }";
assertThat(sources, containsString(expectedTwo));
final String expectedThree = " public String sourceThree()\n" + " {\n" + " return \"EF\";\n" + " }";
assertThat(sources, containsString(expectedThree));
final String expectedFour = " public String sourceFour()\n" + " {\n" + " return \"GH\";\n" + " }";
assertThat(sources, containsString(expectedFour));
}
Aggregations