From: Kefu Chai Date: Fri, 22 Jul 2022 12:54:43 +0000 (+0800) Subject: test/encoding: verify that e.what() starts with expected str X-Git-Tag: v18.0.0~429^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=0d9eec3c4feff30ab55601533bccf9ba6e568b9f;p=ceph.git 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 --- 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); } } }