Boost Test LibraryにあるBOOST_CHECK_EQUAL_COLLECTIONSアサーションと同等のアサーションをGoogle C++ Testing Framework/gtestで見つけようとしています。
でも; 成功せずに。だから私の質問は2つあります:
- gtestには同等のアサーションがありますか?
- そうでない場合: gtestで container-content をアサートするにはどうすればよいでしょうか?
編集(わずかに修正された回答):
#include <iostream>
template<typename LeftIter, typename RightIter>
::testing::AssertionResult CheckEqualCollections(LeftIter left_begin,
LeftIter left_end,
RightIter right_begin)
{
std::stringstream message;
std::size_t index(0);
bool equal(true);
for(;left_begin != left_end; left_begin++, right_begin++) {
if (*left_begin != *right_begin) {
equal = false;
message << "\n Mismatch in position " << index << ": " << *left_begin << " != " << *right_begin;
}
++index;
}
if (message.str().size()) {
message << "\n";
}
return equal ? ::testing::AssertionSuccess() :
::testing::AssertionFailure() << message.str();
}