Skip to content

Commit 595d73c

Browse files
committed
[C] Check for specialised null value when generated enum. PR aeron-io#889.
1 parent 71bb045 commit 595d73c

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

sbe-tool/src/test/c/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,23 @@ find_package(Java REQUIRED)
3535

3636
set(CODE_GENERATION_SCHEMA ${CODEC_SCHEMA_DIR}/code-generation-schema.xml)
3737
set(GROUP_WITH_DATA_SCHEMA ${CODEC_SCHEMA_DIR}/group-with-data-schema.xml)
38+
set(ISSUE889_SCHEMA ${CODEC_SCHEMA_DIR}/issue889.xml)
3839

3940
set(GENERATED_CODECS
4041
${C_CODEC_TARGET_DIR}
4142
)
4243

4344
add_custom_command(
4445
OUTPUT ${GENERATED_CODECS}
45-
DEPENDS sbe-jar ${SBE_JAR} ${CODE_GENERATION_SCHEMA} ${GROUP_WITH_DATA_SCHEMA}
46+
DEPENDS sbe-jar ${SBE_JAR} ${CODE_GENERATION_SCHEMA} ${GROUP_WITH_DATA_SCHEMA} ${ISSUE889_SCHEMA}
4647
COMMAND
4748
${Java_JAVA_EXECUTABLE}
4849
-Dsbe.output.dir=${C_CODEC_TARGET_DIR}
4950
-Dsbe.target.language="C"
5051
-jar ${SBE_JAR}
5152
${CODE_GENERATION_SCHEMA}
5253
${GROUP_WITH_DATA_SCHEMA}
54+
${ISSUE889_SCHEMA}
5355
)
5456

5557
add_custom_target(c_codecs DEPENDS ${GENERATED_CODECS})
@@ -58,6 +60,7 @@ add_custom_target(c_codecs DEPENDS ${GENERATED_CODECS})
5860
sbe_test(BoundsCheckTest c_codecs)
5961
sbe_test(CodeGenTest c_codecs)
6062
sbe_test(GroupWithDataTest c_codecs)
63+
sbe_test(Issue889Test c_codecs)
6164

6265
# Compile a dummy C source to test C compliance of generated headers.
6366
add_executable(CComplianceTest CComplianceTest.c)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2013-2022 Real Logic Limited.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include <gtest/gtest.h>
18+
19+
#include "issue889/lotType.h"
20+
21+
class Issue889Test : public testing::Test
22+
{
23+
};
24+
25+
TEST_F(Issue889Test, shouldGenerateSpecalisedNullValue)
26+
{
27+
issue889_lotType lot_type;
28+
29+
EXPECT_TRUE(issue889_lotType_get(0, &lot_type));
30+
EXPECT_EQ(lot_type, issue889_lotType::issue889_lotType_NULL_VALUE);
31+
}

sbe-tool/src/test/cpp/Issue889Test.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17-
#include "gtest/gtest.h"
17+
#include <gtest/gtest.h>
18+
1819
#include "issue889/LotType.h"
1920

2021
using namespace issue889;

0 commit comments

Comments
 (0)