[poppler] unit test for GLib bindings

Kouhei Sutou kou at cozmixng.org
Sat Apr 25 07:53:38 PDT 2009


Hi,

In <1240670612.4223.8.camel at charmaleon>
  "Re: [poppler] unit test for GLib bindings" on Sat, 25 Apr 2009 16:43:32 +0200,
  Carlos Garcia Campos <carlosgc at gnome.org> wrote:

> I don't think expected is destroyed, the problem is that checksum is
> optional, so it might be NULL. In this case since checksum is a GString
> ->str is what is NULL. So in the test we are passing NULL to
> g_string_append_printf:
> 
> g_string_append_printf (string, "checksum=<%s>",
> attachment->checksum->str);

Is the test passed with the patch? (please revert the
previous patch.)

diff --git a/glib/test/test-document.c b/glib/test/test-document.c
index 117b314..d05da69 100644
--- a/glib/test/test-document.c
+++ b/glib/test/test-document.c
@@ -497,13 +497,18 @@ attachment_equal (gconstpointer data1, gconstpointer data2)
   const PopplerAttachment *attachment1 = data1;
   const PopplerAttachment *attachment2 = data2;
 
+  if ((attachment1->checksum != attachment2->checksum) &&
+      (attachment1->checksum == NULL || attachment2->checksum == NULL))
+    return FALSE;
+
   return
     cut_equal_string (attachment1->name, attachment2->name) &&
     cut_equal_string (attachment1->description, attachment2->description) &&
     attachment1->size == attachment2->size &&
     attachment1->mtime == attachment2->mtime &&
     attachment1->ctime == attachment2->ctime &&
-    cut_equal_string (attachment1->checksum->str, attachment2->checksum->str);
+    (attachment1->checksum == attachment2->checksum ||
+     cut_equal_string (attachment1->checksum->str, attachment2->checksum->str));
 }
 
 static void
@@ -518,7 +523,8 @@ attachment_inspect (GString *string, gconstpointer data, gpointer user_data)
                           attachment->size);
   g_string_append_printf (string, "mtime=<%d>, ", attachment->mtime);
   g_string_append_printf (string, "ctime=<%d>, ", attachment->ctime);
-  g_string_append_printf (string, "checksum=<%s>", attachment->checksum->str);
+  g_string_append_printf (string, "checksum=<%s>",
+                          attachment->checksum ? attachment->checksum->str : "NULL");
   g_string_append (string, ">");
 }
 

Thanks,
--
kou


More information about the poppler mailing list