2
0

lib1912.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) 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.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. * SPDX-License-Identifier: curl
  22. *
  23. ***************************************************************************/
  24. #include "test.h"
  25. #include "testutil.h"
  26. #include "warnless.h"
  27. #include "memdebug.h"
  28. #define print_err(name, exp) \
  29. fprintf(stderr, "Type mismatch for CURLOPT_%s (expected %s)\n", name, exp);
  30. CURLcode test(char *URL)
  31. {
  32. /* Only test if GCC typechecking is available */
  33. int error = 0;
  34. #ifdef CURLINC_TYPECHECK_GCC_H
  35. const struct curl_easyoption *o;
  36. for(o = curl_easy_option_next(NULL);
  37. o;
  38. o = curl_easy_option_next(o)) {
  39. CURL_IGNORE_DEPRECATION(
  40. /* Test for mismatch OR missing typecheck macros */
  41. if(curlcheck_long_option(o->id) !=
  42. (o->type == CURLOT_LONG || o->type == CURLOT_VALUES)) {
  43. print_err(o->name, "CURLOT_LONG or CURLOT_VALUES");
  44. error++;
  45. }
  46. if(curlcheck_off_t_option(o->id) != (o->type == CURLOT_OFF_T)) {
  47. print_err(o->name, "CURLOT_OFF_T");
  48. error++;
  49. }
  50. if(curlcheck_string_option(o->id) != (o->type == CURLOT_STRING)) {
  51. print_err(o->name, "CURLOT_STRING");
  52. error++;
  53. }
  54. if(curlcheck_slist_option(o->id) != (o->type == CURLOT_SLIST)) {
  55. print_err(o->name, "CURLOT_SLIST");
  56. error++;
  57. }
  58. if(curlcheck_cb_data_option(o->id) != (o->type == CURLOT_CBPTR)) {
  59. print_err(o->name, "CURLOT_CBPTR");
  60. error++;
  61. }
  62. /* From here: only test that the type matches if macro is known */
  63. if(curlcheck_write_cb_option(o->id) && (o->type != CURLOT_FUNCTION)) {
  64. print_err(o->name, "CURLOT_FUNCTION");
  65. error++;
  66. }
  67. if(curlcheck_conv_cb_option(o->id) && (o->type != CURLOT_FUNCTION)) {
  68. print_err(o->name, "CURLOT_FUNCTION");
  69. error++;
  70. }
  71. if(curlcheck_postfields_option(o->id) && (o->type != CURLOT_OBJECT)) {
  72. print_err(o->name, "CURLOT_OBJECT");
  73. error++;
  74. }
  75. /* Todo: no gcc typecheck for CURLOPTTYPE_BLOB types? */
  76. )
  77. }
  78. #endif
  79. (void)URL;
  80. return error == 0 ? CURLE_OK : TEST_ERR_FAILURE;
  81. }