Skip to content

Commit

Permalink
[C] Check for specialised null value when generated enum. PR #889.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjpt777 committed Feb 11, 2022
1 parent 71bb045 commit 595d73c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
5 changes: 4 additions & 1 deletion sbe-tool/src/test/c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,23 @@ find_package(Java REQUIRED)

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

set(GENERATED_CODECS
${C_CODEC_TARGET_DIR}
)

add_custom_command(
OUTPUT ${GENERATED_CODECS}
DEPENDS sbe-jar ${SBE_JAR} ${CODE_GENERATION_SCHEMA} ${GROUP_WITH_DATA_SCHEMA}
DEPENDS sbe-jar ${SBE_JAR} ${CODE_GENERATION_SCHEMA} ${GROUP_WITH_DATA_SCHEMA} ${ISSUE889_SCHEMA}
COMMAND
${Java_JAVA_EXECUTABLE}
-Dsbe.output.dir=${C_CODEC_TARGET_DIR}
-Dsbe.target.language="C"
-jar ${SBE_JAR}
${CODE_GENERATION_SCHEMA}
${GROUP_WITH_DATA_SCHEMA}
${ISSUE889_SCHEMA}
)

add_custom_target(c_codecs DEPENDS ${GENERATED_CODECS})
Expand All @@ -58,6 +60,7 @@ add_custom_target(c_codecs DEPENDS ${GENERATED_CODECS})
sbe_test(BoundsCheckTest c_codecs)
sbe_test(CodeGenTest c_codecs)
sbe_test(GroupWithDataTest c_codecs)
sbe_test(Issue889Test c_codecs)

# Compile a dummy C source to test C compliance of generated headers.
add_executable(CComplianceTest CComplianceTest.c)
Expand Down
31 changes: 31 additions & 0 deletions sbe-tool/src/test/c/Issue889Test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2013-2022 Real Logic Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <gtest/gtest.h>

#include "issue889/lotType.h"

class Issue889Test : public testing::Test
{
};

TEST_F(Issue889Test, shouldGenerateSpecalisedNullValue)
{
issue889_lotType lot_type;

EXPECT_TRUE(issue889_lotType_get(0, &lot_type));
EXPECT_EQ(lot_type, issue889_lotType::issue889_lotType_NULL_VALUE);
}
3 changes: 2 additions & 1 deletion sbe-tool/src/test/cpp/Issue889Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
* limitations under the License.
*/

#include "gtest/gtest.h"
#include <gtest/gtest.h>

#include "issue889/LotType.h"

using namespace issue889;
Expand Down

0 comments on commit 595d73c

Please sign in to comment.