File: context.c

package info (click to toggle)
libisds 0.9-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,348 kB
  • ctags: 1,659
  • sloc: ansic: 24,898; sh: 11,772; makefile: 393; xml: 375; sed: 16
file content (46 lines) | stat: -rw-r--r-- 973 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "../test.h"
#include "isds.h"

static int test_create(struct isds_ctx **context) {
    if (!context)
        FAIL_TEST("Bad invocation");

    *context = isds_ctx_create();
    if (!*context) 
        FAIL_TEST("isds_ctx_create() failed");

    PASS_TEST;
}

static int test_free(const isds_error error, struct isds_ctx **context) {
    if (!context)
        FAIL_TEST("Bad invocation");

    if (error != isds_ctx_free(context))
        FAIL_TEST("Wrong return code");

    if (*context) 
        FAIL_TEST("context not NULLed");

    PASS_TEST;
}


int main(int argc, char **argv) {
    INIT_TEST("context");
    
    struct isds_ctx *context = NULL;

    if (isds_init())
        ABORT_UNIT("isds_init() failed\n");

    TEST("create", test_create, &context);
    TEST("free valid context", test_free, IE_SUCCESS, &context);

    context = NULL;
    TEST("free invalid context", test_free, IE_INVALID_CONTEXT, &context);

    isds_cleanup();

    SUM_TEST();
}