diff options
| author | William Casarin <jb55@jb55.com> | 2018-07-09 12:10:32 -0700 |
|---|---|---|
| committer | William Casarin <jb55@jb55.com> | 2018-07-09 12:10:32 -0700 |
| commit | 1b8fbbd843ddeb5fc81c9303db9c590a436d499b (patch) | |
| tree | a7227dfe8e4fbaee7b1e0b58b24994dce8078f3f /ccan/take/test/run-debug.c | |
| parent | 37a9cdd2e80386f2c94e14e4f511284ae14c745a (diff) | |
progress
Diffstat (limited to 'ccan/take/test/run-debug.c')
| -rw-r--r-- | ccan/take/test/run-debug.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/ccan/take/test/run-debug.c b/ccan/take/test/run-debug.c new file mode 100644 index 0000000..a9dda6e --- /dev/null +++ b/ccan/take/test/run-debug.c @@ -0,0 +1,34 @@ +#include <stdlib.h> +#include <stdbool.h> + +#define CCAN_TAKE_DEBUG 1 +#include <ccan/take/take.h> +#include <ccan/take/take.c> +#include <ccan/tap/tap.h> + +int main(void) +{ + const char *p = "hi"; + + plan_tests(14); + + /* We can take NULL. */ + ok1(take(NULL) == NULL); + ok1(is_taken(NULL)); + ok1(strstr(taken_any(), "run-debug.c:16:")); + ok1(taken(NULL)); /* Undoes take() */ + ok1(!is_taken(NULL)); + ok1(!taken(NULL)); + ok1(!taken_any()); + + /* We can take a real pointer. */ + ok1(take(p) == p); + ok1(is_taken(p)); + ok1(strends(taken_any(), "run-debug.c:25:p")); + ok1(taken(p)); /* Undoes take() */ + ok1(!is_taken(p)); + ok1(!taken(p)); + ok1(!taken_any()); + + return exit_status(); +} |
