Changeset 9b20126 in mainline for uspace/lib/pcut/include/pcut/asserts.h
- Timestamp:
- 2014-09-19T08:23:01Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c85a57f
- Parents:
- 15d0046
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/pcut/include/pcut/asserts.h
r15d0046 r9b20126 39 39 #include <errno.h> 40 40 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 41 48 /** @cond devel */ 42 49 … … 46 53 * (if registered). 47 54 * 55 * @param filename File where the assertion occurred. 56 * @param line Line where the assertion occurred. 48 57 * @param fmt Printf-like format string. 49 58 * @param ... Extra arguments. 50 59 */ 51 void pcut_failed_assertion_fmt(const char *f mt, ...);60 void pcut_failed_assertion_fmt(const char *filename, int line, const char *fmt, ...); 52 61 53 62 /** OS-agnostic string comparison. … … 70 79 void pcut_str_error(int error, char *buffer, int size); 71 80 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 72 94 /** @endcond */ 73 95 … … 77 99 * abort (tear-down function of the test suite is run when available). 78 100 * 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__, "") 84 105 85 106 … … 115 136 */ 116 137 #define PCUT_ASSERT_EQUALS(expected, actual) \ 117 118 119 120 121 138 do {\ 139 if (!((expected) == (actual))) { \ 140 PCUT_ASSERTION_FAILED("Expected <"#expected "> but got <" #actual ">"); \ 141 } \ 142 } while (0) 122 143 123 144 /** Asserts that given pointer is NULL.
Note:
See TracChangeset
for help on using the changeset viewer.