]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/encoding: verify that e.what() starts with expected str
authorKefu Chai <tchaikov@gmail.com>
Fri, 22 Jul 2022 12:54:43 +0000 (20:54 +0800)
committerKefu Chai <tchaikov@gmail.com>
Fri, 22 Jul 2022 16:14:35 +0000 (00:14 +0800)
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 <tchaikov@gmail.com>
src/test/encoding.cc

index 6d252fae18b71d65e4698c70fcf697de8bdd480a..f18901cbd27d94795679d30cd40ffdee8b3fb116 100644 (file)
@@ -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);
     }
   }
 }