Skip to content

Commit bf6d1e2

Browse files
committed
use boost::regex in json test
1 parent 5ab488e commit bf6d1e2

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

Release/tests/Functional/json/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CXXFLAGS=$(BASE_CXXFLAGS) -I"$(CASABLANCA_INCLUDE_DIR)" -I$(CASABLANCA_TESTS_DIR)/Common/UnitTestpp/
22
LDFLAGS=-L"$(OUTPUT_DIR)" $(BASE_LDFLAGS)
3-
LDLIBS=-lcasablanca -lunittestpp -l$(BOOST_SYSTEM) -l$(BOOST_THREAD) -lpthread -lstdc++ -lm
3+
LDLIBS=-lcasablanca -lunittestpp -l$(BOOST_SYSTEM) -l$(BOOST_THREAD) -l$(BOOST_REGEX) -lpthread -lstdc++ -lm
44

55
OUTPUT_DIR?=./$(MODE)
66

Release/tests/Functional/json/parsing_tests.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/***
1+
/***
22
* ==++==
33
*
44
* Copyright (c) Microsoft Corporation. All rights reserved.
@@ -24,7 +24,13 @@
2424
****/
2525

2626
#include "stdafx.h"
27+
28+
#if defined(_MS_WINDOWS) || defined(__APPLE__)
2729
#include <regex>
30+
#else
31+
// GCC 4.8 doesn't support regex very well, fall back to Boost. Revist in GCC 4.9.
32+
#include <boost/regex.hpp>
33+
#endif
2834

2935
using namespace web; using namespace utility;
3036
using namespace utility::conversions;
@@ -33,8 +39,14 @@ namespace tests { namespace functional { namespace json_tests {
3339

3440
inline bool verify_parsing_error_msg(const std::string &str)
3541
{
36-
static std::regex pattern("^\\* Line \\d+, Column \\d+ Syntax error: .+");
42+
auto spattern = "^\\* Line \\d+, Column \\d+ Syntax error: .+";
43+
#if defined(_MS_WINDOWS) || defined(__APPLE__)
44+
static std::regex pattern(spattern);
3745
return std::regex_match(str, pattern, std::regex_constants::match_flag_type::match_not_null);
46+
#else
47+
static boost::regex pattern(spattern);
48+
return boost::regex_match(str, pattern, boost::regex_constants::match_flag_type::match_not_null);
49+
#endif
3850
}
3951

4052
#pragma warning (disable: 4127) // const expression

0 commit comments

Comments
 (0)