Fix failure found by David Chisnall

llvm-svn: 140255
This commit is contained in:
Howard Hinnant 2011-09-21 16:42:32 +00:00
parent bcc7a92e53
commit b996af1fe7
1 changed files with 129 additions and 129 deletions

View File

@ -22,7 +22,7 @@
template <class char_type> template <class char_type>
void void
test(const char_type* A, const char_type* expected) test(const char_type* A, const std::basic_string<char_type>& expected)
{ {
std::regex_traits<char_type> t; std::regex_traits<char_type> t;
typedef forward_iterator<const char_type*> F; typedef forward_iterator<const char_type*> F;
@ -31,155 +31,155 @@ test(const char_type* A, const char_type* expected)
int main() int main()
{ {
test("NUL", "\x00"); test("NUL", std::string("\x00", 1));
test("alert", "\x07"); test("alert", std::string("\x07"));
test("backspace", "\x08"); test("backspace", std::string("\x08"));
test("tab", "\x09"); test("tab", std::string("\x09"));
test("carriage-return", "\x0D"); test("carriage-return", std::string("\x0D"));
test("newline", "\x0A"); test("newline", std::string("\x0A"));
test("vertical-tab", "\x0B"); test("vertical-tab", std::string("\x0B"));
test("form-feed", "\x0C"); test("form-feed", std::string("\x0C"));
test("space", " "); test("space", std::string(" "));
test("exclamation-mark", "!"); test("exclamation-mark", std::string("!"));
test("quotation-mark", "\""); test("quotation-mark", std::string("\""));
test("number-sign", "#"); test("number-sign", std::string("#"));
test("dollar-sign", "$"); test("dollar-sign", std::string("$"));
test("percent-sign", "%"); test("percent-sign", std::string("%"));
test("ampersand", "&"); test("ampersand", std::string("&"));
test("apostrophe", "\'"); test("apostrophe", std::string("\'"));
test("left-parenthesis", "("); test("left-parenthesis", std::string("("));
test("right-parenthesis", ")"); test("right-parenthesis", std::string(")"));
test("asterisk", "*"); test("asterisk", std::string("*"));
test("plus-sign", "+"); test("plus-sign", std::string("+"));
test("comma", ","); test("comma", std::string(","));
test("hyphen-minus", "-"); test("hyphen-minus", std::string("-"));
test("hyphen", "-"); test("hyphen", std::string("-"));
test("full-stop", "."); test("full-stop", std::string("."));
test("period", "."); test("period", std::string("."));
test("slash", "/"); test("slash", std::string("/"));
test("solidus", "/"); test("solidus", std::string("/"));
test("zero", "0"); test("zero", std::string("0"));
test("one", "1"); test("one", std::string("1"));
test("two", "2"); test("two", std::string("2"));
test("three", "3"); test("three", std::string("3"));
test("four", "4"); test("four", std::string("4"));
test("five", "5"); test("five", std::string("5"));
test("six", "6"); test("six", std::string("6"));
test("seven", "7"); test("seven", std::string("7"));
test("eight", "8"); test("eight", std::string("8"));
test("nine", "9"); test("nine", std::string("9"));
test("colon", ":"); test("colon", std::string(":"));
test("semicolon", ";"); test("semicolon", std::string(";"));
test("less-than-sign", "<"); test("less-than-sign", std::string("<"));
test("equals-sign", "="); test("equals-sign", std::string("="));
test("greater-than-sign", ">"); test("greater-than-sign", std::string(">"));
test("question-mark", "?"); test("question-mark", std::string("?"));
test("commercial-at", "@"); test("commercial-at", std::string("@"));
for (char c = 'A'; c <= 'Z'; ++c) for (char c = 'A'; c <= 'Z'; ++c)
{ {
const char a[2] = {c}; const char a[2] = {c};
test(a, a); test(a, std::string(a));
} }
test("left-square-bracket", "["); test("left-square-bracket", std::string("["));
test("backslash", "\\"); test("backslash", std::string("\\"));
test("reverse-solidus", "\\"); test("reverse-solidus", std::string("\\"));
test("right-square-bracket", "]"); test("right-square-bracket", std::string("]"));
test("circumflex-accent", "^"); test("circumflex-accent", std::string("^"));
test("circumflex", "^"); test("circumflex", std::string("^"));
test("low-line", "_"); test("low-line", std::string("_"));
test("underscore", "_"); test("underscore", std::string("_"));
test("grave-accent", "`"); test("grave-accent", std::string("`"));
for (char c = 'a'; c <= 'z'; ++c) for (char c = 'a'; c <= 'z'; ++c)
{ {
const char a[2] = {c}; const char a[2] = {c};
test(a, a); test(a, std::string(a));
} }
test("left-brace", "{"); test("left-brace", std::string("{"));
test("left-curly-bracket", "{"); test("left-curly-bracket", std::string("{"));
test("vertical-line", "|"); test("vertical-line", std::string("|"));
test("right-brace", "}"); test("right-brace", std::string("}"));
test("right-curly-bracket", "}"); test("right-curly-bracket", std::string("}"));
test("tilde", "~"); test("tilde", std::string("~"));
test("tild", ""); test("tild", std::string(""));
test("ch", ""); test("ch", std::string(""));
std::locale::global(std::locale("cs_CZ.ISO8859-2")); std::locale::global(std::locale("cs_CZ.ISO8859-2"));
test("ch", "ch"); test("ch", std::string("ch"));
std::locale::global(std::locale("C")); std::locale::global(std::locale("C"));
test(L"NUL", L"\x00"); test(L"NUL", std::wstring(L"\x00", 1));
test(L"alert", L"\x07"); test(L"alert", std::wstring(L"\x07"));
test(L"backspace", L"\x08"); test(L"backspace", std::wstring(L"\x08"));
test(L"tab", L"\x09"); test(L"tab", std::wstring(L"\x09"));
test(L"carriage-return", L"\x0D"); test(L"carriage-return", std::wstring(L"\x0D"));
test(L"newline", L"\x0A"); test(L"newline", std::wstring(L"\x0A"));
test(L"vertical-tab", L"\x0B"); test(L"vertical-tab", std::wstring(L"\x0B"));
test(L"form-feed", L"\x0C"); test(L"form-feed", std::wstring(L"\x0C"));
test(L"space", L" "); test(L"space", std::wstring(L" "));
test(L"exclamation-mark", L"!"); test(L"exclamation-mark", std::wstring(L"!"));
test(L"quotation-mark", L"\""); test(L"quotation-mark", std::wstring(L"\""));
test(L"number-sign", L"#"); test(L"number-sign", std::wstring(L"#"));
test(L"dollar-sign", L"$"); test(L"dollar-sign", std::wstring(L"$"));
test(L"percent-sign", L"%"); test(L"percent-sign", std::wstring(L"%"));
test(L"ampersand", L"&"); test(L"ampersand", std::wstring(L"&"));
test(L"apostrophe", L"\'"); test(L"apostrophe", std::wstring(L"\'"));
test(L"left-parenthesis", L"("); test(L"left-parenthesis", std::wstring(L"("));
test(L"right-parenthesis", L")"); test(L"right-parenthesis", std::wstring(L")"));
test(L"asterisk", L"*"); test(L"asterisk", std::wstring(L"*"));
test(L"plus-sign", L"+"); test(L"plus-sign", std::wstring(L"+"));
test(L"comma", L","); test(L"comma", std::wstring(L","));
test(L"hyphen-minus", L"-"); test(L"hyphen-minus", std::wstring(L"-"));
test(L"hyphen", L"-"); test(L"hyphen", std::wstring(L"-"));
test(L"full-stop", L"."); test(L"full-stop", std::wstring(L"."));
test(L"period", L"."); test(L"period", std::wstring(L"."));
test(L"slash", L"/"); test(L"slash", std::wstring(L"/"));
test(L"solidus", L"/"); test(L"solidus", std::wstring(L"/"));
test(L"zero", L"0"); test(L"zero", std::wstring(L"0"));
test(L"one", L"1"); test(L"one", std::wstring(L"1"));
test(L"two", L"2"); test(L"two", std::wstring(L"2"));
test(L"three", L"3"); test(L"three", std::wstring(L"3"));
test(L"four", L"4"); test(L"four", std::wstring(L"4"));
test(L"five", L"5"); test(L"five", std::wstring(L"5"));
test(L"six", L"6"); test(L"six", std::wstring(L"6"));
test(L"seven", L"7"); test(L"seven", std::wstring(L"7"));
test(L"eight", L"8"); test(L"eight", std::wstring(L"8"));
test(L"nine", L"9"); test(L"nine", std::wstring(L"9"));
test(L"colon", L":"); test(L"colon", std::wstring(L":"));
test(L"semicolon", L";"); test(L"semicolon", std::wstring(L";"));
test(L"less-than-sign", L"<"); test(L"less-than-sign", std::wstring(L"<"));
test(L"equals-sign", L"="); test(L"equals-sign", std::wstring(L"="));
test(L"greater-than-sign", L">"); test(L"greater-than-sign", std::wstring(L">"));
test(L"question-mark", L"?"); test(L"question-mark", std::wstring(L"?"));
test(L"commercial-at", L"@"); test(L"commercial-at", std::wstring(L"@"));
for (wchar_t c = L'A'; c <= L'Z'; ++c) for (wchar_t c = L'A'; c <= L'Z'; ++c)
{ {
const wchar_t a[2] = {c}; const wchar_t a[2] = {c};
test(a, a); test(a, std::wstring(a));
} }
test(L"left-square-bracket", L"["); test(L"left-square-bracket", std::wstring(L"["));
test(L"backslash", L"\\"); test(L"backslash", std::wstring(L"\\"));
test(L"reverse-solidus", L"\\"); test(L"reverse-solidus", std::wstring(L"\\"));
test(L"right-square-bracket", L"]"); test(L"right-square-bracket", std::wstring(L"]"));
test(L"circumflex-accent", L"^"); test(L"circumflex-accent", std::wstring(L"^"));
test(L"circumflex", L"^"); test(L"circumflex", std::wstring(L"^"));
test(L"low-line", L"_"); test(L"low-line", std::wstring(L"_"));
test(L"underscore", L"_"); test(L"underscore", std::wstring(L"_"));
test(L"grave-accent", L"`"); test(L"grave-accent", std::wstring(L"`"));
for (wchar_t c = L'a'; c <= L'z'; ++c) for (wchar_t c = L'a'; c <= L'z'; ++c)
{ {
const wchar_t a[2] = {c}; const wchar_t a[2] = {c};
test(a, a); test(a, std::wstring(a));
} }
test(L"left-brace", L"{"); test(L"left-brace", std::wstring(L"{"));
test(L"left-curly-bracket", L"{"); test(L"left-curly-bracket", std::wstring(L"{"));
test(L"vertical-line", L"|"); test(L"vertical-line", std::wstring(L"|"));
test(L"right-brace", L"}"); test(L"right-brace", std::wstring(L"}"));
test(L"right-curly-bracket", L"}"); test(L"right-curly-bracket", std::wstring(L"}"));
test(L"tilde", L"~"); test(L"tilde", std::wstring(L"~"));
test(L"tild", L""); test(L"tild", std::wstring(L""));
test(L"ch", L""); test(L"ch", std::wstring(L""));
std::locale::global(std::locale("cs_CZ.ISO8859-2")); std::locale::global(std::locale("cs_CZ.ISO8859-2"));
test(L"ch", L"ch"); test(L"ch", std::wstring(L"ch"));
std::locale::global(std::locale("C")); std::locale::global(std::locale("C"));
} }