Commit b3ebe3d0 by Tim Shen Committed by Edward Smith-Rowland

Implement class regex_traits.

2013-07-09  Tim Shen  <timshen91@gmail.com>

	Implement class regex_traits.
	* include/bits/regex.h: Implement lookup_classname and
	lookup_collatename; modify isctype; partially implement
	transform_primary.
	* testsuite/28_regex/traits/char/isctype.cc: Add more test cases.
	* testsuite/28_regex/traits/char/lookup_classname.cc: Likewise.
	* testsuite/28_regex/traits/char/lookup_collatename.cc: Likewise.
	* testsuite/28_regex/traits/char/transform_primary.cc: Likewise.
	* testsuite/28_regex/traits/wchar_t/isctype.cc: New.
	* testsuite/28_regex/traits/wchar_t/lookup_classname.cc: New.
	* testsuite/28_regex/traits/wchar_t/lookup_collatename.cc: New.
	* testsuite/28_regex/traits/wchar_t/transform_primary.cc: New.

From-SVN: r200818
parent 309f50b9
2013-07-09 Tim Shen <timshen91@gmail.com>
Implement class regex_traits.
* include/bits/regex.h: Implement lookup_classname and
lookup_collatename; modify isctype; partially implement
transform_primary.
* testsuite/28_regex/traits/char/isctype.cc: Add more test cases.
* testsuite/28_regex/traits/char/lookup_classname.cc: Likewise.
* testsuite/28_regex/traits/char/lookup_collatename.cc: Likewise.
* testsuite/28_regex/traits/char/transform_primary.cc: Likewise.
* testsuite/28_regex/traits/wchar_t/isctype.cc: New.
* testsuite/28_regex/traits/wchar_t/lookup_classname.cc: New.
* testsuite/28_regex/traits/wchar_t/lookup_collatename.cc: New.
* testsuite/28_regex/traits/wchar_t/transform_primary.cc: New.
2013-07-07 Ed Smith-Rowland <3dw4rd@verizon.net>
* doc/xml/manual/status_cxx2014.xml: Add links for papers.
......
// { dg-do run { xfail *-*-* } }
// { dg-do run }
// { dg-options "-std=c++0x" }
//
......@@ -35,10 +35,28 @@ test01()
typedef char CharT;
typedef std::regex_traits<CharT> traits;
char name[] = "lower";
traits t;
const CharT lower[] = "lOWer";
const CharT upper[] = "UPPER";
const CharT nothing[] = "nothing";
const CharT word[] = "w";
const CharT blank[] = "blank";
const CharT digit[] = "digit";
traits t;
VERIFY( t.isctype('e', t.lookup_classname(name, name+sizeof(name)-1)) );
#define range(s) s, s+sizeof(s)/sizeof(s[0])-1
VERIFY( t.isctype('_', t.lookup_classname(range(word))));
VERIFY( t.isctype('A', t.lookup_classname(range(word))));
VERIFY(!t.isctype('~', t.lookup_classname(range(word))));
VERIFY(!t.isctype('e', t.lookup_classname(range(upper))));
VERIFY( t.isctype('e', t.lookup_classname(range(lower))));
VERIFY(!t.isctype('e', t.lookup_classname(range(nothing))));
VERIFY(!t.isctype('_', t.lookup_classname(range(digit))));
VERIFY( t.isctype(' ', t.lookup_classname(range(blank))));
VERIFY( t.isctype('\t', t.lookup_classname(range(blank))));
VERIFY(!t.isctype('\n', t.lookup_classname(range(blank))));
VERIFY( t.isctype('t', t.lookup_classname(range(upper), true)));
VERIFY( t.isctype('T', t.lookup_classname(range(lower), true)));
#undef range
}
int main()
......
// { dg-do run { xfail *-*-* } }
// { dg-do run }
// { dg-options "-std=c++0x" }
//
......
// { dg-do run { xfail *-*-* } }
// { dg-do run }
// { dg-options "-std=c++0x" }
//
......
// { dg-options "-std=c++0x" }
// { dg-do run { xfail *-*-* } }
// { dg-do run }
//
// 2010-02-17 Stephen M. Webb <stephen.webb@bregmasoft.ca>
......@@ -42,10 +42,12 @@ test01()
traits::string_type J = "ABC";
VERIFY( G < H );
VERIFY( t.transform_primary(G.begin(), G.end()) < t.transform_primary(H.begin(), H.end()) );
VERIFY( t.transform_primary(G.begin(), G.end())
< t.transform_primary(H.begin(), H.end()) );
VERIFY( G == H );
VERIFY( t.transform_primary(G.begin(), G.end()) == t.transform_primary(J.begin(), J.end()) );
VERIFY( G > J );
VERIFY( t.transform_primary(G.begin(), G.end())
== t.transform_primary(J.begin(), J.end()) );
}
int main()
......
// { dg-do run }
// { dg-options "-std=c++0x" }
// Copyright (C) 2010-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 28.3 Requirements [re.req]
// 28.2(4) Table 127 - Regular expression traits class requirements
// 28.7(11) Class template regex_traits [re.traits]
#include <regex>
#include <testsuite_hooks.h>
void
test01()
{
bool test __attribute__((unused)) = true;
typedef wchar_t CharT;
typedef std::regex_traits<CharT> traits;
const CharT lower[] = L"lOWer";
const CharT upper[] = L"UPPER";
const CharT nothing[] = L"nothing";
const CharT word[] = L"w";
const CharT blank[] = L"blank";
const CharT digit[] = L"digit";
traits t;
#define range(s) s, s+sizeof(s)/sizeof(s[0])-1
VERIFY( t.isctype(L'_', t.lookup_classname(range(word))));
VERIFY( t.isctype(L'A', t.lookup_classname(range(word))));
VERIFY(!t.isctype(L'~', t.lookup_classname(range(word))));
VERIFY(!t.isctype(L'e', t.lookup_classname(range(upper))));
VERIFY( t.isctype(L'e', t.lookup_classname(range(lower))));
VERIFY(!t.isctype(L'e', t.lookup_classname(range(nothing))));
VERIFY(!t.isctype(L'_', t.lookup_classname(range(digit))));
VERIFY( t.isctype(L' ', t.lookup_classname(range(blank))));
VERIFY( t.isctype(L'\t', t.lookup_classname(range(blank))));
VERIFY(!t.isctype(L'\n', t.lookup_classname(range(blank))));
VERIFY( t.isctype(L't', t.lookup_classname(range(upper), true)));
VERIFY( t.isctype(L'T', t.lookup_classname(range(lower), true)));
#undef range
}
int main()
{
test01();
return 0;
}
// { dg-do run }
// { dg-options "-std=c++0x" }
// Copyright (C) 2010-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 28.3 Requirements [re.req]
// 28.2(4) Table 127 - Regular expression traits class requirements
// 28.7(9) Class template regex_traits [re.traits]
#include <regex>
#include <testsuite_hooks.h>
void
test01()
{
bool test __attribute__((unused)) = true;
typedef wchar_t CharT;
typedef std::regex_traits<CharT> traits;
wchar_t n1[] = L"lower";
wchar_t n2[] = L"alpha";
traits t;
#define range(s) s, s+sizeof(s)/sizeof(s[0])-1
traits::char_class_type c1 = t.lookup_classname(range(n1));
VERIFY( c1 != 0 );
traits::char_class_type c2 = t.lookup_classname(range(n1), true);
traits::char_class_type c3 = t.lookup_classname(range(n2), true);
VERIFY( c2 == c3 );
#undef range
}
int main()
{
test01();
return 0;
}
// { dg-do run }
// { dg-options "-std=c++0x" }
//
// Copyright (C) 2010-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 28.3 Requirements [re.req]
// 28.2 (4) Table 127 - Regular expression traits class requirements
// 28.7 (8) Class template regex_traits [re.traits]
#include <regex>
#include <testsuite_hooks.h>
void
test01()
{
bool test __attribute__((unused)) = true;
typedef wchar_t CharT;
typedef std::regex_traits<CharT> traits;
wchar_t name[] = L"ll";
traits t;
traits::string_type sname =
t.lookup_collatename(name, name+sizeof(name)/sizeof(*name)-1);
VERIFY( !sname.empty() );
}
int main()
{
test01();
return 0;
}
// { dg-options "-std=c++0x" }
// { dg-do run }
//
// Copyright (C) 2010-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 28.3 Requirements [re.req]
// 28.2 (4) Table 127 - Regular expression traits class requirements
// 28.7 Class template regex_traits [re.traits]
#include <regex>
#include <string>
#include <testsuite_hooks.h>
void
test01()
{
bool test __attribute__((unused)) = true;
typedef wchar_t CharT;
typedef std::regex_traits<CharT> traits;
traits t;
traits::string_type G = L"abc";
traits::string_type H = L"def";
traits::string_type J = L"ABC";
VERIFY( G < H );
VERIFY( t.transform_primary(G.begin(), G.end())
< t.transform_primary(H.begin(), H.end()) );
VERIFY( G > J );
VERIFY( t.transform_primary(G.begin(), G.end())
== t.transform_primary(J.begin(), J.end()) );
}
int main()
{
test01();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment