Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iomanip>
- #include <iostream>
- #include <string>
- using namespace std;
- void Assert(bool value, const string& str, const string& func_name,
- const string& file_name, unsigned line_num, const string& hint) {
- if(!value){
- cout << func_name << "(" << line_num << "): " << file_name << ": ASSERT(" << str << ") ";
- if(hint.empty()){
- cout << "failed.";
- }
- else{
- cout << "failed. Hint: " << hint;
- }
- cout << endl;
- abort();
- }
- }
- void LogImpl();
- #define ASSERT(expr) Assert(expr, #expr, __FILE__, __FUNCTION__, __LINE__, ""s)
- #define ASSERT_HINT(expr, hint) Assert(expr, #expr, __FILE__, __FUNCTION__, __LINE__, (hint))
- int main() {
- string hello = "hello"s;
- ASSERT(!hello.empty());
- ASSERT_HINT(2 + 2 == 5, "This will fail"s);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement