/
common.t.c
113 lines (83 loc) · 1.99 KB
/
common.t.c
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
* common.t.c
* This file is part of dutils library collection
* Copyright (C) 2014 Darcy Bras da Silva
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/
*/
#define LOUD
#include "common.h"
int main(int argc, char **argv)
{
{
void *data = NULL;
void *qata = NULL;
wmsg("testing defaul functions\n");
wmsg("int_copy");
assert( !data && !qata );
data = int_copy(10);
qata = int_copy(10);
assert( data && 10 == *(int*)data );
assert( qata && 10 == *(int*)qata );
//clean up
free(data);
free(qata);
wmsg("[OK]\n");
}
{
void *data = NULL;
data = int_copy(10);
wmsg("print_test");
assert( -1 == print_test_global );
assert( (print_test(data), !print_test_global) );
free(data);
wmsg("[OK]\n");
}
{
void *data = NULL;
void *qata = NULL;
data = int_copy(10);
qata = int_copy(10);
wmsg("cmp_int");
assert( !cmp_int(data, qata) );
//clean up
free(data);
free(qata);
wmsg("[OK]\n");
}
{
void *data = NULL;
wmsg("int_dalloc");
data = int_copy(10);
int_dalloc(data);
wmsg("[OK]\n");
}
{
void *data = NULL;
data = int_copy(10);
wmsg("action_test");
assert( !action_test(NULL, data, NULL) );
free(data);
wmsg("[OK]\n");
}
{
void *data = NULL;
data = int_copy(1000);
wmsg("action_reverse_print_test");
assert( 1000 == *(int*)action_reverse_print_test(NULL, data, NULL) );
free(data);
wmsg("[OK]\n");
}
return 0;
}