summaryrefslogtreecommitdiff
path: root/test/serialization/generated_serializer/generated_serializer_test.cpp
diff options
context:
space:
mode:
authorPaul Elder <paul.elder@ideasonboard.com>2022-08-03 19:56:36 +0900
committerPaul Elder <paul.elder@ideasonboard.com>2022-10-18 18:52:42 +0900
commitdeaf13de9bd99457300d33d5c38aedd909fe8260 (patch)
tree5bb85338e487b8e3e4a1e794417c5bf5ff46994b /test/serialization/generated_serializer/generated_serializer_test.cpp
parent207c9e1c1d73dc062d68bf0dbb27a0b58c7581a2 (diff)
test: generated_serializer: Test Flags that is struct member
Add fields to the test struct to test serialization/deserialization of scoped enums and flags that are struct members. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'test/serialization/generated_serializer/generated_serializer_test.cpp')
-rw-r--r--test/serialization/generated_serializer/generated_serializer_test.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/serialization/generated_serializer/generated_serializer_test.cpp b/test/serialization/generated_serializer/generated_serializer_test.cpp
index a4639a80..4670fe46 100644
--- a/test/serialization/generated_serializer/generated_serializer_test.cpp
+++ b/test/serialization/generated_serializer/generated_serializer_test.cpp
@@ -35,6 +35,13 @@ if (struct1.field != struct2.field) { \
return TestFail; \
}
+#define TEST_SCOPED_ENUM_EQUALITY(struct1, struct2, field) \
+if (struct1.field != struct2.field) { \
+ cerr << #field << " field incorrect" << endl; \
+ return TestFail; \
+}
+
+
ipa::test::TestStruct t, u;
t.m = {
@@ -52,6 +59,12 @@ if (struct1.field != struct2.field) { \
t.s3 = "lorem ipsum";
t.i = 58527;
t.c = ipa::test::IPAOperationInit;
+ t.e = ipa::test::ErrorFlags::Error1;
+
+ Flags<ipa::test::ErrorFlags> flags;
+ flags |= ipa::test::ErrorFlags::Error1;
+ flags |= ipa::test::ErrorFlags::Error2;
+ t.f = flags;
std::vector<uint8_t> serialized;
@@ -72,6 +85,8 @@ if (struct1.field != struct2.field) { \
TEST_FIELD_EQUALITY(t, u, i);
TEST_FIELD_EQUALITY(t, u, c);
+ TEST_SCOPED_ENUM_EQUALITY(t, u, e);
+ TEST_SCOPED_ENUM_EQUALITY(t, u, f);
/* Test vector of generated structs */
std::vector<ipa::test::TestStruct> v = { t, u };
@@ -96,12 +111,18 @@ if (struct1.field != struct2.field) { \
TEST_FIELD_EQUALITY(v[0], w[0], i);
TEST_FIELD_EQUALITY(v[0], w[0], c);
+ TEST_SCOPED_ENUM_EQUALITY(v[0], w[0], e);
+ TEST_SCOPED_ENUM_EQUALITY(v[0], w[0], f);
+
TEST_FIELD_EQUALITY(v[1], w[1], s1);
TEST_FIELD_EQUALITY(v[1], w[1], s2);
TEST_FIELD_EQUALITY(v[1], w[1], s3);
TEST_FIELD_EQUALITY(v[1], w[1], i);
TEST_FIELD_EQUALITY(v[1], w[1], c);
+ TEST_SCOPED_ENUM_EQUALITY(v[1], w[1], e);
+ TEST_SCOPED_ENUM_EQUALITY(v[1], w[1], f);
+
return TestPass;
}