diff options
author | Dave Davenport <qball@gmpclient.org> | 2016-10-13 17:54:52 +0200 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2016-10-13 17:54:52 +0200 |
commit | 306eeac3febfb5a2084bb9c00b8067bdbed3f031 (patch) | |
tree | b1047af3516fd63a74273f36f562ee6b55e28858 | |
parent | 1cd94c27c77f70d4ab2d5751b267370987a38bcd (diff) |
Add some NULL tests to widget test
-rw-r--r-- | source/widgets/widget.c | 2 | ||||
-rw-r--r-- | test/widget-test.c | 21 |
2 files changed, 19 insertions, 4 deletions
diff --git a/source/widgets/widget.c b/source/widgets/widget.c index 37248f15..c286462f 100644 --- a/source/widgets/widget.c +++ b/source/widgets/widget.c @@ -68,7 +68,7 @@ void widget_draw ( widget *widget, cairo_t *d ) } void widget_free ( widget *widget ) { - if ( widget ) { + if ( widget && widget->free ) { widget->free ( widget ); } } diff --git a/test/widget-test.c b/test/widget-test.c index d39b22ac..d3ee1dc5 100644 --- a/test/widget-test.c +++ b/test/widget-test.c @@ -110,7 +110,6 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv ) TASSERT ( widget_intersect ( wid, 20+30, 20+40) == 0 ); TASSERT ( widget_intersect ( wid, 20+30, 20+50) == 0 ); - TASSERT ( widget_intersect ( NULL, 0, 0) == 0 ); TASSERT ( widget_intersect ( wid, -100, -100) == 0); TASSERT ( widget_intersect ( wid, INT_MIN, INT_MIN) == 0); @@ -119,13 +118,29 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv ) // Other wrappers. TASSERT ( widget_get_height ( wid ) == wid->h); TASSERT ( widget_get_width ( wid ) == wid->w); - TASSERT ( widget_get_height ( NULL ) == 0); - TASSERT ( widget_get_width ( NULL ) == 0); TASSERT ( widget_enabled ( wid ) == FALSE ); widget_enable ( wid ); TASSERT ( widget_enabled ( wid ) == TRUE ); widget_disable ( wid ); TASSERT ( widget_enabled ( wid ) == FALSE ); + // Null pointer tests. + TASSERT ( widget_intersect ( NULL, 0, 0) == 0 ); + widget_move ( NULL, 0, 0 ); + TASSERT ( widget_get_height ( NULL ) == 0); + TASSERT ( widget_get_width ( NULL ) == 0); + widget_enabled ( NULL ); + widget_disable ( NULL ); + widget_enable ( NULL ); + widget_draw ( NULL, NULL ); + widget_free ( NULL ); + widget_resize ( NULL, 0, 0); + widget_update ( NULL ); + widget_queue_redraw ( NULL ); + widget_need_redraw ( NULL ); + widget_clicked ( NULL, NULL ); + widget_set_clicked_handler ( NULL, NULL, NULL ); + + g_free(wid); } |