@@ -11,16 +11,16 @@ FILE *_devnull;
11
11
static void
12
12
test_int_field_1d (void )
13
13
{
14
- const int num_rows = 5 ;
14
+ const size_t num_rows = 5 ;
15
15
const int32_t data [] = { 1 , 2 , 12345789 , -1 , -100 };
16
16
vcz_field_t field = { .name = "test" ,
17
17
.type = VCZ_TYPE_INT ,
18
18
.item_size = 4 ,
19
19
.num_columns = 1 ,
20
- .data = data };
20
+ .data = ( const char * ) data };
21
21
char buf [1000 ];
22
22
const char * expected [] = { "1\t" , "2\t" , "12345789\t" , ".\t" , "-100\t" };
23
- int ret ;
23
+ int64_t ret ;
24
24
size_t j ;
25
25
26
26
for (j = 0 ; j < num_rows ; j ++ ) {
@@ -34,16 +34,16 @@ test_int_field_1d(void)
34
34
static void
35
35
test_int_field_2d (void )
36
36
{
37
- const int num_rows = 4 ;
37
+ const size_t num_rows = 4 ;
38
38
const int32_t data [] = { 1 , 2 , 3 , 1234 , 5678 , -2 , -1 , -2 , -2 , -2 , -2 , -2 };
39
39
vcz_field_t field = { .name = "test" ,
40
40
.type = VCZ_TYPE_INT ,
41
41
.item_size = 4 ,
42
42
.num_columns = 3 ,
43
- .data = data };
43
+ .data = ( const char * ) data };
44
44
char buf [1000 ];
45
45
const char * expected [] = { "1,2,3\t" , "1234,5678\t" , ".\t" , "\t" };
46
- int ret ;
46
+ int64_t ret ;
47
47
size_t j ;
48
48
49
49
for (j = 0 ; j < num_rows ; j ++ ) {
@@ -58,7 +58,7 @@ static void
58
58
test_string_field_1d (void )
59
59
{
60
60
/* item_size=3, rows=3, cols=1 */
61
- const int num_rows = 3 ;
61
+ const size_t num_rows = 3 ;
62
62
const char data [] = "X\0\0" /* X */
63
63
"XX\0" /* XX*/
64
64
"XXX" ; /* XXX, */
@@ -70,7 +70,7 @@ test_string_field_1d(void)
70
70
.data = data };
71
71
char buf [1000 ];
72
72
const char * expected [] = { "X\t" , "XX\t" , "XXX\t" };
73
- int ret ;
73
+ int64_t ret ;
74
74
size_t j ;
75
75
76
76
CU_ASSERT_EQUAL_FATAL (sizeof (data ), 10 );
@@ -85,7 +85,7 @@ static void
85
85
test_string_field_2d (void )
86
86
{
87
87
/* item_size=3, rows=3, cols=3 */
88
- const int num_rows = 3 ;
88
+ const size_t num_rows = 3 ;
89
89
const char data [] = "X\0\0Y\0\0\0\0\0" /* [X, Y] */
90
90
"XX\0YY\0Z\0\0" /* [XX, YY, Z], */
91
91
"XXX\0\0\0\0\0" ; /* [XXX], */
@@ -97,7 +97,7 @@ test_string_field_2d(void)
97
97
.data = data };
98
98
char buf [1000 ];
99
99
const char * expected [] = { "X,Y\t" , "XX,YY,Z\t" , "XXX\t" };
100
- int ret ;
100
+ int64_t ret ;
101
101
size_t j ;
102
102
103
103
CU_ASSERT_EQUAL_FATAL (sizeof (data ), 27 );
@@ -113,22 +113,23 @@ static void
113
113
test_variant_encoder_minimal (void )
114
114
{
115
115
// Two rows, one column in each field, two samples
116
- const int num_rows = 2 ;
116
+ const size_t num_rows = 2 ;
117
117
const char contig_data [] = "X\0YY" ;
118
118
const int32_t pos_data [] = { 123 , 45678 };
119
119
const char id_data [] = "RS1RS2" ;
120
120
const char ref_data [] = "AG" ;
121
121
const char alt_data [] = "T" ;
122
- const float qual_data [] = { 9 , 12.1 };
122
+ const float qual_data [] = { 9 , 12.1f };
123
123
const char filter_id_data [] = "PASS\0FILT1" ;
124
- const int8_t filter_data [] = {1 , 0 , 0 , 1 };
124
+ const int8_t filter_data [] = { 1 , 0 , 0 , 1 };
125
125
const int32_t an_data [] = { -1 , 9 };
126
- const char * aa_data = "G." ;
127
- const int8_t flag_data [] = {0 , 1 };
126
+ const char * aa_data = "G." ;
127
+ const int8_t flag_data [] = { 0 , 1 };
128
128
const int32_t gt_data [] = { 0 , 0 , 0 , 1 , 1 , 1 , 1 , 0 };
129
129
const int8_t gt_phased_data [] = { 0 , 1 , 1 , 0 };
130
- const int32_t hq_data [] = { 10 , 15 , 7 , 12 , -1 , -1 , -1 , -1 };
131
- int ret , j ;
130
+ const int32_t hq_data [] = { 10 , 15 , 7 , 12 , -1 , -1 , -1 , -1 };
131
+ int64_t ret ;
132
+ size_t j ;
132
133
vcz_variant_encoder_t writer ;
133
134
const char * expected [] = {
134
135
"X\t123\tRS1\tA\tT\t9\tPASS\tAA=G\tGT:HQ\t0/0:10,15\t0|1:7,12" ,
@@ -137,30 +138,31 @@ test_variant_encoder_minimal(void)
137
138
char buf [1000 ];
138
139
139
140
ret = vcz_variant_encoder_init (& writer , 2 , 2 , contig_data , 2 , pos_data , id_data , 3 ,
140
- 1 , ref_data , 1 , alt_data , 1 , 1 , qual_data ,
141
- filter_id_data , 5 , 2 , filter_data );
141
+ 1 , ref_data , 1 , alt_data , 1 , 1 , qual_data , filter_id_data , 5 , 2 , filter_data );
142
142
CU_ASSERT_EQUAL_FATAL (ret , 0 );
143
143
ret = vcz_variant_encoder_add_gt_field (& writer , gt_data , 4 , 2 , gt_phased_data );
144
144
CU_ASSERT_EQUAL_FATAL (ret , 0 );
145
145
ret = vcz_variant_encoder_add_info_field (& writer , "AN" , VCZ_TYPE_INT , 4 , 1 , an_data );
146
146
CU_ASSERT_EQUAL_FATAL (ret , 0 );
147
- ret = vcz_variant_encoder_add_info_field (& writer , "AA" , VCZ_TYPE_STRING , 1 , 1 , aa_data );
147
+ ret = vcz_variant_encoder_add_info_field (
148
+ & writer , "AA" , VCZ_TYPE_STRING , 1 , 1 , aa_data );
148
149
CU_ASSERT_EQUAL_FATAL (ret , 0 );
149
- ret = vcz_variant_encoder_add_info_field (& writer , "FLAG" , VCZ_TYPE_BOOL , 1 , 1 , flag_data );
150
+ ret = vcz_variant_encoder_add_info_field (
151
+ & writer , "FLAG" , VCZ_TYPE_BOOL , 1 , 1 , flag_data );
150
152
CU_ASSERT_EQUAL_FATAL (ret , 0 );
151
153
ret = vcz_variant_encoder_add_format_field (
152
154
& writer , "HQ" , VCZ_TYPE_INT , 4 , 2 , hq_data );
153
155
CU_ASSERT_EQUAL_FATAL (ret , 0 );
154
156
155
157
vcz_variant_encoder_print_state (& writer , _devnull );
156
- printf ("\n" );
158
+ /* printf("\n"); */
157
159
/* vcz_variant_encoder_print_state(&writer, stdout); */
158
160
159
161
for (j = 0 ; j < num_rows ; j ++ ) {
160
162
ret = vcz_variant_encoder_write_row (& writer , j , buf , 1000 );
161
163
/* printf("ret = %d\n", ret); */
162
- printf ("GOT:%s\n" , buf );
163
- printf ("EXP:%s\n" , expected [j ]);
164
+ /* printf("GOT:%s\n", buf); */
165
+ /* printf("EXP:%s\n", expected[j]); */
164
166
/* printf("GOT:%d\n", (int) strlen(buf)); */
165
167
/* printf("EXP:%d\n", (int) strlen(expected[j])); */
166
168
CU_ASSERT_EQUAL (ret , strlen (expected [j ]));
@@ -186,37 +188,37 @@ test_itoa_small(void)
186
188
}
187
189
}
188
190
189
-
190
191
static void
191
192
test_ftoa (void )
192
193
{
193
194
struct test_case {
194
195
float val ;
195
196
const char * expected ;
196
197
};
198
+ // clang-format off
197
199
struct test_case cases [] = {
198
- {0.0 , "0" },
199
- {0.0001 , "0" },
200
- {0.0005 , "0.001" },
201
- {0.3 , "0.3" },
202
- {0.32 , "0.32" },
203
- {0.329 , "0.329" },
204
- {0.3217 , "0.322" },
205
- {8.0 , "8" },
206
- {8.0001 , "8" },
207
- {8.3 , "8.3" },
208
- {8.32 , "8.32" },
209
- {8.329 , "8.329" },
210
- {8.3217 , "8.322" },
211
- {443.998 , "443.998" },
212
- {1028.0 , "1028" },
213
- {1028.0001 , "1028" },
214
- {1028.3 , "1028.3" },
215
- {1028.32 , "1028.32" },
216
- {1028.329 , "1028.329" },
217
- {1028.3217 , "1028.322" },
200
+ {0.0f , "0" },
201
+ {0.0001f , "0" },
202
+ {0.0005f , "0.001" },
203
+ {0.3f , "0.3" },
204
+ {0.32f , "0.32" },
205
+ {0.329f , "0.329" },
206
+ {0.3217f , "0.322" },
207
+ {8.0f , "8" },
208
+ {8.0001f , "8" },
209
+ {8.3f , "8.3" },
210
+ {8.32f , "8.32" },
211
+ {8.329f , "8.329" },
212
+ {8.3217f , "8.322" },
213
+ {443.998f , "443.998" },
214
+ {1028.0f , "1028" },
215
+ {1028.0001f , "1028" },
216
+ {1028.3f , "1028.3" },
217
+ {1028.32f , "1028.32" },
218
+ {1028.329f , "1028.329" },
219
+ {1028.3217f , "1028.322" },
218
220
{1000000 , "1000000" },
219
- {-100.0 , "-100" },
221
+ {-100.0f , "-100" },
220
222
{NAN , "nan" },
221
223
{INFINITY , "inf" },
222
224
{- INFINITY , "-inf" },
@@ -225,7 +227,9 @@ test_ftoa(void)
225
227
{-16777216 , "-16777216" },
226
228
/* TODO test extreme value here, that push against the limits of f32 */
227
229
};
228
- int j , len ;
230
+ // clang-format on
231
+ int len ;
232
+ size_t j ;
229
233
char buf [1024 ];
230
234
231
235
for (j = 0 ; j < sizeof (cases ) / sizeof (* cases ); j ++ ) {
@@ -267,7 +271,7 @@ handle_cunit_error(void)
267
271
exit (EXIT_FAILURE );
268
272
}
269
273
270
- int
274
+ static int
271
275
test_main (CU_TestInfo * tests , int argc , char * * argv )
272
276
{
273
277
int ret ;
0 commit comments