summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2015-07-19 14:42:00 (GMT)
committer Michael Drake <tlsa@netsurf-browser.org>2015-08-03 21:30:20 (GMT)
commit093e64c448108483fb1c8f5bccc13d12b547550c (patch)
treeb995acf0043f3ad3db9d89028e5e71fd98e6a136
parent0b624c7fba92d74858746328888548d28b55f84a (diff)
downloadlibnslayout-093e64c448108483fb1c8f5bccc13d12b547550c.tar.gz
libnslayout-093e64c448108483fb1c8f5bccc13d12b547550c.tar.bz2
Add nslayout_layout_destroy basic API testing.
-rw-r--r--src/layout.c1
-rw-r--r--test/assert-tests.c13
-rw-r--r--test/basic-layout-tests.c13
3 files changed, 21 insertions, 6 deletions
diff --git a/src/layout.c b/src/layout.c
index 773996a..43570fb 100644
--- a/src/layout.c
+++ b/src/layout.c
@@ -49,6 +49,7 @@ nslayout_error nslayout_layout_destroy(
nslayout_layout *layout)
{
/* TODO: free/unref the stuff we own in the layout */
+ assert(layout != NULL);
free(layout);
return NSLAYOUT_OK;
diff --git a/test/assert-tests.c b/test/assert-tests.c
index 4fca036..1b97814 100644
--- a/test/assert-tests.c
+++ b/test/assert-tests.c
@@ -22,16 +22,27 @@ START_TEST (test_nslayout_layout_create_aborts1)
}
END_TEST
+/* TODO: Test for each individual param being NULL. */
+START_TEST (test_nslayout_layout_destroy_aborts1)
+{
+ (void) nslayout_layout_destroy(NULL);
+}
+END_TEST
+
void nslayout_assert_suite(SRunner *sr)
{
Suite *s = suite_create("libnslayout: API Assert tests");
- TCase *tc_assert = tcase_create("Creation/Destruction");
+ TCase *tc_assert = tcase_create("Creation/Destruction");
tcase_add_test_raise_signal(
tc_assert,
test_nslayout_layout_create_aborts1,
SIGABRT);
+ tcase_add_test_raise_signal(
+ tc_assert,
+ test_nslayout_layout_destroy_aborts1,
+ SIGABRT);
suite_add_tcase(s, tc_assert);
srunner_add_suite(sr, s);
diff --git a/test/basic-layout-tests.c b/test/basic-layout-tests.c
index 84611a9..6dec991 100644
--- a/test/basic-layout-tests.c
+++ b/test/basic-layout-tests.c
@@ -52,11 +52,15 @@ START_TEST (test_nslayout_layout_create_ok)
nslayout_test_callback,
&pw,
&layout);
- fail_unless(error == NSLAYOUT_OK,
+ fail_unless(error == NSLAYOUT_OK,
"Unable to create layout");
- fail_unless(layout != NULL,
+ fail_unless(layout != NULL,
"Returned OK but str was still NULL");
+ error = nslayout_layout_destroy(layout);
+ fail_unless(error == NSLAYOUT_OK,
+ "Unable to destroy layout");
+
css_err = css_select_ctx_destroy(css_ctx);
ck_assert(css_err == CSS_OK);
@@ -68,10 +72,9 @@ END_TEST
void nslayout_basic_layout_suite(SRunner *sr)
{
Suite *s = suite_create("libnslayout: basic layout tests");
- TCase *tc_layout_basic = tcase_create("Creation/Destruction");
+ TCase *tc_layout_basic = tcase_create("Creation/Destruction");
- tcase_add_test(tc_layout_basic,
- test_nslayout_layout_create_ok);
+ tcase_add_test(tc_layout_basic, test_nslayout_layout_create_ok);
suite_add_tcase(s, tc_layout_basic);
srunner_add_suite(sr, s);