From 0d9eec3c4feff30ab55601533bccf9ba6e568b9f Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 22 Jul 2022 20:54:43 +0800 Subject: [PATCH] test/encoding: verify that e.what() starts with expected str boost changes the way how it prints boost::system::system_error in boost 1.79 -- it appends the stringified error_category at end of exception::what(), and our buffer::malformed_input is a subclass of boost::system::system_error. so we cannot just compare the return value of what() with the expected string, to be more future proof, let's check if i starts with the expected string instead. Signed-off-by: Kefu Chai --- src/test/encoding.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/encoding.cc b/src/test/encoding.cc index 6d252fae18b71..f18901cbd27d9 100644 --- a/src/test/encoding.cc +++ b/src/test/encoding.cc @@ -334,11 +334,11 @@ void lame_decoder(int which) { } TEST(EncodingException, Macros) { - for (unsigned i = 0; i < sizeof(expected_what)/sizeof(expected_what[0]); i++) { + for (unsigned i = 0; i < std::size(expected_what); i++) { try { lame_decoder(i); } catch (const exception& e) { - ASSERT_EQ(string(expected_what[i]), string(e.what())); + ASSERT_NE(string(e.what()).find(expected_what[i]), string::npos); } } } -- 2.39.5