Ignore:
Timestamp:
2014-09-19T08:23:01Z (10 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c85a57f
Parents:
15d0046
Message:

Update PCUT to newest version

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/pcut/include/pcut/asserts.h

    r15d0046 r9b20126  
    3939#include <errno.h>
    4040
     41/** @def PCUT_CURRENT_FILENAME
     42 * Overwrite contents of __FILE__ when printing assertion errors.
     43 */
     44#ifndef PCUT_CURRENT_FILENAME
     45#define PCUT_CURRENT_FILENAME __FILE__
     46#endif
     47
    4148/** @cond devel */
    4249
     
    4653 * (if registered).
    4754 *
     55 * @param filename File where the assertion occurred.
     56 * @param line Line where the assertion occurred.
    4857 * @param fmt Printf-like format string.
    4958 * @param ... Extra arguments.
    5059 */
    51 void pcut_failed_assertion_fmt(const char *fmt, ...);
     60void pcut_failed_assertion_fmt(const char *filename, int line, const char *fmt, ...);
    5261
    5362/** OS-agnostic string comparison.
     
    7079void pcut_str_error(int error, char *buffer, int size);
    7180
     81/** Raise assertion error (internal version).
     82 *
     83 * We expect to be always called from PCUT_ASSERTION_FAILED() where
     84 * the last argument is empty string to conform to strict ISO C99
     85 * ("ISO C99 requires rest arguments to be used").
     86 *
     87 * @param fmt Printf-like format string.
     88 * @param ... Extra arguments.
     89 */
     90#define PCUT_ASSERTION_FAILED_INTERNAL(fmt, ...) \
     91        pcut_failed_assertion_fmt(PCUT_CURRENT_FILENAME, __LINE__, fmt, __VA_ARGS__)
     92
     93
    7294/** @endcond */
    7395
     
    7799 * abort (tear-down function of the test suite is run when available).
    78100 *
    79  * @param fmt Printf-like format string.
    80  * @param ... Extra arguments.
    81  */
    82 #define PCUT_ASSERTION_FAILED(fmt, ...) \
    83         pcut_failed_assertion_fmt(__FILE__ ":%d: " fmt, __LINE__, ##__VA_ARGS__)
     101 * @param ... Printf-like arguments.
     102 */
     103#define PCUT_ASSERTION_FAILED(...) \
     104        PCUT_ASSERTION_FAILED_INTERNAL(__VA_ARGS__, "")
    84105
    85106
     
    115136 */
    116137#define PCUT_ASSERT_EQUALS(expected, actual) \
    117                 do {\
    118                         if (!((expected) == (actual))) { \
    119                                 PCUT_ASSERTION_FAILED("Expected <"#expected "> but got <" #actual ">"); \
    120                         } \
    121                 } while (0)
     138        do {\
     139                if (!((expected) == (actual))) { \
     140                        PCUT_ASSERTION_FAILED("Expected <"#expected "> but got <" #actual ">"); \
     141                } \
     142        } while (0)
    122143
    123144/** Asserts that given pointer is NULL.
Note: See TracChangeset for help on using the changeset viewer.