curlcheck.h
Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                  _   _ ____  _
00003  *  Project                     ___| | | |  _ \| |
00004  *                             / __| | | | |_) | |
00005  *                            | (__| |_| |  _ <| |___
00006  *                             \___|\___/|_| \_\_____|
00007  *
00008  * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
00009  *
00010  * This software is licensed as described in the file COPYING, which
00011  * you should have received as part of this distribution. The terms
00012  * are also available at https://curl.haxx.se/docs/copyright.html.
00013  *
00014  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
00015  * copies of the Software, and permit persons to whom the Software is
00016  * furnished to do so, under the terms of the COPYING file.
00017  *
00018  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
00019  * KIND, either express or implied.
00020  *
00021  ***************************************************************************/
00022 #include "test.h"
00023 
00024 /* The fail macros mark the current test step as failed, and continue */
00025 #define fail_if(expr, msg)                              \
00026   if(expr) {                                            \
00027     fprintf(stderr, "%s:%d Assertion '%s' met: %s\n",   \
00028             __FILE__, __LINE__, #expr, msg);            \
00029     unitfail++;                                         \
00030   }
00031 
00032 #define fail_unless(expr, msg)                           \
00033   if(!(expr)) {                                          \
00034     fprintf(stderr, "%s:%d Assertion '%s' failed: %s\n", \
00035             __FILE__, __LINE__, #expr, msg);             \
00036     unitfail++;                                          \
00037   }
00038 
00039 #define verify_memory(dynamic, check, len)                                  \
00040   if(dynamic && memcmp(dynamic, check, len)) {                              \
00041     fprintf(stderr, "%s:%d Memory buffer mismatch size %d. '%s' is not\n",  \
00042             __FILE__, __LINE__, len, hexdump((unsigned char *)check, len)); \
00043     fprintf(stderr, "%s:%d the same as '%s'\n",                             \
00044             __FILE__, __LINE__, hexdump((unsigned char *)dynamic, len));    \
00045     unitfail++;                                                             \
00046   }
00047 
00048 /* fail() is for when the test case figured out by itself that a check
00049    proved a failure */
00050 #define fail(msg) do {                                                 \
00051     fprintf(stderr, "%s:%d test failed: '%s'\n",                       \
00052             __FILE__, __LINE__, msg);                                  \
00053     unitfail++;                                                        \
00054   } WHILE_FALSE
00055 
00056 
00057 /* The abort macros mark the current test step as failed, and exit the test */
00058 #define abort_if(expr, msg)                                   \
00059   if(expr) {                                                  \
00060     fprintf(stderr, "%s:%d Abort assertion '%s' met: %s\n",   \
00061             __FILE__, __LINE__, #expr, msg);                  \
00062     unitfail++;                                               \
00063     goto unit_test_abort;                                     \
00064   }
00065 
00066 #define abort_unless(expr, msg)                                \
00067   if(!(expr)) {                                                \
00068     fprintf(stderr, "%s:%d Abort assertion '%s' failed: %s\n", \
00069             __FILE__, __LINE__, #expr, msg);                   \
00070     unitfail++;                                                \
00071     goto unit_test_abort;                                      \
00072   }
00073 
00074 #define abort_test(msg) do {                                  \
00075     fprintf(stderr, "%s:%d test aborted: '%s'\n",             \
00076             __FILE__, __LINE__, msg);                         \
00077     unitfail++;                                               \
00078     goto unit_test_abort;                                     \
00079   } WHILE_FALSE
00080 
00081 
00082 
00083 extern int unitfail;
00084 
00085 #define UNITTEST_START                          \
00086   int test(char *arg)                           \
00087   {                                             \
00088     (void)arg;                                  \
00089     if(unit_setup()) {                          \
00090       fail("unit_setup() failure");             \
00091     }                                           \
00092     else {
00093 
00094 #define UNITTEST_STOP                           \
00095     goto unit_test_abort; /* avoid warning */   \
00096 unit_test_abort:                                \
00097     unit_stop();                                \
00098   }                                             \
00099   return unitfail;                              \
00100   }
00101 


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:02