summaryrefslogtreecommitdiff
path: root/cp/test/src/test_conn.c
blob: 074458f9696779b59fef08a6466b62134334fe13 (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* Cesar project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    cp/test/test_conn.c
 * \brief   unit tests for conn module
 * \ingroup cp_test
 */

#include "common/std.h"
#include "cp/test/inc/test_conn.h"

/*
 * Test de void interf_init(void);
 */
int cp_conn_init_test (void)
{
    cp_conn_init ();
    return 0;
}

/*
 * test de cp_conn_cid_2_index(u16 cid)
 */
int 
cp_conn_cid_2_index_test(void)
{
    if(cp_conn_cid_2_index(0) != 0) return 1;
    if(cp_conn_cid_2_index(0xFF00) != 0x00FF) return 2;
    return 0;
}


struct interf_test_t
{
    int(*func) (void);
    char func_name[30];
};

int 
conn_test (bool verbose)
{
    unsigned int i;
    int res, return_value = 0;
    struct interf_test_t my_test[]= 
            { 
                { cp_conn_init_test, "cp_conn_init" },
                { cp_conn_cid_2_index_test, "cp_conn_cid_2_index" }
            };

    printf ("test du module conn\n");
    for (i=0 ; i<COUNT(my_test) ; i++)
    {
        res = my_test[i].func ();
        if(verbose || (res != 0))
        {
            printf ("    %-50s", my_test[i].func_name);
            if (res == 0) printf ("OK\n");
            else printf ("FAILED : %i\n", res);
        }
        if(res != 0) return_value++;
    }
    if (i != COUNT(my_test)) return 1;
    return return_value;
}