unit1620.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) 1998 - 2018, 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. #include "urldata.h"
  24. #include "url.h"
  25. #include "memdebug.h" /* LAST include file */
  26. static CURLcode unit_setup(void)
  27. {
  28. return CURLE_OK;
  29. }
  30. static void unit_stop(void)
  31. {
  32. }
  33. UNITTEST_START
  34. {
  35. int rc;
  36. struct Curl_easy *empty;
  37. const char *hostname = "hostname";
  38. enum dupstring i;
  39. bool async = FALSE;
  40. bool protocol_connect = FALSE;
  41. rc = Curl_open(&empty);
  42. fail_unless(rc == CURLE_OK, "Curl_open() failed");
  43. rc = Curl_connect(empty, &async, &protocol_connect);
  44. fail_unless(rc == CURLE_URL_MALFORMAT,
  45. "Curl_connect() failed to return CURLE_URL_MALFORMAT");
  46. fail_unless(empty->magic == CURLEASY_MAGIC_NUMBER,
  47. "empty->magic should be equal to CURLEASY_MAGIC_NUMBER");
  48. /* double invoke to ensure no dependency on internal state */
  49. rc = Curl_connect(empty, &async, &protocol_connect);
  50. fail_unless(rc == CURLE_URL_MALFORMAT,
  51. "Curl_connect() failed to return CURLE_URL_MALFORMAT");
  52. rc = Curl_init_userdefined(empty);
  53. fail_unless(rc == CURLE_OK, "Curl_userdefined() failed");
  54. rc = Curl_init_do(empty, empty->conn);
  55. fail_unless(rc == CURLE_OK, "Curl_init_do() failed");
  56. rc = Curl_parse_login_details(
  57. hostname, strlen(hostname), NULL, NULL, NULL);
  58. fail_unless(rc == CURLE_OK,
  59. "Curl_parse_login_details() failed");
  60. rc = Curl_disconnect(empty, empty->conn, FALSE);
  61. fail_unless(rc == CURLE_OK,
  62. "Curl_disconnect() with dead_connection set FALSE failed");
  63. Curl_freeset(empty);
  64. for(i = (enum dupstring)0; i < STRING_LAST; i++) {
  65. fail_unless(empty->set.str[i] == NULL,
  66. "Curl_free() did not set to NULL");
  67. }
  68. Curl_free_request_state(empty);
  69. rc = Curl_close(empty);
  70. fail_unless(rc == CURLE_OK, "Curl_close() failed");
  71. }
  72. UNITTEST_STOP