Fix possibly undefined values
[libisds.git] / test / context.c
blob8e31235e8ba26a02895ab82b606588eb8e5fbe77
1 #include "test.h"
2 #include "isds.h"
4 static int test_create(struct isds_ctx **context) {
5 if (!context)
6 FAIL_TEST("Bad invocation");
8 *context = isds_ctx_create();
9 if (!*context)
10 FAIL_TEST("isds_ctx_create() failed");
12 PASS_TEST;
15 static int test_free(const isds_error error, struct isds_ctx **context) {
16 if (!context)
17 FAIL_TEST("Bad invocation");
19 if (error != isds_ctx_free(context))
20 FAIL_TEST("Wrong return code");
22 if (*context)
23 FAIL_TEST("context not NULLed");
25 PASS_TEST;
29 int main(int argc, char **argv) {
30 INIT_TEST("context");
32 struct isds_ctx *context = NULL;
34 if (isds_init())
35 ABORT_UNIT("isds_init() failed\n");
37 TEST("create", test_create, &context);
38 TEST("free valid context", test_free, IE_SUCCESS, &context);
40 context = NULL;
41 TEST("free invalid context", test_free, IE_INVALID_CONTEXT, &context);
43 isds_cleanup();
45 SUM_TEST();