Skip to content

Commit

Permalink
FFI test macros print a source location
Browse files Browse the repository at this point in the history
  • Loading branch information
reneme committed Apr 4, 2024
1 parent e9c6c16 commit 619b350
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/tests/test_ffi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,23 @@ namespace {
#if defined(BOTAN_HAS_FFI)

// NOLINTNEXTLINE(*-macro-usage)
#define TEST_FFI_OK(func, args) result.test_rc_ok(#func, func args)
#define _TEST_FFI_STR_HELPER(x) #x
// NOLINTNEXTLINE(*-macro-usage)
#define TEST_FFI_INIT(func, args) result.test_rc_init(#func, func args)
#define _TEST_FFI_STR(x) _TEST_FFI_STR_HELPER(x)
// NOLINTNEXTLINE(*-macro-usage)
#define TEST_FFI_FAIL(msg, func, args) result.test_rc_fail(#func, msg, func args)
#define _TEST_FFI_SOURCE_LOCATION(func, file, line) (func " invoked at " file ":" _TEST_FFI_STR(line))

// NOLINTNEXTLINE(*-macro-usage)
#define TEST_FFI_OK(func, args) result.test_rc_ok(_TEST_FFI_SOURCE_LOCATION(#func, __FILE__, __LINE__), func args)
// NOLINTNEXTLINE(*-macro-usage)
#define TEST_FFI_INIT(func, args) \
result.test_rc_init(_TEST_FFI_SOURCE_LOCATION(#func, __FILE__, __LINE__), func args)
// NOLINTNEXTLINE(*-macro-usage)
#define TEST_FFI_FAIL(msg, func, args) \
result.test_rc_fail(_TEST_FFI_SOURCE_LOCATION(#func, __FILE__, __LINE__), msg, func args)
// NOLINTNEXTLINE(*-macro-usage)
#define TEST_FFI_RC(rc, func, args) result.test_rc(#func, rc, func args)
#define TEST_FFI_RC(rc, func, args) \
result.test_rc(_TEST_FFI_SOURCE_LOCATION(#func, __FILE__, __LINE__), rc, func args)

// NOLINTNEXTLINE(*-macro-usage)
#define REQUIRE_FFI_OK(func, args) \
Expand Down

0 comments on commit 619b350

Please sign in to comment.