diff --git a/test/language/choice_types/cpp/UInt64ParamChoiceTest.cpp b/test/language/choice_types/cpp/UInt64ParamChoiceTest.cpp index 0161161..d625e60 100644 --- a/test/language/choice_types/cpp/UInt64ParamChoiceTest.cpp +++ b/test/language/choice_types/cpp/UInt64ParamChoiceTest.cpp @@ -52,6 +52,62 @@ TEST_F(UInt64ParamChoiceTest, constructors) } } +TEST_F(UInt64ParamChoiceTest, copyConstructor) +{ + UInt64ParamChoice data; + const VariantA value = 99; + data.emplace(value); + UInt64ParamChoice dataCopy(data); + ASSERT_EQ(dataCopy, data); + + zserio::View view(data, VARIANT_A_SELECTOR); + zserio::View viewCopy(view); + ASSERT_EQ(viewCopy, view); +} + +TEST_F(UInt64ParamChoiceTest, assignmentOperator) +{ + UInt64ParamChoice data; + const VariantA value = 99; + data.emplace(value); + UInt64ParamChoice dataCopy; + dataCopy = data; + ASSERT_EQ(dataCopy, data); + + zserio::View view(data, VARIANT_A_SELECTOR); + zserio::View viewCopy(UInt64ParamChoice{}, VARIANT_B_SELECTOR); + viewCopy = view; + ASSERT_EQ(viewCopy, view); +} + +TEST_F(UInt64ParamChoiceTest, moveConstructor) +{ + UInt64ParamChoice data; + const VariantA value = 99; + data.emplace(value); + UInt64ParamChoice dataMoved(std::move(data)); + ASSERT_EQ(value, zserio::get(dataMoved)); + + zserio::View view(data, VARIANT_A_SELECTOR); + zserio::View viewMoved(std::move(view)); + ASSERT_EQ(value, viewMoved.valueA()); +} + +TEST_F(UInt64ParamChoiceTest, moveAssignmentOperator) +{ + UInt64ParamChoice data; + const VariantA value = 99; + data.emplace(value); + UInt64ParamChoice dataMoved; + dataMoved = std::move(data); + ASSERT_EQ(value, zserio::get(dataMoved)); + + zserio::View view(data, VARIANT_A_SELECTOR); + zserio::View viewMoved(UInt64ParamChoice{}, VARIANT_B_SELECTOR); + viewMoved = std::move(view); + ASSERT_EQ(value, viewMoved.valueA()); +} + TEST_F(UInt64ParamChoiceTest, selector) { UInt64ParamChoice data; diff --git a/test/language/structure_types/cpp/SimpleStructureTest.cpp b/test/language/structure_types/cpp/SimpleStructureTest.cpp index 8743b9f..9c7ee7d 100644 --- a/test/language/structure_types/cpp/SimpleStructureTest.cpp +++ b/test/language/structure_types/cpp/SimpleStructureTest.cpp @@ -211,6 +211,18 @@ TEST_F(SimpleStructureDataTest, stdHash) ASSERT_EQ(hasher(simpleStructure1), hasher(simpleStructure2)); } +TEST_F(SimpleStructureViewTest, assignmentOperator) +{ + const uint8_t numberA = 0x07; + const uint8_t numberB = 0xFF; + const uint8_t numberC = 0x7F; + SimpleStructure simpleStructure(numberA, numberB, numberC); + zserio::View view(simpleStructure); + zserio::View viewCopy(SimpleStructure{0, 0, 0}); + viewCopy = view; + ASSERT_EQ(viewCopy, view); +} + TEST_F(SimpleStructureViewTest, operatorEquality) { SimpleStructure simpleStructure1; diff --git a/test/language/union_types/cpp/SimpleUnionTest.cpp b/test/language/union_types/cpp/SimpleUnionTest.cpp index eb88073..b59525f 100644 --- a/test/language/union_types/cpp/SimpleUnionTest.cpp +++ b/test/language/union_types/cpp/SimpleUnionTest.cpp @@ -51,6 +51,58 @@ TEST_F(SimpleUnionTest, constructors) } } +TEST_F(SimpleUnionTest, copyConstructor) +{ + SimpleUnion data; + data.emplace(CASE1_FIELD); + SimpleUnion dataCopy(data); + ASSERT_EQ(dataCopy, data); + + zserio::View view(data); + zserio::View viewCopy(view); + ASSERT_EQ(viewCopy, view); +} + +TEST_F(SimpleUnionTest, assignmentOperator) +{ + SimpleUnion data; + data.emplace(CASE1_FIELD); + SimpleUnion dataCopy; + dataCopy = data; + ASSERT_EQ(dataCopy, data); + + zserio::View view(data); + zserio::View viewCopy(SimpleUnion{}); + viewCopy = view; + ASSERT_EQ(viewCopy, view); +} + +TEST_F(SimpleUnionTest, moveConstructor) +{ + SimpleUnion data; + data.emplace(CASE1_FIELD); + SimpleUnion dataMoved(std::move(data)); + ASSERT_EQ(CASE1_FIELD, zserio::get(dataMoved)); + + zserio::View view(data); + zserio::View viewMoved(std::move(view)); + ASSERT_EQ(CASE1_FIELD, viewMoved.case1Field()); +} + +TEST_F(SimpleUnionTest, moveAssignmentOperator) +{ + SimpleUnion data; + data.emplace(CASE1_FIELD); + SimpleUnion dataMoved; + dataMoved = std::move(data); + ASSERT_EQ(CASE1_FIELD, zserio::get(dataMoved)); + + zserio::View view(data); + zserio::View viewMoved(SimpleUnion{}); + viewMoved = std::move(view); + ASSERT_EQ(CASE1_FIELD, viewMoved.case1Field()); +} + TEST_F(SimpleUnionTest, zserioChoiceTag) { {