0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-20 12:12:15 +02:00

unittests: added THROW_FMT(...) convenience macro to throw an exception with printf-style argument substitution

Example:

  if (expect_throw != actual_throw)
    THROW_FMT("validate_size: bad throw, expect=%s, actual=%s, FC=%s size=%s",
	      expect_throw,
	      actual_throw,
	      fc.info(),
	      size);

Signed-off-by: James Yonan <james@openvpn.net>
This commit is contained in:
James Yonan 2021-07-23 00:13:11 -06:00 committed by Antonio Quartulli
parent 3cd0652d1e
commit 95852fd24a
No known key found for this signature in database
GPG Key ID: 20C8E22F5B1610AB

View File

@ -24,6 +24,7 @@
#include <openvpn/io/io.hpp>
#include <openvpn/common/exception.hpp>
#include <openvpn/common/hexstr.hpp>
#include <openvpn/common/format.hpp>
#include <openvpn/random/mtrandapi.hpp>
#include <iostream>
@ -409,3 +410,6 @@ do { \
if ((v1) < (v2)) \
OPENVPN_THROW_EXCEPTION("JY_ASSERT_GE: failure at " << __FILE__ << ':' << __LINE__); \
} while (0)
// Convenience macro for throwing exceptions
#define THROW_FMT(...) throw Exception(printfmt(__VA_ARGS__))