regex: minor changes to make the test code more conservative in C++ usage

[SVN r9563]
This commit is contained in:
John Maddock
2001-03-16 12:41:36 +00:00
parent 98fd29d60c
commit 1758679bd6
4 changed files with 14 additions and 14 deletions

View File

@ -172,7 +172,7 @@ bool parse_function::operator()(const parse_grep& g)
} }
cout << "Warning: Unknown flag: "; cout << "Warning: Unknown flag: ";
string_type t(i, j); string_type t(i, j);
cout << make_narrow(t.c_str()); cout << make_narrow(t).c_str();
cout << endl; cout << endl;
return true; return true;
} }
@ -184,9 +184,9 @@ bool parse_function::operator()(const parse_grep& g)
case 1: case 1:
// set the text to match: // set the text to match:
search_text = string_type(i, j); search_text = string_type(i, j);
jm_trace("Initial search text: " << make_narrow(search_text)); jm_trace("Initial search text: " << make_narrow(search_text).c_str());
expand_escapes(search_text); expand_escapes(search_text);
jm_trace("Search text after escapes expanded: " << make_narrow(search_text)); jm_trace("Search text after escapes expanded: " << make_narrow(search_text).c_str());
break; break;
case 2: case 2:
// maybe set format string: // maybe set format string:
@ -232,8 +232,8 @@ void parse_input_line(const string_type& s)
parse_function op; parse_function op;
do_test = false; do_test = false;
regex_grep(op, s.begin(), s.end(), parse_expression); regex_grep(op, s.begin(), s.end(), parse_expression);
jm_trace("expression: " << make_narrow(expression)); jm_trace("expression: " << make_narrow(expression).c_str());
jm_trace("search string: " << make_narrow(search_text)); jm_trace("search string: " << make_narrow(search_text).c_str());
} }
int to_int(string_type::const_iterator i, string_type::const_iterator j) int to_int(string_type::const_iterator i, string_type::const_iterator j)

View File

@ -101,7 +101,7 @@ int main(int argc, char * argv[])
string_type s; string_type s;
get_line(is, s); get_line(is, s);
++line; ++line;
jm_trace("Reading test script line " << line << " " << make_narrow(s.c_str())); jm_trace("Reading test script line " << line << " " << make_narrow(s).c_str());
parse_input_line(s); parse_input_line(s);
if(do_test) if(do_test)
{ {

View File

@ -51,14 +51,14 @@ using std::endl;
typedef wchar_t char_t; typedef wchar_t char_t;
#endif #endif
#define NO_POSIX_TEST
typedef std::basic_string<char_t> string_type; typedef std::basic_string<char_t> string_type;
typedef std::basic_string<char> nstring_type; typedef std::basic_string<char> nstring_type;
inline istream& get_line(istream& is, nstring_type& s, char delim = '\n'); inline istream& get_line(istream& is, nstring_type& s, char delim = '\n');
istream& get_line(istream& is, string_type& s, char delim = L'\n'); istream& get_line(istream& is, string_type& s, char delim = L'\n');
#define BOOST_RE_STR(x) L##x #define BOOST_RE_STR(x) L##x
std::string make_narrow(const wchar_t* ptr); std::string make_narrow(const wchar_t* ptr);
//ostream& operator << (ostream& os, const string_type& s); inline std::string make_narrow(const std::wstring& s)
{ return make_narrow(s.c_str()); }
#else // TEST_UNICODE #else // TEST_UNICODE
@ -71,11 +71,11 @@ typedef char char_t;
typedef std::basic_string<char_t> string_type; typedef std::basic_string<char_t> string_type;
inline istream& get_line(istream& is, string_type& s, char delim = '\n'); inline istream& get_line(istream& is, string_type& s, char delim = '\n');
#define BOOST_RE_STR(x) x #define BOOST_RE_STR(x) x
#define make_narrow(x) x inline std::string make_narrow(const std::string& s)
{ return s; }
#endif // TEST_UNICODE #endif // TEST_UNICODE
//ostream& operator << (ostream& os, const wchar_t* s);
void parse_input_line(const string_type& s); void parse_input_line(const string_type& s);
void expand_escapes(string_type& s); void expand_escapes(string_type& s);
void run_tests(); void run_tests();

View File

@ -213,7 +213,7 @@ void cpp_tests(const reg_expression<C, T, A>& e, bool recurse = true)
if(s != merge_string) if(s != merge_string)
{ {
begin_error(); begin_error();
cout << "merge result mismatch: found \"" << make_narrow(s.c_str()) << "\" expected \"" << make_narrow(merge_string.c_str()) << "\"" << endl; cout << "merge result mismatch: found \"" << make_narrow(s).c_str() << "\" expected \"" << make_narrow(merge_string.c_str()) << "\"" << endl;
} }
return; return;
} }
@ -713,8 +713,8 @@ void begin_error()
if(line != last_line) if(line != last_line)
{ {
cout << "Error in line " << line << " of file " << file << endl; cout << "Error in line " << line << " of file " << file << endl;
cout << "Expression: " << make_narrow(expression.c_str()) << endl; cout << "Expression: " << make_narrow(expression).c_str() << endl;
cout << "Search text: " << make_narrow(search_text.c_str()) << endl; cout << "Search text: " << make_narrow(search_text).c_str() << endl;
cout << "Flags: "; cout << "Flags: ";
bool started = false; bool started = false;
unsigned int id = 0; unsigned int id = 0;
@ -724,7 +724,7 @@ void begin_error()
{ {
if(started) if(started)
cout << " | "; cout << " | ";
cout << make_narrow(flag_data[id].name); cout << make_narrow(flag_data[id].name).c_str();
started = true; started = true;
} }
++id; ++id;