Continuing to work through regex, and updated libcxx_by_chapter.pdf with weekly test results

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@106790 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Howard Hinnant
2010-06-24 21:28:00 +00:00
parent f409d2f2fc
commit 8c2c18d57c
7 changed files with 666 additions and 29 deletions

View File

@@ -26,66 +26,71 @@ int main()
{
std::regex_error e(std::regex_constants::error_collate);
assert(e.code() == std::regex_constants::error_collate);
assert(e.what() == std::string("error_collate"));
assert(e.what() == std::string("The expression contained an invalid collating element name."));
}
{
std::regex_error e(std::regex_constants::error_ctype);
assert(e.code() == std::regex_constants::error_ctype);
assert(e.what() == std::string("error_ctype"));
assert(e.what() == std::string("The expression contained an invalid character class name."));
}
{
std::regex_error e(std::regex_constants::error_escape);
assert(e.code() == std::regex_constants::error_escape);
assert(e.what() == std::string("error_escape"));
assert(e.what() == std::string("The expression contained an invalid escaped character, or a "
"trailing escape."));
}
{
std::regex_error e(std::regex_constants::error_backref);
assert(e.code() == std::regex_constants::error_backref);
assert(e.what() == std::string("error_backref"));
assert(e.what() == std::string("The expression contained an invalid back reference."));
}
{
std::regex_error e(std::regex_constants::error_brack);
assert(e.code() == std::regex_constants::error_brack);
assert(e.what() == std::string("error_brack"));
assert(e.what() == std::string("The expression contained mismatched [ and ]."));
}
{
std::regex_error e(std::regex_constants::error_paren);
assert(e.code() == std::regex_constants::error_paren);
assert(e.what() == std::string("error_paren"));
assert(e.what() == std::string("The expression contained mismatched ( and )."));
}
{
std::regex_error e(std::regex_constants::error_brace);
assert(e.code() == std::regex_constants::error_brace);
assert(e.what() == std::string("error_brace"));
assert(e.what() == std::string("The expression contained mismatched { and }."));
}
{
std::regex_error e(std::regex_constants::error_badbrace);
assert(e.code() == std::regex_constants::error_badbrace);
assert(e.what() == std::string("error_badbrace"));
assert(e.what() == std::string("The expression contained an invalid range in a {} expression."));
}
{
std::regex_error e(std::regex_constants::error_range);
assert(e.code() == std::regex_constants::error_range);
assert(e.what() == std::string("error_range"));
assert(e.what() == std::string("The expression contained an invalid character range, "
"such as [b-a] in most encodings."));
}
{
std::regex_error e(std::regex_constants::error_space);
assert(e.code() == std::regex_constants::error_space);
assert(e.what() == std::string("error_space"));
assert(e.what() == std::string("There was insufficient memory to convert the expression into "
"a finite state machine."));
}
{
std::regex_error e(std::regex_constants::error_badrepeat);
assert(e.code() == std::regex_constants::error_badrepeat);
assert(e.what() == std::string("error_badrepeat"));
assert(e.what() == std::string("One of *?+{ was not preceded by a valid regular expression."));
}
{
std::regex_error e(std::regex_constants::error_complexity);
assert(e.code() == std::regex_constants::error_complexity);
assert(e.what() == std::string("error_complexity"));
assert(e.what() == std::string("The complexity of an attempted match against a regular "
"expression exceeded a pre-set level."));
}
{
std::regex_error e(std::regex_constants::error_stack);
assert(e.code() == std::regex_constants::error_stack);
assert(e.what() == std::string("error_stack"));
assert(e.what() == std::string("There was insufficient memory to determine whether the regular "
"expression could match the specified character sequence."));
}
}

View File

@@ -0,0 +1,52 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <regex>
// template <class charT, class traits = regex_traits<charT>>
// class basic_regex
// {
// public:
// // constants:
// static constexpr regex_constants::syntax_option_type icase = regex_constants::icase;
// static constexpr regex_constants::syntax_option_type nosubs = regex_constants::nosubs;
// static constexpr regex_constants::syntax_option_type optimize = regex_constants::optimize;
// static constexpr regex_constants::syntax_option_type collate = regex_constants::collate;
// static constexpr regex_constants::syntax_option_type ECMAScript = regex_constants::ECMAScript;
// static constexpr regex_constants::syntax_option_type basic = regex_constants::basic;
// static constexpr regex_constants::syntax_option_type extended = regex_constants::extended;
// static constexpr regex_constants::syntax_option_type awk = regex_constants::awk;
// static constexpr regex_constants::syntax_option_type grep = regex_constants::grep;
// static constexpr regex_constants::syntax_option_type egrep = regex_constants::egrep;
#include <regex>
#include <type_traits>
template <class CharT>
void
test()
{
typedef std::basic_regex<CharT> BR;
static_assert((BR::icase == std::regex_constants::icase), "");
static_assert((BR::nosubs == std::regex_constants::nosubs), "");
static_assert((BR::optimize == std::regex_constants::optimize), "");
static_assert((BR::collate == std::regex_constants::collate), "");
static_assert((BR::ECMAScript == std::regex_constants::ECMAScript), "");
static_assert((BR::basic == std::regex_constants::basic), "");
static_assert((BR::extended == std::regex_constants::extended), "");
static_assert((BR::awk == std::regex_constants::awk), "");
static_assert((BR::grep == std::regex_constants::grep), "");
static_assert((BR::egrep == std::regex_constants::egrep), "");
}
int main()
{
test<char>();
test<wchar_t>();
}

View File

@@ -0,0 +1,32 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <regex>
// template <class charT, class traits = regex_traits<charT>> class basic_regex;
// basic_regex();
#include <regex>
#include <cassert>
template <class CharT>
void
test()
{
std::basic_regex<CharT> r;
assert(r.flags() == 0);
assert(r.mark_count() == 0);
}
int main()
{
test<char>();
test<wchar_t>();
}

View File

@@ -0,0 +1,35 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <regex>
// template <class charT, class traits = regex_traits<charT>>
// class basic_regex
// {
// public:
// // types:
// typedef charT value_type;
// typedef regex_constants::syntax_option_type flag_type;
// typedef typename traits::locale_type locale_type;
#include <regex>
#include <type_traits>
int main()
{
static_assert((std::is_same<std::basic_regex<char>::value_type, char>::value), "");
static_assert((std::is_same<std::basic_regex<char>::flag_type,
std::regex_constants::syntax_option_type>::value), "");
static_assert((std::is_same<std::basic_regex<char>::locale_type, std::locale>::value), "");
static_assert((std::is_same<std::basic_regex<wchar_t>::value_type, wchar_t>::value), "");
static_assert((std::is_same<std::basic_regex<wchar_t>::flag_type,
std::regex_constants::syntax_option_type>::value), "");
static_assert((std::is_same<std::basic_regex<wchar_t>::locale_type, std::locale>::value), "");
}