summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@netsurf-browser.org>2010-12-04 15:47:32 +0000
committerDaniel Silverstone <dsilvers@netsurf-browser.org>2010-12-04 15:47:32 +0000
commit780d398d7b29ac874df30854f85072a45aaec9a9 (patch)
tree21bfb9bb62a81cf13b3966662648bfaa10e58d4a /test
parenta79cf8437b936e1c3e730a9b216867cfaa9520bc (diff)
downloadlibwapcaplet-780d398d7b29ac874df30854f85072a45aaec9a9.tar.gz
libwapcaplet-780d398d7b29ac874df30854f85072a45aaec9a9.tar.bz2
Remove initialisation, use system allocation functions. r=vince
svn path=/trunk/libwapcaplet/; revision=10963
Diffstat (limited to 'test')
-rw-r--r--test/basictests.c109
1 files changed, 1 insertions, 108 deletions
diff --git a/test/basictests.c b/test/basictests.c
index cd1fa32..c55e1bd 100644
--- a/test/basictests.c
+++ b/test/basictests.c
@@ -16,14 +16,6 @@
#define UNUSED(x) (void)(x)
#endif
-static void *last_pw = NULL;
-static void *
-trivial_alloc_fn(void *p, size_t s, void *pw)
-{
- last_pw = pw;
- return realloc(p, s);
-}
-
#ifndef NDEBUG
/* All the basic assert() tests */
START_TEST (test_lwc_intern_string_aborts1)
@@ -47,8 +39,6 @@ END_TEST
START_TEST (test_lwc_intern_substring_aborts2)
{
lwc_string *str;
- fail_unless(lwc_initialise(trivial_alloc_fn, NULL, 0) == lwc_error_ok,
- "unable to initialise the library");
fail_unless(lwc_intern_string("Jam", 3, &str) == lwc_error_ok,
"unable to intern 'Jam'");
@@ -88,99 +78,12 @@ END_TEST
#endif
-START_TEST (test_lwc_double_initialise_fails)
-{
- fail_unless(lwc_initialise(trivial_alloc_fn, NULL, 0) == lwc_error_ok,
- "Unable to initialise library");
- fail_unless(lwc_initialise(trivial_alloc_fn, NULL, 0) == lwc_error_initialised,
- "Able to initialise library a second time");
-}
-END_TEST
-
-static void *enomem_allocator(void *ptr, size_t n, void *pw)
-{
- int *pi = (int*)pw;
- UNUSED(ptr);
- UNUSED(n);
-
- if (*pi > 0) {
- *pi -= 1;
- return realloc(ptr, n);
- }
-
- return NULL;
-}
-
-START_TEST (test_lwc_initialise_fails_with_no_memory)
-{
- int permitted = 0;
- fail_unless(lwc_initialise(enomem_allocator, &permitted, 0) == lwc_error_oom,
- "Able to initialise library with no memory available?!");
-}
-END_TEST
-
-START_TEST (test_lwc_initialise_fails_with_low_memory)
-{
- int permitted = 1;
- fail_unless(lwc_initialise(enomem_allocator, &permitted, 0) == lwc_error_oom,
- "Able to initialise library with no memory available?!");
-}
-END_TEST
-
-START_TEST (test_lwc_intern_fails_with_no_memory)
-{
- int permitted = 2; /* context and buckets */
- lwc_string *str;
-
- fail_unless(lwc_initialise(enomem_allocator, &permitted, 0) == lwc_error_ok,
- "Unable to initialise library");
- fail_unless(lwc_intern_string("Hello", 5, &str) == lwc_error_oom,
- "Able to allocate string despite enomem.");
-
-}
-END_TEST
-
-START_TEST (test_lwc_caseless_compare_fails_with_no_memory1)
-{
- int permitted = 3; /* ctx, buckets, 1 string */
- lwc_string *str;
- bool result = true;
-
- fail_unless(lwc_initialise(enomem_allocator, &permitted, 0) == lwc_error_ok,
- "Unable to initialise library");
- fail_unless(lwc_intern_string("Hello", 5, &str) == lwc_error_ok,
- "Unable to allocate string.");
- fail_unless(lwc_string_caseless_isequal(str, str, &result) == lwc_error_oom,
- "Able to caselessly compare despite no memory");
-
-}
-END_TEST
-
-START_TEST (test_lwc_caseless_compare_fails_with_no_memory2)
-{
- int permitted = 5; /* ctx, buckets, 3 strings */
- lwc_string *str1, *str2;
- bool result = true;
-
- fail_unless(lwc_initialise(enomem_allocator, &permitted, 0) == lwc_error_ok,
- "Unable to initialise library");
- fail_unless(lwc_intern_string("Hello", 5, &str1) == lwc_error_ok,
- "Unable to allocate string.");
- fail_unless(lwc_intern_string("World", 5, &str2) == lwc_error_ok,
- "Unable to allocate string.");
- fail_unless(lwc_string_caseless_isequal(str1, str2, &result) == lwc_error_oom,
- "Able to caselessly compare despite no memory");
-
-}
-END_TEST
-
/**** The next set of tests need a fixture set ****/
static void
with_simple_context_setup(void)
{
- fail_unless(lwc_initialise(trivial_alloc_fn, NULL, 0) == lwc_error_ok,
- "Unable to initialise library");
+ /* Nothing to set up */
}
static void
@@ -234,9 +137,6 @@ static lwc_string *intern_one = NULL, *intern_two = NULL, *intern_three = NULL,
static void
with_filled_context_setup(void)
{
- fail_unless(lwc_initialise(trivial_alloc_fn, NULL, 2) == lwc_error_ok,
- "Unable to initialise library");
-
fail_unless(lwc_intern_string("one", 3, &intern_one) == lwc_error_ok,
"Unable to intern 'one'");
fail_unless(lwc_intern_string("two", 3, &intern_two) == lwc_error_ok,
@@ -480,13 +380,6 @@ lwc_basic_suite(SRunner *sr)
SIGABRT);
#endif
- tcase_add_test(tc_basic, test_lwc_double_initialise_fails);
- tcase_add_test(tc_basic, test_lwc_initialise_fails_with_no_memory);
- tcase_add_test(tc_basic, test_lwc_initialise_fails_with_low_memory);
- tcase_add_test(tc_basic, test_lwc_intern_fails_with_no_memory);
- tcase_add_test(tc_basic, test_lwc_caseless_compare_fails_with_no_memory1);
- tcase_add_test(tc_basic, test_lwc_caseless_compare_fails_with_no_memory2);
-
suite_add_tcase(s, tc_basic);
tc_basic = tcase_create("Ops with a context");