Finished [re.traits]. I'd like to acknowledge the help of Bjorn Reese with <regex>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@106478 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -15,9 +15,21 @@
|
||||
// regex_traits();
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::regex_traits<char> t1();
|
||||
std::regex_traits<wchar_t> t2();
|
||||
{
|
||||
std::regex_traits<char> t1;
|
||||
assert(t1.getloc().name() == "C");
|
||||
std::regex_traits<wchar_t> t2;
|
||||
assert(t2.getloc().name() == "C");
|
||||
}
|
||||
{
|
||||
std::locale::global(std::locale("en_US"));
|
||||
std::regex_traits<char> t1;
|
||||
assert(t1.getloc().name() == "en_US");
|
||||
std::regex_traits<wchar_t> t2;
|
||||
assert(t2.getloc().name() == "en_US");
|
||||
}
|
||||
}
|
||||
|
@@ -14,8 +14,21 @@
|
||||
// locale_type getloc()const;
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#error getloc not implemented
|
||||
{
|
||||
std::regex_traits<char> t1;
|
||||
assert(t1.getloc().name() == "C");
|
||||
std::regex_traits<wchar_t> t2;
|
||||
assert(t2.getloc().name() == "C");
|
||||
}
|
||||
{
|
||||
std::locale::global(std::locale("en_US"));
|
||||
std::regex_traits<char> t1;
|
||||
assert(t1.getloc().name() == "en_US");
|
||||
std::regex_traits<wchar_t> t2;
|
||||
assert(t2.getloc().name() == "en_US");
|
||||
}
|
||||
}
|
||||
|
@@ -14,8 +14,15 @@
|
||||
// locale_type imbue(locale_type l);
|
||||
|
||||
#include <regex>
|
||||
#include <locale>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#error imbue not implemented
|
||||
{
|
||||
std::regex_traits<char> t;
|
||||
std::locale loc = t.imbue(std::locale("en_US"));
|
||||
assert(loc.name() == "C");
|
||||
assert(t.getloc().name() == "en_US");
|
||||
}
|
||||
}
|
||||
|
@@ -14,8 +14,266 @@
|
||||
// bool isctype(charT c, char_class_type f) const;
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#error isctype not implemented
|
||||
{
|
||||
std::regex_traits<char> t;
|
||||
|
||||
std::string s("w");
|
||||
assert( t.isctype('_', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
|
||||
|
||||
s = "alnum";
|
||||
assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
|
||||
|
||||
s = "alpha";
|
||||
assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
|
||||
|
||||
s = "blank";
|
||||
assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
|
||||
|
||||
s = "cntrl";
|
||||
assert( t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
|
||||
|
||||
s = "digit";
|
||||
assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
|
||||
|
||||
s = "graph";
|
||||
assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype('_', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype('-', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype('@', t.lookup_classname(s.begin(), s.end())));
|
||||
|
||||
s = "lower";
|
||||
assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
|
||||
|
||||
s = "print";
|
||||
assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype('_', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype('-', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype('@', t.lookup_classname(s.begin(), s.end())));
|
||||
|
||||
s = "punct";
|
||||
assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype('_', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype('-', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype('@', t.lookup_classname(s.begin(), s.end())));
|
||||
|
||||
s = "space";
|
||||
assert( t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
|
||||
|
||||
s = "upper";
|
||||
assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
|
||||
|
||||
s = "xdigit";
|
||||
assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
|
||||
}
|
||||
{
|
||||
std::regex_traits<wchar_t> t;
|
||||
|
||||
std::wstring s(L"w");
|
||||
assert( t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
|
||||
|
||||
s = L"alnum";
|
||||
assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
|
||||
|
||||
s = L"alpha";
|
||||
assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
|
||||
|
||||
s = L"blank";
|
||||
assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
|
||||
|
||||
s = L"cntrl";
|
||||
assert( t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
|
||||
|
||||
s = L"digit";
|
||||
assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
|
||||
|
||||
s = L"graph";
|
||||
assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
|
||||
|
||||
s = L"lower";
|
||||
assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
|
||||
|
||||
s = L"print";
|
||||
assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
|
||||
|
||||
s = L"punct";
|
||||
assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
|
||||
|
||||
s = L"space";
|
||||
assert( t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
|
||||
|
||||
s = L"upper";
|
||||
assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
|
||||
|
||||
s = L"xdigit";
|
||||
assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
|
||||
assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
|
||||
assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
|
||||
}
|
||||
}
|
||||
|
@@ -17,8 +17,193 @@
|
||||
// bool icase = false) const;
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
#include "iterators.h"
|
||||
|
||||
template <class char_type>
|
||||
void
|
||||
test(const char_type* A, std::ctype_base::mask expected, bool icase = false)
|
||||
{
|
||||
std::regex_traits<char_type> t;
|
||||
typedef forward_iterator<const char_type*> F;
|
||||
assert(t.lookup_classname(F(A), F(A + t.length(A)), icase) == expected);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
#error lookup_classname not implemented
|
||||
test("d", std::ctype_base::digit);
|
||||
test("D", std::ctype_base::digit);
|
||||
test("d", std::ctype_base::digit, true);
|
||||
test("D", std::ctype_base::digit, true);
|
||||
|
||||
test("w", std::regex_traits<char>::__regex_word | std::ctype_base::alnum
|
||||
| std::ctype_base::upper | std::ctype_base::lower);
|
||||
test("W", std::regex_traits<char>::__regex_word | std::ctype_base::alnum
|
||||
| std::ctype_base::upper | std::ctype_base::lower);
|
||||
test("w", std::regex_traits<char>::__regex_word | std::ctype_base::alnum
|
||||
| std::ctype_base::upper | std::ctype_base::lower, true);
|
||||
test("W", std::regex_traits<char>::__regex_word | std::ctype_base::alnum
|
||||
| std::ctype_base::upper | std::ctype_base::lower, true);
|
||||
|
||||
test("s", std::ctype_base::space);
|
||||
test("S", std::ctype_base::space);
|
||||
test("s", std::ctype_base::space, true);
|
||||
test("S", std::ctype_base::space, true);
|
||||
|
||||
test("alnum", std::ctype_base::alnum);
|
||||
test("AlNum", std::ctype_base::alnum);
|
||||
test("alnum", std::ctype_base::alnum, true);
|
||||
test("AlNum", std::ctype_base::alnum, true);
|
||||
|
||||
test("alpha", std::ctype_base::alpha);
|
||||
test("Alpha", std::ctype_base::alpha);
|
||||
test("alpha", std::ctype_base::alpha, true);
|
||||
test("Alpha", std::ctype_base::alpha, true);
|
||||
|
||||
test("blank", std::ctype_base::blank);
|
||||
test("Blank", std::ctype_base::blank);
|
||||
test("blank", std::ctype_base::blank, true);
|
||||
test("Blank", std::ctype_base::blank, true);
|
||||
|
||||
test("cntrl", std::ctype_base::cntrl);
|
||||
test("Cntrl", std::ctype_base::cntrl);
|
||||
test("cntrl", std::ctype_base::cntrl, true);
|
||||
test("Cntrl", std::ctype_base::cntrl, true);
|
||||
|
||||
test("digit", std::ctype_base::digit);
|
||||
test("Digit", std::ctype_base::digit);
|
||||
test("digit", std::ctype_base::digit, true);
|
||||
test("Digit", std::ctype_base::digit, true);
|
||||
|
||||
test("digit", std::ctype_base::digit);
|
||||
test("DIGIT", std::ctype_base::digit);
|
||||
test("digit", std::ctype_base::digit, true);
|
||||
test("Digit", std::ctype_base::digit, true);
|
||||
|
||||
test("graph", std::ctype_base::graph);
|
||||
test("GRAPH", std::ctype_base::graph);
|
||||
test("graph", std::ctype_base::graph, true);
|
||||
test("Graph", std::ctype_base::graph, true);
|
||||
|
||||
test("lower", std::ctype_base::lower);
|
||||
test("LOWER", std::ctype_base::lower);
|
||||
test("lower", std::ctype_base::lower | std::ctype_base::alpha, true);
|
||||
test("Lower", std::ctype_base::lower | std::ctype_base::alpha, true);
|
||||
|
||||
test("print", std::ctype_base::print);
|
||||
test("PRINT", std::ctype_base::print);
|
||||
test("print", std::ctype_base::print, true);
|
||||
test("Print", std::ctype_base::print, true);
|
||||
|
||||
test("punct", std::ctype_base::punct);
|
||||
test("PUNCT", std::ctype_base::punct);
|
||||
test("punct", std::ctype_base::punct, true);
|
||||
test("Punct", std::ctype_base::punct, true);
|
||||
|
||||
test("space", std::ctype_base::space);
|
||||
test("SPACE", std::ctype_base::space);
|
||||
test("space", std::ctype_base::space, true);
|
||||
test("Space", std::ctype_base::space, true);
|
||||
|
||||
test("upper", std::ctype_base::upper);
|
||||
test("UPPER", std::ctype_base::upper);
|
||||
test("upper", std::ctype_base::upper | std::ctype_base::alpha, true);
|
||||
test("Upper", std::ctype_base::upper | std::ctype_base::alpha, true);
|
||||
|
||||
test("xdigit", std::ctype_base::xdigit);
|
||||
test("XDIGIT", std::ctype_base::xdigit);
|
||||
test("xdigit", std::ctype_base::xdigit, true);
|
||||
test("Xdigit", std::ctype_base::xdigit, true);
|
||||
|
||||
test("dig", 0);
|
||||
test("", 0);
|
||||
test("digits", 0);
|
||||
|
||||
test(L"d", std::ctype_base::digit);
|
||||
test(L"D", std::ctype_base::digit);
|
||||
test(L"d", std::ctype_base::digit, true);
|
||||
test(L"D", std::ctype_base::digit, true);
|
||||
|
||||
test(L"w", std::regex_traits<wchar_t>::__regex_word | std::ctype_base::alnum
|
||||
| std::ctype_base::upper | std::ctype_base::lower);
|
||||
test(L"W", std::regex_traits<wchar_t>::__regex_word | std::ctype_base::alnum
|
||||
| std::ctype_base::upper | std::ctype_base::lower);
|
||||
test(L"w", std::regex_traits<wchar_t>::__regex_word | std::ctype_base::alnum
|
||||
| std::ctype_base::upper | std::ctype_base::lower, true);
|
||||
test(L"W", std::regex_traits<wchar_t>::__regex_word | std::ctype_base::alnum
|
||||
| std::ctype_base::upper | std::ctype_base::lower, true);
|
||||
|
||||
test(L"s", std::ctype_base::space);
|
||||
test(L"S", std::ctype_base::space);
|
||||
test(L"s", std::ctype_base::space, true);
|
||||
test(L"S", std::ctype_base::space, true);
|
||||
|
||||
test(L"alnum", std::ctype_base::alnum);
|
||||
test(L"AlNum", std::ctype_base::alnum);
|
||||
test(L"alnum", std::ctype_base::alnum, true);
|
||||
test(L"AlNum", std::ctype_base::alnum, true);
|
||||
|
||||
test(L"alpha", std::ctype_base::alpha);
|
||||
test(L"Alpha", std::ctype_base::alpha);
|
||||
test(L"alpha", std::ctype_base::alpha, true);
|
||||
test(L"Alpha", std::ctype_base::alpha, true);
|
||||
|
||||
test(L"blank", std::ctype_base::blank);
|
||||
test(L"Blank", std::ctype_base::blank);
|
||||
test(L"blank", std::ctype_base::blank, true);
|
||||
test(L"Blank", std::ctype_base::blank, true);
|
||||
|
||||
test(L"cntrl", std::ctype_base::cntrl);
|
||||
test(L"Cntrl", std::ctype_base::cntrl);
|
||||
test(L"cntrl", std::ctype_base::cntrl, true);
|
||||
test(L"Cntrl", std::ctype_base::cntrl, true);
|
||||
|
||||
test(L"digit", std::ctype_base::digit);
|
||||
test(L"Digit", std::ctype_base::digit);
|
||||
test(L"digit", std::ctype_base::digit, true);
|
||||
test(L"Digit", std::ctype_base::digit, true);
|
||||
|
||||
test(L"digit", std::ctype_base::digit);
|
||||
test(L"DIGIT", std::ctype_base::digit);
|
||||
test(L"digit", std::ctype_base::digit, true);
|
||||
test(L"Digit", std::ctype_base::digit, true);
|
||||
|
||||
test(L"graph", std::ctype_base::graph);
|
||||
test(L"GRAPH", std::ctype_base::graph);
|
||||
test(L"graph", std::ctype_base::graph, true);
|
||||
test(L"Graph", std::ctype_base::graph, true);
|
||||
|
||||
test(L"lower", std::ctype_base::lower);
|
||||
test(L"LOWER", std::ctype_base::lower);
|
||||
test(L"lower", std::ctype_base::lower | std::ctype_base::alpha, true);
|
||||
test(L"Lower", std::ctype_base::lower | std::ctype_base::alpha, true);
|
||||
|
||||
test(L"print", std::ctype_base::print);
|
||||
test(L"PRINT", std::ctype_base::print);
|
||||
test(L"print", std::ctype_base::print, true);
|
||||
test(L"Print", std::ctype_base::print, true);
|
||||
|
||||
test(L"punct", std::ctype_base::punct);
|
||||
test(L"PUNCT", std::ctype_base::punct);
|
||||
test(L"punct", std::ctype_base::punct, true);
|
||||
test(L"Punct", std::ctype_base::punct, true);
|
||||
|
||||
test(L"space", std::ctype_base::space);
|
||||
test(L"SPACE", std::ctype_base::space);
|
||||
test(L"space", std::ctype_base::space, true);
|
||||
test(L"Space", std::ctype_base::space, true);
|
||||
|
||||
test(L"upper", std::ctype_base::upper);
|
||||
test(L"UPPER", std::ctype_base::upper);
|
||||
test(L"upper", std::ctype_base::upper | std::ctype_base::alpha, true);
|
||||
test(L"Upper", std::ctype_base::upper | std::ctype_base::alpha, true);
|
||||
|
||||
test(L"xdigit", std::ctype_base::xdigit);
|
||||
test(L"XDIGIT", std::ctype_base::xdigit);
|
||||
test(L"xdigit", std::ctype_base::xdigit, true);
|
||||
test(L"Xdigit", std::ctype_base::xdigit, true);
|
||||
|
||||
test(L"dig", 0);
|
||||
test(L"", 0);
|
||||
test(L"digits", 0);
|
||||
}
|
||||
|
@@ -13,9 +13,115 @@
|
||||
|
||||
// int value(charT ch, int radix) const;
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#error value not implemented
|
||||
{
|
||||
std::regex_traits<char> t;
|
||||
|
||||
for (char c = 0; c < '0'; ++c)
|
||||
{
|
||||
assert(t.value(c, 8) == -1);
|
||||
assert(t.value(c, 10) == -1);
|
||||
assert(t.value(c, 16) == -1);
|
||||
}
|
||||
for (char c = '0'; c < '8'; ++c)
|
||||
{
|
||||
assert(t.value(c, 8) == c - '0');
|
||||
assert(t.value(c, 10) == c - '0');
|
||||
assert(t.value(c, 16) == c - '0');
|
||||
}
|
||||
for (char c = '8'; c < ':'; ++c)
|
||||
{
|
||||
assert(t.value(c, 8) == -1);
|
||||
assert(t.value(c, 10) == c - '0');
|
||||
assert(t.value(c, 16) == c - '0');
|
||||
}
|
||||
for (char c = ':'; c < 'A'; ++c)
|
||||
{
|
||||
assert(t.value(c, 8) == -1);
|
||||
assert(t.value(c, 10) == -1);
|
||||
assert(t.value(c, 16) == -1);
|
||||
}
|
||||
for (char c = 'A'; c < 'G'; ++c)
|
||||
{
|
||||
assert(t.value(c, 8) == -1);
|
||||
assert(t.value(c, 10) == -1);
|
||||
assert(t.value(c, 16) == c - 'A' +10);
|
||||
}
|
||||
for (char c = 'G'; c < 'a'; ++c)
|
||||
{
|
||||
assert(t.value(c, 8) == -1);
|
||||
assert(t.value(c, 10) == -1);
|
||||
assert(t.value(c, 16) == -1);
|
||||
}
|
||||
for (char c = 'a'; c < 'g'; ++c)
|
||||
{
|
||||
assert(t.value(c, 8) == -1);
|
||||
assert(t.value(c, 10) == -1);
|
||||
assert(t.value(c, 16) == c - 'a' +10);
|
||||
}
|
||||
for (int c = 'g'; c < 256; ++c)
|
||||
{
|
||||
assert(t.value(char(c), 8) == -1);
|
||||
assert(t.value(char(c), 10) == -1);
|
||||
assert(t.value(char(c), 16) == -1);
|
||||
}
|
||||
}
|
||||
{
|
||||
std::regex_traits<wchar_t> t;
|
||||
|
||||
for (wchar_t c = 0; c < '0'; ++c)
|
||||
{
|
||||
assert(t.value(c, 8) == -1);
|
||||
assert(t.value(c, 10) == -1);
|
||||
assert(t.value(c, 16) == -1);
|
||||
}
|
||||
for (wchar_t c = '0'; c < '8'; ++c)
|
||||
{
|
||||
assert(t.value(c, 8) == c - '0');
|
||||
assert(t.value(c, 10) == c - '0');
|
||||
assert(t.value(c, 16) == c - '0');
|
||||
}
|
||||
for (wchar_t c = '8'; c < ':'; ++c)
|
||||
{
|
||||
assert(t.value(c, 8) == -1);
|
||||
assert(t.value(c, 10) == c - '0');
|
||||
assert(t.value(c, 16) == c - '0');
|
||||
}
|
||||
for (wchar_t c = ':'; c < 'A'; ++c)
|
||||
{
|
||||
assert(t.value(c, 8) == -1);
|
||||
assert(t.value(c, 10) == -1);
|
||||
assert(t.value(c, 16) == -1);
|
||||
}
|
||||
for (wchar_t c = 'A'; c < 'G'; ++c)
|
||||
{
|
||||
assert(t.value(c, 8) == -1);
|
||||
assert(t.value(c, 10) == -1);
|
||||
assert(t.value(c, 16) == c - 'A' +10);
|
||||
}
|
||||
for (wchar_t c = 'G'; c < 'a'; ++c)
|
||||
{
|
||||
assert(t.value(c, 8) == -1);
|
||||
assert(t.value(c, 10) == -1);
|
||||
assert(t.value(c, 16) == -1);
|
||||
}
|
||||
for (wchar_t c = 'a'; c < 'g'; ++c)
|
||||
{
|
||||
assert(t.value(c, 8) == -1);
|
||||
assert(t.value(c, 10) == -1);
|
||||
assert(t.value(c, 16) == c - 'a' +10);
|
||||
}
|
||||
for (int c = 'g'; c < 0xFFFF; ++c)
|
||||
{
|
||||
assert(t.value(c, 8) == -1);
|
||||
assert(t.value(c, 10) == -1);
|
||||
assert(t.value(c, 16) == -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user