Statistics
| Branch: | Tag: | Revision:

sssimulator / EventScheduler / Test / action_event_test.c @ af271552

History | View | Annotate | Download (1.2 KB)

1
/*
2
 * this is sssim: the simple & stupid simulator
3
 *
4
 *  copyright (c) 2015 luca baldesi
5
 *
6
 *  this is free software; see gpl-3.0.txt
7
 */
8

    
9
#include<malloc.h>
10
#include<assert.h>
11

    
12
#include"action_event.h"
13

    
14
int globalv;
15

    
16
int inc_globalv(struct action_event * ev)
17
{
18
        globalv++;
19
        return 0;
20
}
21

    
22
void action_event_new_test()
23
{
24
        struct action_event * ae;
25

    
26
        ae = action_event_new(NULL);
27
        assert(ae != NULL);
28
        action_event_destroy(&ae);
29
        assert(ae == NULL);
30

    
31
        globalv = 0;
32
        ae = action_event_new(inc_globalv);
33
        assert(ae != NULL);
34
        action_event_trigger(ae);
35
        assert(globalv == 1);
36
        action_event_destroy(&ae);
37
        assert(ae == NULL);
38

    
39
        fprintf(stderr,"%s successfully passed!\n",__func__);
40
}
41

    
42
void action_event_trigger_test()
43
{
44
        struct action_event * ae;
45

    
46
        globalv = 0;
47
        ae = action_event_new(inc_globalv);
48
        assert(ae != NULL);
49
        action_event_trigger(ae);
50
        assert(globalv == 1);
51
        action_event_destroy(&ae);
52
        assert(ae == NULL);
53

    
54
        fprintf(stderr,"%s successfully passed!\n",__func__);
55
}
56

    
57
void action_event_destroy_test()
58
{
59
        action_event_destroy(NULL);
60
        fprintf(stderr,"%s successfully passed!\n",__func__);
61
}
62

    
63
int main(char ** argc,int argv)
64
{
65
        action_event_new_test();
66
        action_event_destroy_test();
67
        action_event_trigger_test();
68
        return 0;
69
}