chiark / gitweb /
test-tables: ellide boring parts of sparse mappings
[elogind.git] / src / shared / test-tables.h
index 74f1716fe08ee9af42fc7bd1c6f7bdcd1ceef840..228e51010481c30087f48ea7651f68b066a19e11 100644 (file)
@@ -28,18 +28,25 @@ static inline void _test_table(const char *name,
                                reverse_t reverse,
                                int size,
                                bool sparse) {
-        int i;
+        int i, boring = 0;
 
         for (i = -1; i < size + 1; i++) {
                 const char* val = lookup(i);
                 int rev;
 
-                if (val)
+                if (val) {
                         rev = reverse(val);
-                else
+                        boring = 0;
+                } else {
                         rev = reverse("--no-such--value----");
+                        boring += i >= 0;
+                }
+
+                if (boring < 1 || i == size)
+                        printf("%s: %d → %s → %d\n", name, i, val, rev);
+                else if (boring == 1)
+                        printf("%*s  ...\n", (int) strlen(name), "");
 
-                printf("%s: %d → %s → %d\n", name, i, val, rev);
                 assert_se(!(i >= 0 && i < size ?
                             sparse ? rev != i && rev != -1 : val == NULL || rev != i :
                             val != NULL || rev != -1));