diff options
author | kobalicek <kobalicek.petr@gmail.com> | 2019-12-24 17:57:59 +0300 |
---|---|---|
committer | kobalicek <kobalicek.petr@gmail.com> | 2019-12-24 17:57:59 +0300 |
commit | eea0a22b3b612cc0a5274c03fb79010f982170bc (patch) | |
tree | a6aca03c7547008ef28499a84c7eb5fa1f2e2270 /test | |
parent | ac77dfcd75f043e2fe317133a971040e5b999916 (diff) |
Hash table update
Diffstat (limited to 'test')
-rw-r--r-- | test/asmjit_test_x86_cc.cpp | 4 | ||||
-rw-r--r-- | test/broken.cpp | 16 | ||||
-rw-r--r-- | test/broken.h | 25 |
3 files changed, 26 insertions, 19 deletions
diff --git a/test/asmjit_test_x86_cc.cpp b/test/asmjit_test_x86_cc.cpp index 9175201..6fb144e 100644 --- a/test/asmjit_test_x86_cc.cpp +++ b/test/asmjit_test_x86_cc.cpp @@ -504,13 +504,13 @@ public: cc.setArg(1, val); cc.cmp(val, 0); - cc.je(L0); + cc.je(L2); cc.cmp(val, 1); cc.je(L1); cc.cmp(val, 2); - cc.je(L2); + cc.je(L0); cc.mov(x86::dword_ptr(dst), val); cc.jmp(LEnd); diff --git a/test/broken.cpp b/test/broken.cpp index eae6e5c..1d3ddfa 100644 --- a/test/broken.cpp +++ b/test/broken.cpp @@ -271,16 +271,20 @@ void BrokenAPI::info(const char* fmt, ...) noexcept { va_end(ap); } -void BrokenAPI::fail(const char* file, int line, const char* fmt, ...) noexcept { +void BrokenAPI::fail(const char* file, int line, const char* expression, const char* fmt, ...) noexcept { BrokenGlobal& global = _brokenGlobal; FILE* dst = global.file(); - va_list ap; - va_start(ap, fmt); - BrokenAPI_printMessage(" FAILED!", fmt, ap); - va_end(ap); + fprintf(dst, " FAILED: %s\n", expression); + + if (fmt) { + va_list ap; + va_start(ap, fmt); + BrokenAPI_printMessage(" REASON: ", fmt, ap); + va_end(ap); + } - fprintf(dst, " File: %s (Line: %d)\n", file, line); + fprintf(dst, " SOURCE: %s (Line: %d)\n", file, line); fflush(dst); exit(1); diff --git a/test/broken.h b/test/broken.h index 9923ce1..1cc04e2 100644 --- a/test/broken.h +++ b/test/broken.h @@ -70,20 +70,20 @@ struct BrokenAPI { static void info(const char* fmt, ...) noexcept; //! Called on `EXPECT()` failure. - static void fail(const char* file, int line, const char* fmt, ...) noexcept; + static void fail(const char* file, int line, const char* expression, const char* fmt, ...) noexcept; //! Used internally by `EXPECT` macro. template<typename T> - static inline void expect(const char* file, int line, const T& exp) noexcept { - if (!exp) - fail(file, line, nullptr); + static inline void expect(const char* file, int line, const char* expression, const T& result) noexcept { + if (!result) + fail(file, line, expression, nullptr); } //! Used internally by `EXPECT` macro. template<typename T, typename... Args> - static inline void expect(const char* file, int line, const T& exp, const char* fmt, Args&&... args) noexcept { - if (!exp) - fail(file, line, fmt, std::forward<Args>(args)...); + static inline void expect(const char* file, int line, const char* expression, const T& result, const char* fmt, Args&&... args) noexcept { + if (!result) + fail(file, line, expression, fmt, std::forward<Args>(args)...); } }; @@ -92,11 +92,14 @@ struct BrokenAPI { // ============================================================================ //! Internal macro used by `UNIT()`. -#define UNIT_INTERNAL(NAME, ...) \ +#define BROKEN_UNIT_INTERNAL(NAME, PRIORITY) \ static void unit_##NAME##_entry(void); \ - static ::BrokenAPI::AutoUnit unit_##NAME##_autoinit(unit_##NAME##_entry, #NAME, __VA_ARGS__); \ + static ::BrokenAPI::AutoUnit unit_##NAME##_autoinit(unit_##NAME##_entry, #NAME, PRIORITY); \ static void unit_##NAME##_entry(void) +//! Stringifies the expression used by EXPECT(). +#define BROKEN_STRINFIGY_EXPRESSION_INTERNAL(EXP, ...) #EXP + //! \def UNIT(NAME [, PRIORITY]) //! //! Define a unit test with an optional priority. @@ -107,7 +110,7 @@ struct BrokenAPI { //! `PRIORITY` specifies the order in which unit tests are run. Lesses value //! increases the priority. At the moment all units are first sorted by //! priority and then by name - this makes the run always deterministic. -#define UNIT(...) UNIT_INTERNAL(__VA_ARGS__, 0) +#define UNIT(NAME, ...) BROKEN_UNIT_INTERNAL(NAME, __VA_ARGS__ + 0) //! #define INFO(FORMAT [, ...]) //! @@ -117,7 +120,7 @@ struct BrokenAPI { //! #define INFO(EXP [, FORMAT [, ...]]) //! //! Expect `EXP` to be true or evaluates to true, fail otherwise. -#define EXPECT(...) ::BrokenAPI::expect(__FILE__, __LINE__, __VA_ARGS__) +#define EXPECT(...) ::BrokenAPI::expect(__FILE__, __LINE__, BROKEN_STRINFIGY_EXPRESSION_INTERNAL(__VA_ARGS__), __VA_ARGS__) //! \endcond |