summaryrefslogtreecommitdiff
path: root/csv-test.c
diff options
context:
space:
mode:
Diffstat (limited to 'csv-test.c')
-rw-r--r--csv-test.c38
1 files changed, 31 insertions, 7 deletions
diff --git a/csv-test.c b/csv-test.c
index 201e3f1..ab996b4 100644
--- a/csv-test.c
+++ b/csv-test.c
@@ -56,7 +56,7 @@ test_line_endings1(void)
56 assert(strcmp(csv_field(&csv, 1), "E") == 0); 56 assert(strcmp(csv_field(&csv, 1), "E") == 0);
57 assert(strcmp(csv_field(&csv, 2), "F") == 0); 57 assert(strcmp(csv_field(&csv, 2), "F") == 0);
58 58
59 assert(csv_read(&csv, f) == EOF); 59 assert(csv_read(&csv, f) == 0);
60 60
61 FMEMCLOSE(f); 61 FMEMCLOSE(f);
62} 62}
@@ -84,7 +84,7 @@ test_line_endings2(void)
84 assert(strcmp(csv_field(&csv, 1), "E") == 0); 84 assert(strcmp(csv_field(&csv, 1), "E") == 0);
85 assert(strcmp(csv_field(&csv, 2), "F") == 0); 85 assert(strcmp(csv_field(&csv, 2), "F") == 0);
86 86
87 assert(csv_read(&csv, f) == EOF); 87 assert(csv_read(&csv, f) == 0);
88 88
89 FMEMCLOSE(f); 89 FMEMCLOSE(f);
90} 90}
@@ -233,7 +233,7 @@ test_empty_fields(void)
233 assert(strcmp(csv_field(&csv, 2), "") == 0); 233 assert(strcmp(csv_field(&csv, 2), "") == 0);
234 234
235 // EOF 235 // EOF
236 assert(csv_read(&csv, f) == EOF); 236 assert(csv_read(&csv, f) == 0);
237 237
238 FMEMCLOSE(f); 238 FMEMCLOSE(f);
239} 239}
@@ -382,7 +382,7 @@ test_simple_fields(void)
382 assert(strcmp(csv_field(&csv, 2), "C") == 0); 382 assert(strcmp(csv_field(&csv, 2), "C") == 0);
383 383
384 // EOF 384 // EOF
385 assert(csv_read(&csv, f) == EOF); 385 assert(csv_read(&csv, f) == 0);
386 386
387 FMEMCLOSE(f); 387 FMEMCLOSE(f);
388} 388}
@@ -405,7 +405,7 @@ test_quoted_fields(void)
405 assert(strcmp(csv_field(&csv, 3), "foo \"baz\" bar") == 0); 405 assert(strcmp(csv_field(&csv, 3), "foo \"baz\" bar") == 0);
406 assert(strcmp(csv_field(&csv, 4), "foo \"baz\", bar") == 0); 406 assert(strcmp(csv_field(&csv, 4), "foo \"baz\", bar") == 0);
407 407
408 assert(csv_read(&csv, f) == EOF); 408 assert(csv_read(&csv, f) == 0);
409 409
410 FMEMCLOSE(f); 410 FMEMCLOSE(f);
411} 411}
@@ -424,7 +424,7 @@ test_wrong_quoted_field(void)
424 assert(csv_nfields(&csv) == 1); 424 assert(csv_nfields(&csv) == 1);
425 assert(strcmp(csv_field(&csv, 0), "foo") == 0); 425 assert(strcmp(csv_field(&csv, 0), "foo") == 0);
426 426
427 assert(csv_read(&csv, f) == EOF); 427 assert(csv_read(&csv, f) == 0);
428 428
429 FMEMCLOSE(f); 429 FMEMCLOSE(f);
430} 430}
@@ -488,7 +488,7 @@ test_read_error(void)
488 488
489 switch ( setjmp(env) ) { 489 switch ( setjmp(env) ) {
490 case CSV_ERR_OK: 490 case CSV_ERR_OK:
491 assert(csv_read(&csv, f) == EOF); 491 assert(csv_read(&csv, f) == 0);
492 break; 492 break;
493 493
494 case CSV_ERR_IO_READ: 494 case CSV_ERR_IO_READ:
@@ -580,9 +580,33 @@ test_allocation_error1(void)
580 FMEMCLOSE(f); 580 FMEMCLOSE(f);
581} 581}
582 582
583void
584show_version(void)
585{
586 const char *version = csv_version;
587
588 printf("Version: ");
589 for ( ; *version; ++version ) {
590 putchar(*version);
591 }
592
593 printf(", Build Date: ");
594 for ( ++version; *version; ++version ) {
595 putchar(*version);
596 }
597
598 printf(", Build Time: ");
599 for ( ++version; *version; ++version ) {
600 putchar(*version);
601 }
602 putchar('\n');
603}
604
583int 605int
584main(void) 606main(void)
585{ 607{
608 show_version();
609
586 test_empty_object(); 610 test_empty_object();
587 test_line_endings1(); 611 test_line_endings1();
588 test_line_endings2(); 612 test_line_endings2();