File tree 3 files changed +16
-5
lines changed
3 files changed +16
-5
lines changed Original file line number Diff line number Diff line change 16
16
#include " lib/Lib/CorpusImpl.hpp"
17
17
#include " lib/Lib/MrDocsCompilationDatabase.hpp"
18
18
#include " lib/Lib/SingleFileDB.hpp"
19
+ #include " test_suite/diff.hpp"
19
20
#include < mrdocs/Config.hpp>
20
21
#include < mrdocs/Generators.hpp>
21
22
#include < mrdocs/Platform.hpp>
Original file line number Diff line number Diff line change 23
23
namespace test_suite {
24
24
// Diff two strings and return the result as a string with additional stats
25
25
DiffStringsResult
26
- diffStrings (std::string_view str1, std::string_view str2, std::size_t context_size = 3 )
26
+ diffStrings (std::string_view str1, std::string_view str2, std::size_t context_size)
27
27
{
28
28
static constexpr auto splitLines =
29
29
[](std::string_view text, std::vector<std::string_view> &lines)
@@ -280,9 +280,12 @@ BOOST_TEST_DIFF(
280
280
DiffStringsResult diff = diffStrings (expected_contents, rendered_contents);
281
281
if (diff.added > 0 || diff.removed > 0 )
282
282
{
283
- std::ofstream out ((std::string (error_output_path)));
284
- BOOST_TEST (out);
285
- out << rendered_contents;
283
+ if (!error_output_path.empty ())
284
+ {
285
+ std::ofstream out ((std::string (error_output_path)));
286
+ BOOST_TEST (out);
287
+ out << rendered_contents;
288
+ }
286
289
#ifdef MRDOCS_TEST_HAS_FMT
287
290
fmt::println (" DIFF:\n =====================\n {}\n =====================" , diff.diff );
288
291
#else
Original file line number Diff line number Diff line change @@ -37,6 +37,13 @@ struct DiffStringsResult
37
37
int unmodified{0 };
38
38
};
39
39
40
+ // / Diff two strings and return the result as a string with additional stats
41
+ DiffStringsResult
42
+ diffStrings (
43
+ std::string_view str1,
44
+ std::string_view str2,
45
+ std::size_t context_size = 3 );
46
+
40
47
/* * Perform a diff between two strings and check if they are equal
41
48
42
49
This function is used to compare the contents of a file with the expected
@@ -65,7 +72,7 @@ BOOST_TEST_DIFF(
65
72
std::string_view expected_contents,
66
73
std::string_view expected_contents_path,
67
74
std::string_view rendered_contents,
68
- std::string_view error_output_path);
75
+ std::string_view error_output_path = {} );
69
76
70
77
}
71
78
You can’t perform that action at this time.
0 commit comments