expect.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "crucible/test/expect.hpp" #include <cstring> #include <sstream> namespace crucible::test::expect { constexpr char SOURCE_FILE_PATH_SEPARATOR = '/'; auto fail(char const *message, char const *file, int const line, char const *function) -> void { char const *final_path_separator = std::strrchr(file, SOURCE_FILE_PATH_SEPARATOR); char const *truncated_file = final_path_separator ? final_path_separator + 1 : file; std::ostringstream buffer; buffer << truncated_file << ":" << line << " [" << function << "]: " << message; throw ExpectFailed(buffer.str()); } }