Commit ff2ed5fe authored by Kirill Smelkov's avatar Kirill Smelkov

golang: testing: Provide file and line for a failing ASSERT_EQ

Makes understanding which test is it and where when one fails.
parent 46a6f424
...@@ -65,11 +65,11 @@ namespace _testing { ...@@ -65,11 +65,11 @@ namespace _testing {
panic(__FILE__ ":" STR(__LINE__) " assert `" #COND "` failed"); \ panic(__FILE__ ":" STR(__LINE__) " assert `" #COND "` failed"); \
} while(0) } while(0)
#define ASSERT_EQ(A, B) golang::_testing::__assert_eq(#A, A, B) #define ASSERT_EQ(A, B) golang::_testing::__assert_eq(__FILE__ ":" STR(__LINE__), #A, A, B)
template<typename T, typename U> template<typename T, typename U>
void __assert_eq(const string &expr, const T &have, const U &want) { void __assert_eq(const string& loc, const string &expr, const T &have, const U &want) {
if (have != want) { if (have != want) {
string emsg = expr + "\n"; string emsg = loc + ": " + expr + "\n";
emsg += "have: '" + std::to_string(have) + "'\n"; emsg += "have: '" + std::to_string(have) + "'\n";
emsg += "want: '" + std::to_string(want) + "'"; emsg += "want: '" + std::to_string(want) + "'";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment