Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ Unit Test with Diff on Files

Is there any library that allows you to diff files in C++ unit tests? Ideally this would work with Boost Unit tests.

I was thinking of a function along the lines of:

CHECK_FILES_EQUAL('output.txt', 'reference.txt');

Which would then fail the test if the files were equal (possibly showing the line that it failed on).

Thanks

like image 419
Peter Avatar asked Nov 03 '22 05:11

Peter


1 Answers

I assume you want something more intelligent that just checking if the files equal byte-by-byte. I would use google-diff-match-patch, a powerful library which can (among other functionality) calculate a diff between two files. A C++ implementation is available, along with other languages. You'll need to handle file IO yourself, though.

like image 167
Liosan Avatar answered Nov 12 '22 23:11

Liosan