mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-05-07 06:26:53 +02:00
Add some tests for off-by-one errors.
2004-04-22 Matthias Clasen <mclasen@redhat.com> * tests/queue-test.c (main): Add some tests for off-by-one errors. * glib/gqueue.c (g_queue_pop_nth_link): Fix an off-by-one error. (#139703, Philippe Blain)
This commit is contained in:
parent
05501852ec
commit
2efb5e1cd8
@ -1,5 +1,10 @@
|
|||||||
2004-04-22 Matthias Clasen <mclasen@redhat.com>
|
2004-04-22 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* tests/queue-test.c (main): Add some tests for off-by-one errors.
|
||||||
|
|
||||||
|
* glib/gqueue.c (g_queue_pop_nth_link): Fix an off-by-one
|
||||||
|
error. (#139703, Philippe Blain)
|
||||||
|
|
||||||
* tests/testglib.c (main): Add testcases for g_message() involving
|
* tests/testglib.c (main): Add testcases for g_message() involving
|
||||||
non-printable and unsafe characters.
|
non-printable and unsafe characters.
|
||||||
|
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
2004-04-22 Matthias Clasen <mclasen@redhat.com>
|
2004-04-22 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* tests/queue-test.c (main): Add some tests for off-by-one errors.
|
||||||
|
|
||||||
|
* glib/gqueue.c (g_queue_pop_nth_link): Fix an off-by-one
|
||||||
|
error. (#139703, Philippe Blain)
|
||||||
|
|
||||||
* tests/testglib.c (main): Add testcases for g_message() involving
|
* tests/testglib.c (main): Add testcases for g_message() involving
|
||||||
non-printable and unsafe characters.
|
non-printable and unsafe characters.
|
||||||
|
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
2004-04-22 Matthias Clasen <mclasen@redhat.com>
|
2004-04-22 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* tests/queue-test.c (main): Add some tests for off-by-one errors.
|
||||||
|
|
||||||
|
* glib/gqueue.c (g_queue_pop_nth_link): Fix an off-by-one
|
||||||
|
error. (#139703, Philippe Blain)
|
||||||
|
|
||||||
* tests/testglib.c (main): Add testcases for g_message() involving
|
* tests/testglib.c (main): Add testcases for g_message() involving
|
||||||
non-printable and unsafe characters.
|
non-printable and unsafe characters.
|
||||||
|
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
2004-04-22 Matthias Clasen <mclasen@redhat.com>
|
2004-04-22 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* tests/queue-test.c (main): Add some tests for off-by-one errors.
|
||||||
|
|
||||||
|
* glib/gqueue.c (g_queue_pop_nth_link): Fix an off-by-one
|
||||||
|
error. (#139703, Philippe Blain)
|
||||||
|
|
||||||
* tests/testglib.c (main): Add testcases for g_message() involving
|
* tests/testglib.c (main): Add testcases for g_message() involving
|
||||||
non-printable and unsafe characters.
|
non-printable and unsafe characters.
|
||||||
|
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
2004-04-22 Matthias Clasen <mclasen@redhat.com>
|
2004-04-22 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* tests/queue-test.c (main): Add some tests for off-by-one errors.
|
||||||
|
|
||||||
|
* glib/gqueue.c (g_queue_pop_nth_link): Fix an off-by-one
|
||||||
|
error. (#139703, Philippe Blain)
|
||||||
|
|
||||||
* tests/testglib.c (main): Add testcases for g_message() involving
|
* tests/testglib.c (main): Add testcases for g_message() involving
|
||||||
non-printable and unsafe characters.
|
non-printable and unsafe characters.
|
||||||
|
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
2004-04-22 Matthias Clasen <mclasen@redhat.com>
|
2004-04-22 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* tests/queue-test.c (main): Add some tests for off-by-one errors.
|
||||||
|
|
||||||
|
* glib/gqueue.c (g_queue_pop_nth_link): Fix an off-by-one
|
||||||
|
error. (#139703, Philippe Blain)
|
||||||
|
|
||||||
* tests/testglib.c (main): Add testcases for g_message() involving
|
* tests/testglib.c (main): Add testcases for g_message() involving
|
||||||
non-printable and unsafe characters.
|
non-printable and unsafe characters.
|
||||||
|
|
||||||
|
@ -662,7 +662,7 @@ g_queue_pop_nth_link (GQueue *queue,
|
|||||||
|
|
||||||
g_return_val_if_fail (queue != NULL, NULL);
|
g_return_val_if_fail (queue != NULL, NULL);
|
||||||
|
|
||||||
if (n > queue->length)
|
if (n >= queue->length)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
link = g_queue_peek_nth_link (queue, n);
|
link = g_queue_peek_nth_link (queue, n);
|
||||||
|
@ -928,6 +928,20 @@ int main(int argc, gchar *args[])
|
|||||||
check_integrity (q2);
|
check_integrity (q2);
|
||||||
check_integrity (q);
|
check_integrity (q);
|
||||||
|
|
||||||
|
/* some checks for off by one errors */
|
||||||
|
g_queue_push_tail (q, GINT_TO_POINTER (1234));
|
||||||
|
check_integrity (q);
|
||||||
|
node = g_queue_peek_tail_link (q);
|
||||||
|
g_assert (node != NULL && node->data == GINT_TO_POINTER (1234));
|
||||||
|
node = g_queue_peek_nth_link (q, g_queue_get_length (q));
|
||||||
|
g_assert (node == NULL);
|
||||||
|
node = g_queue_peek_nth_link (q, g_queue_get_length (q) - 1);
|
||||||
|
g_assert (node->data == GINT_TO_POINTER (1234));
|
||||||
|
node = g_queue_pop_nth_link (q, g_queue_get_length (q));
|
||||||
|
g_assert (node == NULL);
|
||||||
|
node = g_queue_pop_nth_link (q, g_queue_get_length (q) - 1);
|
||||||
|
g_assert (node != NULL && node->data == GINT_TO_POINTER (1234));
|
||||||
|
|
||||||
g_queue_free (q);
|
g_queue_free (q);
|
||||||
|
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user