mirror of
https://github.com/NVIDIA/nvbench.git
synced 2026-04-19 22:38:52 +00:00
Refactor nvbench::state to use this for axis parameters. These will also be useful for summaries and measurements. Also adds a new ASSERT_THROWS_ANY macro to test some of the new API.
54 lines
3.6 KiB
Plaintext
54 lines
3.6 KiB
Plaintext
#pragma once
|
|
|
|
#include <fmt/format.h>
|
|
|
|
#define ASSERT(cond) \
|
|
do \
|
|
{ \
|
|
if (cond) \
|
|
{} \
|
|
else \
|
|
{ \
|
|
fmt::print("{}:{}: Assertion failed ({}).\n", __FILE__, __LINE__, #cond); \
|
|
exit(EXIT_FAILURE); \
|
|
} \
|
|
} while (false)
|
|
|
|
#define ASSERT_MSG(cond, fmtstr, ...) \
|
|
do \
|
|
{ \
|
|
if (cond) \
|
|
{} \
|
|
else \
|
|
{ \
|
|
fmt::print("{}:{}: Test assertion failed ({}) {}\n", \
|
|
__FILE__, \
|
|
__LINE__, \
|
|
#cond, \
|
|
fmt::format(fmtstr, __VA_ARGS__)); \
|
|
exit(EXIT_FAILURE); \
|
|
} \
|
|
} while (false)
|
|
|
|
#define ASSERT_THROWS_ANY(expr) \
|
|
do \
|
|
{ \
|
|
bool threw = false; \
|
|
try \
|
|
{ \
|
|
expr; \
|
|
} \
|
|
catch (...) \
|
|
{ \
|
|
threw = true; \
|
|
} \
|
|
if (!threw) \
|
|
{ \
|
|
fmt::print("{}:{}: Expression expected exception: '{}'.", \
|
|
__FILE__, \
|
|
__LINE__, \
|
|
#expr); \
|
|
exit(EXIT_FAILURE); \
|
|
} \
|
|
} while (false)
|