00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "curlcheck.h"
00023
00024 #include "tool_getparam.h"
00025
00026 #include <stdio.h>
00027 #include <stdlib.h>
00028 #include <string.h>
00029
00030 #include "memdebug.h"
00031
00032 static CURLcode unit_setup(void)
00033 {
00034 return CURLE_OK;
00035 }
00036
00037 static void unit_stop(void)
00038 {
00039
00040 }
00041
00042 UNITTEST_START
00043
00044 const char *values[] = {
00045
00046 "foo:bar:baz", "foo", "bar:baz",
00047 "foo\\:bar:baz", "foo:bar", "baz",
00048 "foo\\\\:bar:baz", "foo\\", "bar:baz",
00049 "foo:bar\\:baz", "foo", "bar\\:baz",
00050 "foo:bar\\\\:baz", "foo", "bar\\\\:baz",
00051 "foo\\bar\\baz", "foo\\bar\\baz", NULL,
00052 "foo\\\\bar\\\\baz", "foo\\bar\\baz", NULL,
00053 "foo\\", "foo\\", NULL,
00054 "foo\\\\", "foo\\", NULL,
00055 "foo:bar\\", "foo", "bar\\",
00056 "foo:bar\\\\", "foo", "bar\\\\",
00057 "foo:bar:", "foo", "bar:",
00058 "foo\\::bar\\:", "foo:", "bar\\:",
00059 #ifdef WIN32
00060 "c:\\foo:bar:baz", "c:\\foo", "bar:baz",
00061 "c:\\foo\\:bar:baz", "c:\\foo:bar", "baz",
00062 "c:\\foo\\\\:bar:baz", "c:\\foo\\", "bar:baz",
00063 "c:\\foo:bar\\:baz", "c:\\foo", "bar\\:baz",
00064 "c:\\foo:bar\\\\:baz", "c:\\foo", "bar\\\\:baz",
00065 "c:\\foo\\bar\\baz", "c:\\foo\\bar\\baz", NULL,
00066 "c:\\foo\\\\bar\\\\baz", "c:\\foo\\bar\\baz", NULL,
00067 "c:\\foo\\", "c:\\foo\\", NULL,
00068 "c:\\foo\\\\", "c:\\foo\\", NULL,
00069 "c:\\foo:bar\\", "c:\\foo", "bar\\",
00070 "c:\\foo:bar\\\\", "c:\\foo", "bar\\\\",
00071 "c:\\foo:bar:", "c:\\foo", "bar:",
00072 "c:\\foo\\::bar\\:", "c:\\foo:", "bar\\:",
00073 #endif
00074 NULL, NULL, NULL,
00075 };
00076 const char **p;
00077 char *certname, *passphrase;
00078 for(p = values; *p; p += 3) {
00079 parse_cert_parameter(p[0], &certname, &passphrase);
00080 if(p[1]) {
00081 if(certname) {
00082 if(strcmp(p[1], certname)) {
00083 printf("expected certname '%s' but got '%s' "
00084 "for -E param '%s'\n", p[1], certname, p[0]);
00085 fail("assertion failure");
00086 }
00087 }
00088 else {
00089 printf("expected certname '%s' but got NULL "
00090 "for -E param '%s'\n", p[1], p[0]);
00091 fail("assertion failure");
00092 }
00093 }
00094 else {
00095 if(certname) {
00096 printf("expected certname NULL but got '%s' "
00097 "for -E param '%s'\n", certname, p[0]);
00098 fail("assertion failure");
00099 }
00100 }
00101 if(p[2]) {
00102 if(passphrase) {
00103 if(strcmp(p[2], passphrase)) {
00104 printf("expected passphrase '%s' but got '%s'"
00105 "for -E param '%s'\n", p[2], passphrase, p[0]);
00106 fail("assertion failure");
00107 }
00108 }
00109 else {
00110 printf("expected passphrase '%s' but got NULL "
00111 "for -E param '%s'\n", p[2], p[0]);
00112 fail("assertion failure");
00113 }
00114 }
00115 else {
00116 if(passphrase) {
00117 printf("expected passphrase NULL but got '%s' "
00118 "for -E param '%s'\n", passphrase, p[0]);
00119 fail("assertion failure");
00120 }
00121 }
00122 if(certname) free(certname);
00123 if(passphrase) free(passphrase);
00124 }
00125
00126 UNITTEST_STOP