Skip to content

Commit 9576055

Browse files
committed
Double-check content on failure in test_stream_io
1 parent cd43cdc commit 9576055

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

test/boostLocale/test/unit_test.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ std::string to_string(const char32_t c)
259259
#endif
260260

261261
template<typename T, typename U>
262-
void test_impl(bool success,
262+
bool test_impl(bool success,
263263
T const& l,
264264
U const& r,
265265
const char* expr,
@@ -276,18 +276,19 @@ void test_impl(bool success,
276276
} else
277277
boost::locale::test::report_error(expr, file, line);
278278
}
279+
return success;
279280
}
280281

281-
void test_impl(bool success, const char* reason, const char* file, int line)
282+
bool test_impl(bool success, const char* reason, const char* file, int line)
282283
{
283-
test_impl(success, nullptr, nullptr, reason, nullptr, file, line);
284+
return test_impl(success, nullptr, nullptr, reason, nullptr, file, line);
284285
}
285286

286287
#define BOOST_LOCALE_TEST_OP_IMPL(name, test_op, fail_op) \
287288
template<typename T, typename U> \
288-
void test_##name##_impl(T const& l, U const& r, const char* expr, const char* file, int line) \
289+
bool test_##name##_impl(T const& l, U const& r, const char* expr, const char* file, int line) \
289290
{ \
290-
test_impl(l test_op r, l, r, expr, #fail_op, file, line); \
291+
return test_impl(l test_op r, l, r, expr, #fail_op, file, line); \
291292
}
292293

293294
BOOST_LOCALE_TEST_OP_IMPL(eq, ==, !=)

test/test_stream_io.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,14 @@ void test_ok(const std::string& content, const std::locale& l, std::basic_string
5454
}
5555
stream_type in_file(file_path, stream_type::in);
5656
in_file.imbue(l);
57-
TEST_EQ(read_file<Char>(in_file), cmp);
57+
if(!TEST_EQ(read_file<Char>(in_file), cmp)) {
58+
// If test fails, double check the file content
59+
in_file.close();
60+
std::ifstream check_file(file_path, std::ios::binary);
61+
std::string check_content;
62+
TEST(check_file >> check_content);
63+
TEST_EQ(check_content, content);
64+
}
5865
}
5966

6067
{

0 commit comments

Comments
 (0)