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 14
14
#include < exception>
15
15
#include < sstream>
16
16
#include < string>
17
+ #include < unordered_set>
17
18
#include < vector>
18
19
19
20
#include < gtest/gtest.h>
@@ -391,8 +392,22 @@ TEST_F(StringUtilTest, decodeFormattedHexString) {
391
392
TEST_F (StringUtilTest, stringSanitizer) {
392
393
// Bad regular expression should throw.
393
394
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
+ }
396
411
397
412
string good_data (StringSanitizer::MAX_DATA_SIZE, ' 0' );
398
413
string bad_data (StringSanitizer::MAX_DATA_SIZE + 1 , ' 0' );
You can’t perform that action at this time.
0 commit comments