From: Andrei Pavel Date: Mon, 4 Mar 2024 15:21:05 +0000 (+0200) Subject: [#3210] fix different exception message on BSD X-Git-Tag: Kea-2.5.7~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=54d0219bf368640f3b532b25c6960b46c6e7467e;p=thirdparty%2Fkea.git [#3210] fix different exception message on BSD --- diff --git a/src/lib/util/tests/str_unittests.cc b/src/lib/util/tests/str_unittests.cc index accaf218bd..78d28ce569 100644 --- a/src/lib/util/tests/str_unittests.cc +++ b/src/lib/util/tests/str_unittests.cc @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -391,8 +392,22 @@ TEST_F(StringUtilTest, decodeFormattedHexString) { TEST_F(StringUtilTest, stringSanitizer) { // Bad regular expression should throw. StringSanitizerPtr ss; - ASSERT_THROW_MSG(ss.reset(new StringSanitizer("[bogus-regex", "")), BadValue, - "invalid regex: '[bogus-regex', Invalid range in bracket expression."); + + try { + ss.reset(new StringSanitizer("[bogus-regex", "")); + } catch (BadValue const& ex) { + unordered_set expected{ + // BSD + "invalid regex: '[bogus-regex', The expression contained mismatched [ and ].", + // Linux + "invalid regex: '[bogus-regex', Invalid range in bracket expression.", + }; + if (!expected.count(ex.what())) { + FAIL() << "unexpected BadValue exception message: " << ex.what(); + } + } catch (exception const& ex) { + FAIL() << "unexpected exception: " << ex.what(); + } string good_data(StringSanitizer::MAX_DATA_SIZE, '0'); string bad_data(StringSanitizer::MAX_DATA_SIZE + 1, '0');