]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-master: Properly compare unit test output strings with expected values
authorJosef 'Jeff' Sipek <jeff.sipek@open-xchange.com>
Mon, 27 Jul 2020 15:15:42 +0000 (11:15 -0400)
committerjeff.sipek <jeff.sipek@open-xchange.com>
Tue, 4 Aug 2020 21:34:56 +0000 (21:34 +0000)
The I_MIN() mean that only the prefix was getting compared.

src/lib-master/test-event-stats.c

index 3699a363b9e3ccb2ab6da322e090580c36361db0..7d878596ce5a36c06a74e8e6e4fed79fc209555b 100644 (file)
@@ -224,9 +224,13 @@ static bool compare_test_stats_data_line(const char *reference, const char *actu
 {
        const char *const *ref_args = t_strsplit(reference, "\t");
        const char *const *act_args = t_strsplit(actual, "\t");
-       unsigned int max = I_MIN(str_array_length(ref_args), str_array_length(act_args));
+       unsigned int max = str_array_length(ref_args);
 
-       for(size_t i=0; i < max && *ref_args != NULL; i++) {
+       /* different lengths imply not equal */
+       if (str_array_length(ref_args) != str_array_length(act_args))
+               return FALSE;
+
+       for (size_t i = 0; i < max; i++) {
                if (i > 1 && i < 6) continue;
                if (*(ref_args[i]) == 'l') {
                        i++;