public int encodedLength()
    {
        if (presence() == CONSTANT)
        {
            return 0;
        }

        if (varLen)
        {
            return Token.VARIABLE_LENGTH;
        }

        return primitiveType.size() * length;
    }
@Test
    void shouldReturnCorrectSizeForPrimitiveTypes() throws Exception
    {
        final String testXmlString =
            "<types>" +
            "    <type name=\"testTypeChar\" primitiveType=\"char\"/>" +
            "    <type name=\"testTypeInt8\" primitiveType=\"int8\"/>" +
            "    <type name=\"testTypeInt16\" primitiveType=\"int16\"/>" +
            "    <type name=\"testTypeInt32\" primitiveType=\"int32\"/>" +
            "    <type name=\"testTypeInt64\" primitiveType=\"int64\"/>" +
            "    <type name=\"testTypeUInt8\" primitiveType=\"uint8\"/>" +
            "    <type name=\"testTypeUInt16\" primitiveType=\"uint16\"/>" +
            "    <type name=\"testTypeUInt32\" primitiveType=\"uint32\"/>" +
            "    <type name=\"testTypeUInt64\" primitiveType=\"uint64\"/>" +
            "    <type name=\"testTypeFloat\" primitiveType=\"float\"/>" +
            "    <type name=\"testTypeDouble\" primitiveType=\"double\"/>" +
            "</types>";

        final Map<String, Type> map = parseTestXmlWithMap("/types/type", testXmlString);

        assertThat(map.get("testTypeChar").encodedLength(), is(1));
        assertThat(map.get("testTypeInt8").encodedLength(), is(1));
        assertThat(map.get("testTypeInt32").encodedLength(), is(4));
        assertThat(map.get("testTypeInt64").encodedLength(), is(8));
        assertThat(map.get("testTypeUInt8").encodedLength(), is(1));
        assertThat(map.get("testTypeUInt16").encodedLength(), is(2));
        assertThat(map.get("testTypeUInt32").encodedLength(), is(4));
        assertThat(map.get("testTypeUInt64").encodedLength(), is(8));
        assertThat(map.get("testTypeFloat").encodedLength(), is(4));
        assertThat(map.get("testTypeDouble").encodedLength(), is(8));
    }