File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed
Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change 1414#include < exception>
1515#include < sstream>
1616#include < string>
17+ #include < unordered_set>
1718#include < vector>
1819
1920#include < gtest/gtest.h>
@@ -391,8 +392,22 @@ TEST_F(StringUtilTest, decodeFormattedHexString) {
391392TEST_F (StringUtilTest, stringSanitizer) {
392393 // Bad regular expression should throw.
393394 StringSanitizerPtr ss;
394- ASSERT_THROW_MSG (ss.reset (new StringSanitizer (" [bogus-regex" , " " )), BadValue,
395- " invalid regex: '[bogus-regex', Invalid range in bracket expression." );
395+
396+ try {
397+ ss.reset (new StringSanitizer (" [bogus-regex" , " " ));
398+ } catch (BadValue const & ex) {
399+ unordered_set<string> expected{
400+ // BSD
401+ " invalid regex: '[bogus-regex', The expression contained mismatched [ and ]." ,
402+ // Linux
403+ " invalid regex: '[bogus-regex', Invalid range in bracket expression." ,
404+ };
405+ if (!expected.count (ex.what ())) {
406+ FAIL () << " unexpected BadValue exception message: " << ex.what ();
407+ }
408+ } catch (exception const & ex) {
409+ FAIL () << " unexpected exception: " << ex.what ();
410+ }
396411
397412 string good_data (StringSanitizer::MAX_DATA_SIZE, ' 0' );
398413 string bad_data (StringSanitizer::MAX_DATA_SIZE + 1 , ' 0' );
You can’t perform that action at this time.
0 commit comments