Skip to content

Commit

Permalink
Fix language tests with polymorphic allocator
Browse files Browse the repository at this point in the history
  • Loading branch information
Mi-La committed Sep 20, 2023
1 parent 3da9b3a commit 01327aa
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "zserio/CppRuntimeException.h"

#include "enumeration_types/deprecated_enum_item/Traffic.h"
#include "enumeration_types/deprecated_enum_item/AllocatorType.h"

using namespace zserio::literals;

Expand All @@ -15,6 +16,8 @@ namespace enumeration_types
namespace deprecated_enum_item
{

using allocator_type = AllocatorType::allocator_type;

class DeprecatedEnumItemTest : public ::testing::Test
{
protected:
Expand Down Expand Up @@ -152,7 +155,7 @@ TEST_F(DeprecatedEnumItemTest, writeRead)

TEST_F(DeprecatedEnumItemTest, enumTypeInfo)
{
const auto& typeInfo = zserio::enumTypeInfo<Traffic>();
const auto& typeInfo = zserio::enumTypeInfo<Traffic, allocator_type>();

ASSERT_EQ(4, typeInfo.getEnumItems().size());

Expand Down
5 changes: 4 additions & 1 deletion test/language/enumeration_types/cpp/RemovedEnumItemTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "zserio/CppRuntimeException.h"

#include "enumeration_types/removed_enum_item/Traffic.h"
#include "enumeration_types/removed_enum_item/AllocatorType.h"

using namespace zserio::literals;

Expand All @@ -13,6 +14,8 @@ namespace enumeration_types
namespace removed_enum_item
{

using allocator_type = AllocatorType::allocator_type;

class RemovedEnumItemTest : public ::testing::Test
{
protected:
Expand Down Expand Up @@ -121,7 +124,7 @@ TEST_F(RemovedEnumItemTest, write)

TEST_F(RemovedEnumItemTest, enumTypeInfo)
{
const auto& typeInfo = zserio::enumTypeInfo<Traffic>();
const auto& typeInfo = zserio::enumTypeInfo<Traffic, allocator_type>();

ASSERT_EQ(4, typeInfo.getEnumItems().size());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ enum uint8 Traffic
LIGHT,
MID
};

struct AllocatorType // empty just to get allocator_type typedef in the test
{};
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ enum uint8 Traffic
LIGHT,
MID
};

struct AllocatorType // empty just to get allocator_type typedef in the test
{};
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ namespace structure_types
namespace structure_with_removed_enum_item_field
{

using allocator_type = StructureWithRemovedEnumItemField::allocator_type;
using string_type = zserio::string<allocator_type>;

class StructureWithRemovedEnumItemFieldTest : public ::testing::Test
{
protected:
Expand Down Expand Up @@ -57,7 +60,7 @@ TEST_F(StructureWithRemovedEnumItemFieldTest, writeRemovedException)
TEST_F(StructureWithRemovedEnumItemFieldTest, toJsonString)
{
StructureWithRemovedEnumItemField structureWithRemovedEnumItemField(Enumeration::ZSERIO_REMOVED_REMOVED);
std::string json = zserio::toJsonString(structureWithRemovedEnumItemField);
string_type json = zserio::toJsonString(structureWithRemovedEnumItemField);
ASSERT_EQ("{\n \"enumeration\": \"REMOVED\"\n}", json);
}

Expand Down

0 comments on commit 01327aa

Please sign in to comment.