summaryrefslogtreecommitdiffstats
path: root/libcxx/test
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test')
-rw-r--r--libcxx/test/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.pass.cpp44
-rw-r--r--libcxx/test/re/re.iter/re.regiter/re.regiter.cnstr/default.pass.cpp32
-rw-r--r--libcxx/test/re/re.iter/re.regiter/re.regiter.comp/tested_elsewhere.pass.cpp19
-rw-r--r--libcxx/test/re/re.iter/re.regiter/re.regiter.deref/deref.pass.cpp42
-rw-r--r--libcxx/test/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp42
-rw-r--r--libcxx/test/re/re.iter/re.regiter/types.pass.cpp45
6 files changed, 224 insertions, 0 deletions
diff --git a/libcxx/test/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.pass.cpp b/libcxx/test/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.pass.cpp
new file mode 100644
index 00000000000..46f4a3eb674
--- /dev/null
+++ b/libcxx/test/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type& re,
+// regex_constants::match_flag_type m = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::cregex_iterator i(std::begin(phone_book), std::end(phone_book), phone_numbers);
+ assert(i != std::cregex_iterator());
+ assert(i->size() == 1);
+ assert(i->position() == 0);
+ assert(i->str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_iterator());
+ assert(i->size() == 1);
+ assert(i->position() == 10);
+ assert(i->str() == "555-2345");
+ ++i;
+ assert(i != std::cregex_iterator());
+ assert(i->size() == 1);
+ assert(i->position() == 20);
+ assert(i->str() == "555-3456");
+ ++i;
+ assert(i == std::cregex_iterator());
+ }
+} \ No newline at end of file
diff --git a/libcxx/test/re/re.iter/re.regiter/re.regiter.cnstr/default.pass.cpp b/libcxx/test/re/re.iter/re.regiter/re.regiter.cnstr/default.pass.cpp
new file mode 100644
index 00000000000..33b0f7e5d60
--- /dev/null
+++ b/libcxx/test/re/re.iter/re.regiter/re.regiter.cnstr/default.pass.cpp
@@ -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>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// regex_iterator();
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test()
+{
+ typedef std::regex_iterator<const CharT*> I;
+ I i1;
+ assert(i1 == I());
+}
+
+int main()
+{
+ test<char>();
+ test<wchar_t>();
+} \ No newline at end of file
diff --git a/libcxx/test/re/re.iter/re.regiter/re.regiter.comp/tested_elsewhere.pass.cpp b/libcxx/test/re/re.iter/re.regiter/re.regiter.comp/tested_elsewhere.pass.cpp
new file mode 100644
index 00000000000..aa4e662d87d
--- /dev/null
+++ b/libcxx/test/re/re.iter/re.regiter/re.regiter.comp/tested_elsewhere.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// bool operator==(const regex_iterator& right) const;
+// bool operator!=(const regex_iterator& right) const;
+
+int main()
+{
+} \ No newline at end of file
diff --git a/libcxx/test/re/re.iter/re.regiter/re.regiter.deref/deref.pass.cpp b/libcxx/test/re/re.iter/re.regiter/re.regiter.deref/deref.pass.cpp
new file mode 100644
index 00000000000..8ea1c587566
--- /dev/null
+++ b/libcxx/test/re/re.iter/re.regiter/re.regiter.deref/deref.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// const value_type& operator*() const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::cregex_iterator i(std::begin(phone_book), std::end(phone_book), phone_numbers);
+ assert(i != std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 0);
+ assert((*i).str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 10);
+ assert((*i).str() == "555-2345");
+ ++i;
+ assert(i != std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 20);
+ assert((*i).str() == "555-3456");
+ ++i;
+ assert(i == std::cregex_iterator());
+ }
+} \ No newline at end of file
diff --git a/libcxx/test/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp b/libcxx/test/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp
new file mode 100644
index 00000000000..66b3f17b3a2
--- /dev/null
+++ b/libcxx/test/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// regex_iterator operator++(int);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::cregex_iterator i(std::begin(phone_book), std::end(phone_book), phone_numbers);
+ assert(i != std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 0);
+ assert((*i).str() == "555-1234");
+ i++;
+ assert(i != std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 10);
+ assert((*i).str() == "555-2345");
+ i++;
+ assert(i != std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 20);
+ assert((*i).str() == "555-3456");
+ i++;
+ assert(i == std::cregex_iterator());
+ }
+} \ No newline at end of file
diff --git a/libcxx/test/re/re.iter/re.regiter/types.pass.cpp b/libcxx/test/re/re.iter/re.regiter/types.pass.cpp
new file mode 100644
index 00000000000..b89e29a98a3
--- /dev/null
+++ b/libcxx/test/re/re.iter/re.regiter/types.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator,
+// class charT = typename iterator_traits< BidirectionalIterator>::value_type,
+// class traits = regex_traits<charT>>
+// class regex_iterator
+// {
+// public:
+// typedef basic_regex<charT, traits> regex_type;
+// typedef match_results<BidirectionalIterator> value_type;
+// typedef ptrdiff_t difference_type;
+// typedef const value_type* pointer;
+// typedef const value_type& reference;
+// typedef forward_iterator_tag iterator_category;
+
+#include <regex>
+#include <type_traits>
+
+template <class CharT>
+void
+test()
+{
+ typedef std::regex_iterator<const CharT*> I;
+ static_assert((std::is_same<typename I::regex_type, std::basic_regex<CharT> >::value), "");
+ static_assert((std::is_same<typename I::value_type, std::match_results<const CharT*> >::value), "");
+ static_assert((std::is_same<typename I::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<typename I::pointer, const std::match_results<const CharT*>*>::value), "");
+ static_assert((std::is_same<typename I::reference, const std::match_results<const CharT*>&>::value), "");
+ static_assert((std::is_same<typename I::iterator_category, std::forward_iterator_tag>::value), "");
+}
+
+int main()
+{
+ test<char>();
+ test<wchar_t>();
+} \ No newline at end of file
OpenPOWER on IntegriCloud