Init variables and split multiple serializaion test by parameter type 77/307277/2
authorYonggoo Kang <ygace.kang@samsung.com>
Wed, 6 Mar 2024 13:48:25 +0000 (22:48 +0900)
committerYonggoo Kang <ygace.kang@samsung.com>
Wed, 6 Mar 2024 13:48:51 +0000 (22:48 +0900)
Change-Id: I5bda599854d7cf74a6c73cb581fbf7fdf7ca6d23

tests/serialization-test.cpp

index ddd82abed65bcb09549648bda35a4a3b53c1b8cf..fcea9f0cb504788b47e345f46ee66a82111e3b9e 100644 (file)
@@ -1287,11 +1287,9 @@ TEST_F(WAuthnSerializationTest, wauthn_client_data_s_N3)
 }
 
 template<typename T, typename U, typename FT, typename FU>
-void __testMultipleSerialization(T first, U second, FT cmpfirst, FU cmpsecond)
+void __testMultipleSerialization(T first, U second, FT cmpfirst, FU cmpsecond,
+                                 T deserialized_first, U deserialized_second)
 {
-    T deserialized_first = nullptr;
-    U deserialized_second = nullptr;
-
     MessageBuffer buffer;
     buffer.InitForStreaming();
     Serialization::Serialize(buffer, first, second);
@@ -1304,12 +1302,30 @@ void __testMultipleSerialization(T first, U second, FT cmpfirst, FU cmpsecond)
     EXPECT_EQ(cmpsecond(second, deserialized_second), true);
 }
 
+template<typename T, typename U, typename FT, typename FU>
+void __testMultipleSerialization(T first, U second, FT cmpfirst, FU cmpsecond)
+{
+    T deserialized_first = nullptr;
+    U deserialized_second = nullptr;
+    __testMultipleSerialization(first, second, cmpfirst, cmpsecond,
+                                deserialized_first, deserialized_second);
+}
+
+template<typename T, typename U, typename FT, typename FU>
+void __testMultipleSerializationWAuthErrorE(T first, U second, FT cmpfirst, FU cmpsecond)
+{
+    T deserialized_first = nullptr;
+    U deserialized_second = WAUTHN_ERROR_NONE;
+    __testMultipleSerialization(first, second, cmpfirst, cmpsecond,
+                                deserialized_first, deserialized_second);
+}
+
 TEST_F(WAuthnSerializationTest, multiple_serialization_mcreq_P)
 {
     wauthn_client_data_s *client_data = &SerializationTestData::clientData;
     wauthn_pubkey_cred_creation_options_s *options = &SerializationTestData::pubkeyCredCreationOptions;
 
-    __testMultipleSerialization(client_data, options, 
+    __testMultipleSerialization(client_data, options,
             __compareWAuthnClientDataS, __compareWAuthnPubkeyCredCreationOptionsS);
 }
 
@@ -1318,7 +1334,7 @@ TEST_F(WAuthnSerializationTest, multiple_serialization_gareq_P)
     wauthn_client_data_s *client_data = &SerializationTestData::clientData;
     wauthn_pubkey_cred_request_options_s *options = &SerializationTestData::pubkeyCredRequestOptions;
 
-    __testMultipleSerialization(client_data, options, 
+    __testMultipleSerialization(client_data, options,
             __compareWAuthnClientDataS, __compareWAuthnPubkeyCredRequestOptionsS);
 }
 
@@ -1327,7 +1343,7 @@ TEST_F(WAuthnSerializationTest, multiple_serialization_mcres_P)
     wauthn_pubkey_credential_attestaion_s *pubkeyCred = &SerializationTestData::pubkeyCredentialAttestation;
     wauthn_error_e result = WAUTHN_ERROR_PERMISSION_DENIED;
 
-    __testMultipleSerialization(pubkeyCred, result, 
+    __testMultipleSerializationWAuthErrorE(pubkeyCred, result,
             __compareWAuthnPubkeyCredentialAttestionS, __compareWAuthErrorE);
 }
 
@@ -1336,7 +1352,7 @@ TEST_F(WAuthnSerializationTest, multiple_serialization_gares_P)
     wauthn_pubkey_credential_assertion_s *pubkeyCred = &SerializationTestData::pubkeyCredentialAssertion;
     wauthn_error_e result = WAUTHN_ERROR_CANCELLED;
 
-    __testMultipleSerialization(pubkeyCred, result, 
+    __testMultipleSerializationWAuthErrorE(pubkeyCred, result,
             __compareWAuthnPubkeyCredentialAssertionS, __compareWAuthErrorE);
 }