[vlc-devel] [PATCH 2/4] src: test: split out MD5 equality check

Marvin Scholz epirat07 at gmail.com
Thu Jul 23 14:51:57 CEST 2020


---
 src/test/md5.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/test/md5.c b/src/test/md5.c
index c81e73b4d0..f952b517d6 100644
--- a/src/test/md5.c
+++ b/src/test/md5.c
@@ -52,6 +52,18 @@ static const md5_sample_t md5_samples[] =
     { NULL,         NULL            }
 };
 
+static void check_result(char *result, char *expected)
+{
+    if ( strcmp( result, expected ) )
+    {
+        printf( "Output:   %s\n"
+                "Expected: %s\n",
+                result,
+                expected );
+        abort();
+    }
+}
+
 static void test_vlc_hash_md5()
 {
     for( int i = 0; md5_samples[i].psz_string; i++ )
@@ -62,12 +74,7 @@ static void test_vlc_hash_md5()
         vlc_hash_md5_Update( &md5, md5_samples[i].psz_string, strlen( md5_samples[i].psz_string ) );
         vlc_hash_FinishHex( &md5, psz_hash );
 
-        if( strcmp( psz_hash, md5_samples[i].psz_md5 ) )
-        {
-            printf( "Output: %s\nExpected: %s\n", psz_hash,
-                    md5_samples[i].psz_md5 );
-            abort();
-        }
+        check_result( psz_hash, md5_samples[i].psz_md5 );
     }
 }
 
-- 
2.24.3 (Apple Git-128)



More information about the vlc-devel mailing list