Annotation of embedaddon/curl/tests/unit/unit1621.c, revision 1.1
1.1 ! misho 1: /***************************************************************************
! 2: * _ _ ____ _
! 3: * Project ___| | | | _ \| |
! 4: * / __| | | | |_) | |
! 5: * | (__| |_| | _ <| |___
! 6: * \___|\___/|_| \_\_____|
! 7: *
! 8: * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
! 9: *
! 10: * This software is licensed as described in the file COPYING, which
! 11: * you should have received as part of this distribution. The terms
! 12: * are also available at https://curl.haxx.se/docs/copyright.html.
! 13: *
! 14: * You may opt to use, copy, modify, merge, publish, distribute and/or sell
! 15: * copies of the Software, and permit persons to whom the Software is
! 16: * furnished to do so, under the terms of the COPYING file.
! 17: *
! 18: * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
! 19: * KIND, either express or implied.
! 20: *
! 21: ***************************************************************************/
! 22: #include "curlcheck.h"
! 23:
! 24: #include "urldata.h"
! 25: #include "url.h"
! 26:
! 27: #include "memdebug.h" /* LAST include file */
! 28:
! 29: static CURLcode unit_setup(void)
! 30: {
! 31: return CURLE_OK;
! 32: }
! 33:
! 34: static void unit_stop(void)
! 35: {
! 36: }
! 37:
! 38: #if defined(__MINGW32__) || \
! 39: (!defined(HAVE_FSETXATTR) && \
! 40: (!defined(__FreeBSD_version) || (__FreeBSD_version < 500000)))
! 41: UNITTEST_START
! 42: {
! 43: return 0;
! 44: }
! 45: UNITTEST_STOP
! 46: #else
! 47:
! 48: bool stripcredentials(char **url);
! 49:
! 50: struct checkthis {
! 51: const char *input;
! 52: const char *output;
! 53: };
! 54:
! 55: static struct checkthis tests[] = {
! 56: { "ninja://foo@example.com", "ninja://foo@example.com" },
! 57: { "https://foo@example.com", "https://example.com/" },
! 58: { "https://localhost:45", "https://localhost:45/" },
! 59: { "https://foo@localhost:45", "https://localhost:45/" },
! 60: { "http://daniel:password@localhost", "http://localhost/" },
! 61: { "http://daniel@localhost", "http://localhost/" },
! 62: { "http://localhost/", "http://localhost/" },
! 63: { NULL, NULL } /* end marker */
! 64: };
! 65:
! 66: UNITTEST_START
! 67: {
! 68: bool cleanup;
! 69: char *url;
! 70: int i;
! 71: int rc = 0;
! 72:
! 73: for(i = 0; tests[i].input; i++) {
! 74: url = (char *)tests[i].input;
! 75: cleanup = stripcredentials(&url);
! 76: printf("Test %u got input \"%s\", output: \"%s\"\n",
! 77: i, tests[i].input, url);
! 78:
! 79: if(strcmp(tests[i].output, url)) {
! 80: fprintf(stderr, "Test %u got input \"%s\", expected output \"%s\"\n"
! 81: " Actual output: \"%s\"\n", i, tests[i].input, tests[i].output,
! 82: url);
! 83: rc++;
! 84: }
! 85: if(cleanup)
! 86: curl_free(url);
! 87: }
! 88: return rc;
! 89: }
! 90: UNITTEST_STOP
! 91: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>