| 1 |
/** |
| 2 |
* This file is part of the Detox package. |
| 3 |
* |
| 4 |
* Copyright (c) Doug Harple <[email protected]> |
| 5 |
* |
| 6 |
* For the full copyright and license information, please view the LICENSE |
| 7 |
* file that was distributed with this source code. |
| 8 |
*/ |
| 9 |
|
| 10 |
#include <stdio.h> |
| 11 |
#include <stdlib.h> |
| 12 |
#include <string.h> |
| 13 |
|
| 14 |
// need defines first |
| 15 |
#include "config.h" |
| 16 |
|
| 17 |
#include "wrapped.h" |
| 18 |
|
| 19 |
#test-exit(1) test_wrapped_malloc_fail |
| 20 |
#ifdef SUPPORT_COVERAGE |
| 21 |
wrapped_malloc_failure = 1; |
| 22 |
wrapped_malloc(5); |
| 23 |
# else |
| 24 |
fprintf(stderr, "warning: not testing malloc failure\n"); |
| 25 |
exit(EXIT_FAILURE); |
| 26 |
#endif |
| 27 |
|
| 28 |
#test-exit(1) test_wrapped_strdup_fail |
| 29 |
#ifdef SUPPORT_COVERAGE |
| 30 |
wrapped_strdup_failure = 1; |
| 31 |
wrapped_strdup("test"); |
| 32 |
# else |
| 33 |
fprintf(stderr, "warning: not testing malloc failure\n"); |
| 34 |
exit(EXIT_FAILURE); |
| 35 |
#endif |
| 36 |
|
| 37 |
#test test_wrapped_malloc |
| 38 |
void *test; |
| 39 |
|
| 40 |
test = wrapped_malloc(16); |
| 41 |
ck_assert((test != NULL)); |
| 42 |
|
| 43 |
#test test_wrapped_strdup |
| 44 |
char *check; |
| 45 |
|
| 46 |
check = wrapped_strdup("so broken"); |
| 47 |
ck_assert_str_eq(check, "so broken"); |