1 /*********************************************************************
2  *   Copyright 2016, UCAR/Unidata
3  *   See netcdf/COPYRIGHT file for copying and redistribution conditions.
4  *********************************************************************/
5 
6 /**
7 Test the NCpathcvt
8 */
9 
10 #include <stdlib.h>
11 #include <stdio.h>
12 #include <string.h>
13 #include "ncwinpath.h"
14 
15 #undef VERBOSE
16 
17 typedef struct Test {
18     char* path;
19     char* expected;
20 } Test;
21 
22 /* Path conversion tests */
23 static Test PATHTESTS[] = {
24 {"/xxx/a/b","/xxx/a/b"},
25 {"d:/x/y","d:\\x\\y"},
26 {"/cygdrive/d/x/y","d:\\x\\y"},
27 {"/d/x/y","d:\\x\\y"},
28 {"/cygdrive/d","d:\\"},
29 {"/d","d:\\"},
30 {"/cygdrive/d/git/netcdf-c/dap4_test/daptestfiles/test_anon_dim.2.syn","d:\\git\\netcdf-c\\dap4_test\\daptestfiles\\test_anon_dim.2.syn"},
31 {"[dap4]file:///cygdrive/d/git/netcdf-c/dap4_test/daptestfiles/test_anon_dim.2.syn","[dap4]file:///cygdrive/d/git/netcdf-c/dap4_test/daptestfiles/test_anon_dim.2.syn"},
32 {NULL,NULL}
33 };
34 
35 int
main(int argc,char ** argv)36 main(int argc, char** argv)
37 {
38     Test* test;
39     int failcount = 0;
40 
41     for(test=PATHTESTS;test->path;test++) {
42 	char* cvt = NCpathcvt(test->path);
43 	if(cvt == NULL) {
44 	    fprintf(stderr,"TEST returned NULL: %s\n",test->path);
45 	    exit(1);
46 	}
47 	if(strcmp(cvt,test->expected) != 0) {
48 	    fprintf(stderr,"NCpathcvt failed:: input: |%s| expected=|%s| actual=|%s|\n",test->path,test->expected,cvt);
49 	    failcount++;
50 	}
51 #ifdef VERBOSE
52 	fprintf(stderr,"NCpathcvt:: input: |%s| actual=|%s|\n",test->path,cvt);
53 #endif
54 	free(cvt);
55     }
56 
57     fprintf(stderr,"%s test_ncuri\n",failcount > 0 ? "***FAIL":"***PASS");
58     return (failcount > 0 ? 1 : 0);
59 }
60