aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/28_regex
diff options
context:
space:
mode:
authorTim Shen <timshen@google.com>2015-01-19 23:00:13 +0000
committerTim Shen <timshen@gcc.gnu.org>2015-01-19 23:00:13 +0000
commite5f3553320cd121e7952ee7b8ee5cad696336541 (patch)
treebb52ff3db7595623a6812207d0f1160673585f9e /libstdc++-v3/testsuite/28_regex
parent60c176fb459c7780f9cb711e2427e41dca12a54a (diff)
downloadgcc-e5f3553320cd121e7952ee7b8ee5cad696336541.zip
gcc-e5f3553320cd121e7952ee7b8ee5cad696336541.tar.gz
gcc-e5f3553320cd121e7952ee7b8ee5cad696336541.tar.bz2
re PR libstdc++/64649 (regex_traits::lookup_classname() only works with random access iterators)
PR libstdc++/64649 * include/bits/regex.tcc (regex_traits<>::lookup_collatename, regex_traits<>::lookup_classname): Support forward iterators. * testsuite/28_regex/traits/char/lookup_classname.cc: New testcases. * testsuite/28_regex/traits/char/lookup_collatename.cc: New testcase. From-SVN: r219866
Diffstat (limited to 'libstdc++-v3/testsuite/28_regex')
-rw-r--r--libstdc++-v3/testsuite/28_regex/traits/char/lookup_classname.cc22
-rw-r--r--libstdc++-v3/testsuite/28_regex/traits/char/lookup_collatename.cc12
2 files changed, 34 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/28_regex/traits/char/lookup_classname.cc b/libstdc++-v3/testsuite/28_regex/traits/char/lookup_classname.cc
index d7216ce..f4c9758 100644
--- a/libstdc++-v3/testsuite/28_regex/traits/char/lookup_classname.cc
+++ b/libstdc++-v3/testsuite/28_regex/traits/char/lookup_classname.cc
@@ -26,6 +26,7 @@
// 28.7(9) Class template regex_traits [re.traits]
#include <regex>
+#include <forward_list>
#include <testsuite_hooks.h>
void
@@ -47,8 +48,29 @@ test01()
VERIFY( c2 == c3 );
}
+// Test forward iterator
+void
+test02()
+{
+ const char strlit[] = "upper";
+ std::forward_list<char> s(strlit, strlit + strlen(strlit));
+ std::regex_traits<char> traits;
+ VERIFY(traits.isctype('C', traits.lookup_classname(s.begin(), s.end(), false)));
+}
+
+// icase
+void
+test03()
+{
+ std::string s("lower");
+ std::regex_traits<char> traits;
+ VERIFY(traits.isctype('C', traits.lookup_classname(s.begin(), s.end(), true)));
+}
+
int main()
{
test01();
+ test02();
+ test03();
return 0;
}
diff --git a/libstdc++-v3/testsuite/28_regex/traits/char/lookup_collatename.cc b/libstdc++-v3/testsuite/28_regex/traits/char/lookup_collatename.cc
index 56d0576..fac4a24 100644
--- a/libstdc++-v3/testsuite/28_regex/traits/char/lookup_collatename.cc
+++ b/libstdc++-v3/testsuite/28_regex/traits/char/lookup_collatename.cc
@@ -26,6 +26,7 @@
// 28.7 (8) Class template regex_traits [re.traits]
#include <regex>
+#include <forward_list>
#include <testsuite_hooks.h>
void
@@ -40,8 +41,19 @@ test01()
VERIFY(t.lookup_collatename(name, name+sizeof(name)-1) == "~");
}
+// Test forward iterator.
+void
+test02()
+{
+ const char strlit[] = "tilde";
+ std::forward_list<char> s(strlit, strlit + strlen(strlit));
+ std::regex_traits<char> traits;
+ VERIFY(traits.lookup_collatename(s.begin(), s.end()) == "~");
+}
+
int main()
{
test01();
+ test02();
return 0;
}