[gobject-introspection] Fix the list comparison assertions.
- From: Johan Bilien <jobi src gnome org>
- To: svn-commits-list gnome org
- Subject: [gobject-introspection] Fix the list comparison assertions.
- Date: Tue, 12 May 2009 11:06:47 -0400 (EDT)
commit 9e85ff040f31a6ea91bb3f9d529c28c236a3dcae
Author: C. Scott Ananian <cscott litl com>
Date: Fri May 1 18:20:06 2009 -0400
Fix the list comparison assertions.
We weren't checking the length of the input list, and we were erroneously
comparing every element in the test sequence against the *first* element
of the passed-in list.
---
tests/everything/everything.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/tests/everything/everything.c b/tests/everything/everything.c
index d02182d..ddab7b6 100644
--- a/tests/everything/everything.c
+++ b/tests/everything/everything.c
@@ -483,8 +483,11 @@ static void assert_test_sequence_list (const GList *in)
const GList *l;
gsize i;
- for (i = 0, l = in; l != NULL; ++i, l = l->next)
- g_assert (strcmp (in->data, test_sequence[i]) == 0);
+ for (i = 0, l = in; l != NULL; ++i, l = l->next) {
+ g_assert (i < G_N_ELEMENTS(test_sequence));
+ g_assert (strcmp (l->data, test_sequence[i]) == 0);
+ }
+ g_assert (i == G_N_ELEMENTS(test_sequence));
}
/**
@@ -602,8 +605,11 @@ static void assert_test_sequence_slist (const GSList *in)
const GSList *l;
gsize i;
- for (i = 0, l = in; l != NULL; ++i, l = l->next)
- g_assert (strcmp (in->data, test_sequence[i]) == 0);
+ for (i = 0, l = in; l != NULL; ++i, l = l->next) {
+ g_assert (i < G_N_ELEMENTS(test_sequence));
+ g_assert (strcmp (l->data, test_sequence[i]) == 0);
+ }
+ g_assert (i == G_N_ELEMENTS(test_sequence));
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]