Search in sources :

Example 1 with StringWriterOutputManager

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));
}
Also used : IrGenerator(uk.co.real_logic.sbe.xml.IrGenerator) ParserOptions(uk.co.real_logic.sbe.xml.ParserOptions) MessageSchema(uk.co.real_logic.sbe.xml.MessageSchema) StringWriterOutputManager(org.agrona.generation.StringWriterOutputManager) Ir(uk.co.real_logic.sbe.ir.Ir) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Aggregations

StringWriterOutputManager (org.agrona.generation.StringWriterOutputManager)1 StringContains.containsString (org.hamcrest.core.StringContains.containsString)1 Test (org.junit.Test)1 Ir (uk.co.real_logic.sbe.ir.Ir)1 IrGenerator (uk.co.real_logic.sbe.xml.IrGenerator)1 MessageSchema (uk.co.real_logic.sbe.xml.MessageSchema)1 ParserOptions (uk.co.real_logic.sbe.xml.ParserOptions)1