diff options
author | Lars Wirzenius <liw@liw.fi> | 2010-10-22 14:00:54 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2010-10-22 14:00:54 +0100 |
commit | 553742bf21b03047556d6d8fa05658cfe7e00ca1 (patch) | |
tree | e07150257d793e239c45e712c9061bab076c1cb4 | |
parent | ef2598daee4ad8321a2313dbdbeb5e4664e3842b (diff) | |
download | dynstr-553742bf21b03047556d6d8fa05658cfe7e00ca1.tar.gz |
Add test to verify alloc() does not call error handler if allocation succeeds.
-rw-r--r-- | unittests.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/unittests.c b/unittests.c index 4e7c15c..11a5acb 100644 --- a/unittests.c +++ b/unittests.c @@ -123,6 +123,18 @@ static int test_alloc_calls_error_handler(void) return true; } +static int test_alloc_does_not_call_error_handler(void) +{ + Dynstr *dynstr; + + error_handler_called = false; + dynstr_set_malloc_error_handler(error_handler); + dynstr_set_malloc(malloc); + dynstr = dynstr_new_empty(); + FAIL_UNLESS_EQUAL(error_handler_called, false); + return true; +} + static int test_uses_malloc_by_default(void) { @@ -266,6 +278,7 @@ static const struct test tests[] = { TEST(test_sets_malloc), TEST(test_init_resets_malloc), TEST(test_alloc_calls_error_handler), + TEST(test_alloc_does_not_call_error_handler), TEST(test_indicate_handler_returns), TEST(test_abort_handler_calls_abort), TEST(test_empty_string_is_empty), |