Reputation: 994
I've two files that I need to compare. I would use something like this
BOOST_REQUIRE_EQUAL(filename1, filename2);
Upvotes: 12
Views: 4615
Reputation: 1387
I would compare the hashes of the two files. Examples of using openssl library to calculate hashes are plenty.
Upvotes: 0
Reputation: 3112
You can use BOOST_CHECK_EQUAL_COLLECTIONS to compare file contents.
Code sample:
#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>
#include <fstream>
#include <iterator>
BOOST_AUTO_TEST_CASE( test )
{
std::ifstream ifs1("data1.txt");
std::ifstream ifs2("data2.txt");
std::istream_iterator<char> b1(ifs1), e1;
std::istream_iterator<char> b2(ifs2), e2;
BOOST_CHECK_EQUAL_COLLECTIONS(b1, e1, b2, e2);
}
Upvotes: 13