Package: bibutils / 6.10-2

0001-Correcting-tests-of-slist_add.patch Patch series | 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
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
From: Pierre Gruet <pgtdebian@free.fr>
Date: Fri, 27 Mar 2020 09:39:56 +0100
Subject: Correcting tests of slist_add

---
 test/slist_test.c | 74 ++++++++++++++++++++++++++++---------------------------
 1 file changed, 38 insertions(+), 36 deletions(-)

diff --git a/test/slist_test.c b/test/slist_test.c
index bc1b03b..373e3d1 100644
--- a/test/slist_test.c
+++ b/test/slist_test.c
@@ -96,21 +96,22 @@ test_init( void )
 int
 test_add( void )
 {
-	str s, *t;
+	str s;
+        int status;
 	slist a;
 	str_init( &s );
 	slist_init( &a );
 
 	str_strcpyc( &s, "1" );
-	t = slist_add( &a, &s );
-	check_add_result( t, &s );
+	status = slist_add( &a, &s );
+	check( (status==SLIST_OK), "slist_add() return SLIST_OK on success" );
 	check_len( &a, 1 );
 	check_entry( &a, 0, "1" );
 	check_entry( &a, 1, NULL );
 
 	str_strcpyc( &s, "2" );
-	t = slist_add( &a, &s );
-	check_add_result( t, &s );
+	status = slist_add( &a, &s );
+	check( (status==SLIST_OK), "slist_add() return SLIST_OK on success" );
 	check_len( &a, 2 );
 	check_entry( &a, 0, "1" );
 	check_entry( &a, 1, "2" );
@@ -124,18 +125,18 @@ test_add( void )
 int
 test_addc( void )
 {
-	str *t;
+	int status;
 	slist a;
 	slist_init( &a );
 
-	t = slist_addc( &a, "1" );
-	check_addc_result( t, "1" );
+	status = slist_addc( &a, "1" );
+	check( (status==SLIST_OK), "slist_addc() return SLIST_OK on success" );
 	check_len( &a, 1 );
 	check_entry( &a, 0, "1" );
 	check_entry( &a, 1, NULL );
 
-	t = slist_addc( &a, "2" );
-	check_addc_result( t, "2" );
+	status = slist_addc( &a, "2" );
+	check( (status==SLIST_OK), "slist_addc() return SLIST_OK on success" );
 	check_len( &a, 2 );
 	check_entry( &a, 0, "1" );
 	check_entry( &a, 1, "2" );
@@ -148,20 +149,21 @@ test_addc( void )
 int
 test_addvp( void )
 {
-	str s, *t;
+	str s;
+        int status;
 	slist a;
 	str_init( &s );
 	slist_init( &a );
 
-	t= slist_addvp( &a, SLIST_CHR, "1" );
-	check_addc_result( t, "1" );
+	status= slist_addvp( &a, SLIST_CHR, "1" );
+	check( (status==SLIST_OK), "slist_addvp() return SLIST_OK on success" );
 	check_len( &a, 1 );
 	check_entry( &a, 0, "1" );
 	check_entry( &a, 1, NULL );
 
 	str_strcpyc( &s, "2" );
-	t = slist_addvp( &a, SLIST_STR, &s );
-	check_add_result( t, &s );
+	status = slist_addvp( &a, SLIST_STR, &s );
+	check( (status==SLIST_OK), "slist_addvp() return SLIST_OK on success" );
 	check_len( &a, 2 );
 	check_entry( &a, 0, "1" );
 	check_entry( &a, 1, "2" );
@@ -601,21 +603,22 @@ out:
 int
 test_empty( void )
 {
-	str s, *t;
+	str s;
+        int status;
 	slist a;
 	str_init( &s );
 	slist_init( &a );
 
 	str_strcpyc( &s, "1" );
-	t = slist_add( &a, &s );
-	check_add_result( t, &s );
+	status = slist_add( &a, &s );
+	check( (status==SLIST_OK), "slist_add() return SLIST_OK on success" );
 	check_len( &a, 1 );
 	check_entry( &a, 0, "1" );
 	check_entry( &a, 1, NULL );
 
 	str_strcpyc( &s, "2" );
-	t = slist_add( &a, &s );
-	check_add_result( t, &s );
+	status = slist_add( &a, &s );
+	check( (status==SLIST_OK), "slist_add() return SLIST_OK on success" );
 	check_len( &a, 2 );
 	check_entry( &a, 0, "1" );
 	check_entry( &a, 1, "2" );
@@ -638,7 +641,7 @@ test_new( void )
 {
 	char buf[1000];
 	slist *a;
-	str *tmp;
+	int status;
 	int i;
 
 	a = slist_new();
@@ -651,8 +654,8 @@ test_new( void )
 
 	for ( i=0; i<100; ++i ) {
 		sprintf( buf, "Test%d", i );
-		tmp = slist_addc( a, buf );
-		if ( !tmp ) {
+		status = slist_addc( a, buf );
+		if ( status!=SLIST_OK ) {
 			fprintf( stderr, "Memory error at %s() line %d\n", __FUNCTION__, __LINE__ );
 			goto out;
 		}
@@ -678,15 +681,15 @@ test_dup( void )
 {
 	char buf[1000];
 	slist a, *dupa;
-	str *tmp;
+	int status;
 	int i;
 
 	slist_init( &a );
 
 	for ( i=0; i<100; ++i ) {
 		sprintf( buf, "Test%d", i );
-		tmp = slist_addc( &a, buf );
-		if ( !tmp ) {
+		status = slist_addc( &a, buf );
+		if ( status!=SLIST_OK ) {
 			fprintf( stderr, "Memory error 1 at %s() line %d\n", __FUNCTION__, __LINE__ );
 			goto out;
 		}
@@ -721,14 +724,13 @@ test_copy( void )
 	int i, status, ret = 0;
 	char buf[1000];
 	slist a, copya;
-	str *tmp;
 
 	/* Build and test list to be copied */
 	slist_init( &a );
 	for ( i=0; i<100; ++i ) {
 		sprintf( buf, "ToBeCopied%d", i );
-		tmp = slist_addc( &a, buf );
-		if ( !tmp ) {
+		status = slist_addc( &a, buf );
+		if ( status!=SLIST_OK ) {
 			fprintf( stderr, "Memory error at %s() line %d\n", __FUNCTION__, __LINE__ );
 			goto out;
 		}
@@ -1726,24 +1728,24 @@ test_get_maxlen( void )
 {
 	unsigned long n;
 	slist a;
-	str *t;
+	int status;
 
 	slist_init( &a );
 
-	t = slist_addc( &a, "churlish" );
-	check( (t!=NULL), "slist_addc() should not return NULL" );
+	status = slist_addc( &a, "churlish" );
+	check( (status==SLIST_OK), "slist_addc() should not return NULL" );
 
 	n = slist_get_maxlen( &a );
 	check( (n==strlen("churlish")), "slist_get_maxlen() should return length of 'churlish'" );
 
-	t = slist_addc( &a, "boorish" );
-	check( (t!=NULL), "slist_addc() should not return NULL" );
+	status = slist_addc( &a, "boorish" );
+	check( (status==SLIST_OK), "slist_addc() should not return NULL" );
 
 	n = slist_get_maxlen( &a );
 	check( (n==strlen("churlish")), "slist_get_maxlen() should return length of 'churlish'" );
 
-	t = slist_addc( &a, "amateurish" );
-	check( (t!=NULL), "slist_addc() should not return NULL" );
+	status = slist_addc( &a, "amateurish" );
+	check( (status==SLIST_OK), "slist_addc() should not return NULL" );
 
 	n = slist_get_maxlen( &a );
 	check( (n==strlen("amateurish")), "slist_get_maxlen() should return length of 'amateurish'" );