-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
And begin on assert framework.
- Loading branch information
Showing
9 changed files
with
116 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#include "misc.hpp" | ||
|
||
#include <utility> | ||
#include <string_view> | ||
|
||
namespace hage::detail { | ||
template<typename F> requires std::predicate<F> | ||
void assert(F&& f, std::string_view cond, std::string_view msg) { | ||
if (!std::forward<F>(f)()) { | ||
std::string lel(msg); | ||
std::string cl(cond); | ||
throw std::runtime_error("We got an error during assertion: " +lel + " " + cl); | ||
} | ||
} | ||
} | ||
|
||
#ifdef HAGE_DEBUG | ||
#define HAGE_ASSERT(cond,...) HAGE_ASSERT_##__VA_OPT__(1)(cond __VA_OPT__(,)__VA_ARGS__) | ||
#define HAGE_ASSERT_(cond) HAGE_ASSERT_1(cond, "") | ||
#define HAGE_ASSERT_1(cond, msg) hage::detail::assert([&]{ return cond; }, #cond, msg) | ||
#else | ||
#define HAGE_ASSERT(cond,...) void() | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters