Move test into test/std subdirectory.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@224658 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2014-12-20 01:40:03 +00:00
parent 669a8a5a19
commit a90c6dd460
4817 changed files with 13 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
int main()
{
}

View File

@@ -0,0 +1,38 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <regex>
// class regex_iterator<BidirectionalIterator, charT, traits>
// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
// const regex_type&& re,
// int submatch = 0,
// regex_constants::match_flag_type m =
// regex_constants::match_default) = delete;
#include <__config>
#if _LIBCPP_STD_VER <= 11
#error
#else
#include <regex>
#include <cassert>
int main()
{
{
const char phone_book[] = "555-1234, 555-2345, 555-3456";
std::cregex_iterator i(
std::begin(phone_book), std::end(phone_book),
std::regex("\\d{3}-\\d{4}"));
}
}
#endif

View File

@@ -0,0 +1,44 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. 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());
}
}

View File

@@ -0,0 +1,32 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. 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>();
}

View File

@@ -0,0 +1,19 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. 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()
{
}

View File

@@ -0,0 +1,42 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. 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());
}
}

View File

@@ -0,0 +1,97 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. 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);
std::cregex_iterator i2 = i;
assert(i != std::cregex_iterator());
assert(i2!= std::cregex_iterator());
assert((*i).size() == 1);
assert((*i).position() == 0);
assert((*i).str() == "555-1234");
assert((*i2).size() == 1);
assert((*i2).position() == 0);
assert((*i2).str() == "555-1234");
i++;
assert(i != std::cregex_iterator());
assert(i2!= std::cregex_iterator());
assert((*i).size() == 1);
assert((*i).position() == 10);
assert((*i).str() == "555-2345");
assert((*i2).size() == 1);
assert((*i2).position() == 0);
assert((*i2).str() == "555-1234");
i++;
assert(i != std::cregex_iterator());
assert(i2!= std::cregex_iterator());
assert((*i).size() == 1);
assert((*i).position() == 20);
assert((*i).str() == "555-3456");
assert((*i2).size() == 1);
assert((*i2).position() == 0);
assert((*i2).str() == "555-1234");
i++;
assert(i == std::cregex_iterator());
assert(i2!= std::cregex_iterator());
assert((*i2).size() == 1);
assert((*i2).position() == 0);
assert((*i2).str() == "555-1234");
}
{
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);
std::cregex_iterator i2 = i;
assert(i != std::cregex_iterator());
assert(i2!= std::cregex_iterator());
assert((*i).size() == 1);
assert((*i).position() == 0);
assert((*i).str() == "555-1234");
assert((*i2).size() == 1);
assert((*i2).position() == 0);
assert((*i2).str() == "555-1234");
++i;
assert(i != std::cregex_iterator());
assert(i2!= std::cregex_iterator());
assert((*i).size() == 1);
assert((*i).position() == 10);
assert((*i).str() == "555-2345");
assert((*i2).size() == 1);
assert((*i2).position() == 0);
assert((*i2).str() == "555-1234");
++i;
assert(i != std::cregex_iterator());
assert(i2!= std::cregex_iterator());
assert((*i).size() == 1);
assert((*i).position() == 20);
assert((*i).str() == "555-3456");
assert((*i2).size() == 1);
assert((*i2).position() == 0);
assert((*i2).str() == "555-1234");
++i;
assert(i == std::cregex_iterator());
assert(i2!= std::cregex_iterator());
assert((*i2).size() == 1);
assert((*i2).position() == 0);
assert((*i2).str() == "555-1234");
}
}

View File

@@ -0,0 +1,45 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. 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>();
}

View File

@@ -0,0 +1,41 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <regex>
// class regex_iterator<BidirectionalIterator, charT, traits>
// template <size_t N>
// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
// const regex_type&& re,
// const int (&submatches)[N],
// regex_constants::match_flag_type m =
// regex_constants::match_default);
#include <__config>
#if _LIBCPP_STD_VER <= 11
#error
#else
#include <regex>
#include <vector>
#include <cassert>
int main()
{
{
std::regex phone_numbers("\\d{3}-(\\d{4})");
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
const int indices[] = {-1, 0, 1};
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
std::regex("\\d{3}-\\d{4}"), indices);
}
}
#endif

View File

@@ -0,0 +1,64 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <regex>
// class regex_token_iterator<BidirectionalIterator, charT, traits>
// template <size_t N>
// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
// const regex_type& re,
// const int (&submatches)[N],
// 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[] = "start 555-1234, 555-2345, 555-3456 end";
const int indices[] = {-1, 0, 1};
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
phone_numbers, indices);
assert(i != std::cregex_token_iterator());
assert(i->str() == "start ");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == "555-1234");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == "1234");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == ", ");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == "555-2345");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == "2345");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == ", ");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == "555-3456");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == "3456");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == " end");
++i;
assert(i == std::cregex_token_iterator());
}
}

View File

@@ -0,0 +1,32 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <regex>
// class regex_token_iterator<BidirectionalIterator, charT, traits>
// regex_token_iterator();
#include <regex>
#include <cassert>
template <class CharT>
void
test()
{
typedef std::regex_token_iterator<const CharT*> I;
I i1;
assert(i1 == I());
}
int main()
{
test<char>();
test<wchar_t>();
}

View File

@@ -0,0 +1,38 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <regex>
// class regex_iterator<BidirectionalIterator, charT, traits>
// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
// const regex_type&& re,
// initializer_list<int> submatches,
// regex_constants::match_flag_type m =
// regex_constants::match_default);
#include <__config>
#if _LIBCPP_STD_VER <= 11
#error
#else
#include <regex>
#include <cassert>
int main()
{
{
std::regex phone_numbers("\\d{3}-(\\d{4})");
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
std::regex("\\d{3}-\\d{4}"), {-1, 0, 1});
}
}
#endif

View File

@@ -0,0 +1,64 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <regex>
// class regex_token_iterator<BidirectionalIterator, charT, traits>
// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
// const regex_type& re,
// initializer_list<int> submatches,
// regex_constants::match_flag_type m =
// regex_constants::match_default);
#include <regex>
#include <cassert>
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
{
std::regex phone_numbers("\\d{3}-(\\d{4})");
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
phone_numbers, {-1, 0, 1});
assert(i != std::cregex_token_iterator());
assert(i->str() == "start ");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == "555-1234");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == "1234");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == ", ");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == "555-2345");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == "2345");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == ", ");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == "555-3456");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == "3456");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == " end");
++i;
assert(i == std::cregex_token_iterator());
}
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@@ -0,0 +1,37 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <regex>
// class regex_iterator<BidirectionalIterator, charT, traits>
// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
// const regex_type&& re, int submatch = 0,
// regex_constants::match_flag_type m =
// regex_constants::match_default);
#include <__config>
#if _LIBCPP_STD_VER <= 11
#error
#else
#include <regex>
#include <cassert>
int main()
{
{
std::regex phone_numbers("\\d{3}-\\d{4}");
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
std::regex("\\d{3}-\\d{4}"), -1);
}
}
#endif

View File

@@ -0,0 +1,75 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <regex>
// class regex_token_iterator<BidirectionalIterator, charT, traits>
// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
// const regex_type& re, int submatch = 0,
// 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[] = "start 555-1234, 555-2345, 555-3456 end";
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
phone_numbers, -1);
assert(i != std::cregex_token_iterator());
assert(i->str() == "start ");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == ", ");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == ", ");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == " end");
++i;
assert(i == std::cregex_token_iterator());
}
{
std::regex phone_numbers("\\d{3}-\\d{4}");
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
phone_numbers);
assert(i != std::cregex_token_iterator());
assert(i->str() == "555-1234");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == "555-2345");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == "555-3456");
++i;
assert(i == std::cregex_token_iterator());
}
{
std::regex phone_numbers("\\d{3}-(\\d{4})");
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
phone_numbers, 1);
assert(i != std::cregex_token_iterator());
assert(i->str() == "1234");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == "2345");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == "3456");
++i;
assert(i == std::cregex_token_iterator());
}
}

View File

@@ -0,0 +1,42 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <regex>
// class regex_iterator<BidirectionalIterator, charT, traits>
// template <std::size_t N>
// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
// const regex_type&& re,
// const std::vector<int>& submatches,
// regex_constants::match_flag_type m =
// regex_constants::match_default);
#include <__config>
#if _LIBCPP_STD_VER <= 11
#error
#else
#include <regex>
#include <cassert>
int main()
{
{
std::regex phone_numbers("\\d{3}-(\\d{4})");
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
std::vector<int> v;
v.push_back(-1);
v.push_back(-1);
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
std::regex("\\d{3}-\\d{4}"), v);
}
}
#endif

View File

@@ -0,0 +1,128 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <regex>
// class regex_token_iterator<BidirectionalIterator, charT, traits>
// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
// const regex_type& re,
// const std::vector<int>& submatches,
// 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[] = "start 555-1234, 555-2345, 555-3456 end";
std::vector<int> v;
v.push_back(-1);
v.push_back(-1);
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
phone_numbers, v);
assert(i != std::cregex_token_iterator());
assert(i->str() == "start ");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == "start ");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == ", ");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == ", ");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == ", ");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == ", ");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == " end");
++i;
assert(i == std::cregex_token_iterator());
}
{
std::regex phone_numbers("\\d{3}-(\\d{4})");
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
std::vector<int> v;
v.push_back(-1);
v.push_back(0);
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
phone_numbers, v);
assert(i != std::cregex_token_iterator());
assert(i->str() == "start ");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == "555-1234");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == ", ");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == "555-2345");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == ", ");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == "555-3456");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == " end");
++i;
assert(i == std::cregex_token_iterator());
}
{
std::regex phone_numbers("\\d{3}-(\\d{4})");
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
std::vector<int> v;
v.push_back(-1);
v.push_back(0);
v.push_back(1);
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
phone_numbers, v);
assert(i != std::cregex_token_iterator());
assert(i->str() == "start ");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == "555-1234");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == "1234");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == ", ");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == "555-2345");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == "2345");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == ", ");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == "555-3456");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == "3456");
++i;
assert(i != std::cregex_token_iterator());
assert(i->str() == " end");
++i;
assert(i == std::cregex_token_iterator());
}
}

View File

@@ -0,0 +1,36 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <regex>
// class regex_token_iterator<BidirectionalIterator, charT, traits>
// bool operator==(const regex_token_iterator& right) const;
// bool operator!=(const regex_token_iterator& right) const;
#include <regex>
#include <cassert>
int main()
{
{
std::regex phone_numbers("\\d{3}-\\d{4}");
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
phone_numbers, -1);
assert(i != std::cregex_token_iterator());
assert(!(i == std::cregex_token_iterator()));
std::cregex_token_iterator i2 = i;
assert(i2 == i);
assert(!(i2 != i));
++i;
assert(!(i2 == i));
assert(i2 != i);
}
}

View File

@@ -0,0 +1,72 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <regex>
// class regex_token_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[] = "start 555-1234, 555-2345, 555-3456 end";
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
phone_numbers, -1);
assert(i != std::cregex_token_iterator());
assert((*i).str() == "start ");
++i;
assert(i != std::cregex_token_iterator());
assert((*i).str() == ", ");
++i;
assert(i != std::cregex_token_iterator());
assert((*i).str() == ", ");
++i;
assert(i != std::cregex_token_iterator());
assert((*i).str() == " end");
++i;
assert(i == std::cregex_token_iterator());
}
{
std::regex phone_numbers("\\d{3}-\\d{4}");
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
phone_numbers);
assert(i != std::cregex_token_iterator());
assert((*i).str() == "555-1234");
++i;
assert(i != std::cregex_token_iterator());
assert((*i).str() == "555-2345");
++i;
assert(i != std::cregex_token_iterator());
assert((*i).str() == "555-3456");
++i;
assert(i == std::cregex_token_iterator());
}
{
std::regex phone_numbers("\\d{3}-(\\d{4})");
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
phone_numbers, 1);
assert(i != std::cregex_token_iterator());
assert((*i).str() == "1234");
++i;
assert(i != std::cregex_token_iterator());
assert((*i).str() == "2345");
++i;
assert(i != std::cregex_token_iterator());
assert((*i).str() == "3456");
++i;
assert(i == std::cregex_token_iterator());
}
}

View File

@@ -0,0 +1,135 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <regex>
// class regex_token_iterator<BidirectionalIterator, charT, traits>
// regex_token_iterator& operator++(int);
#include <regex>
#include <cassert>
int main()
{
{
std::regex phone_numbers("\\d{3}-\\d{4}");
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
phone_numbers, -1);
std::cregex_token_iterator i2 = i;
std::cregex_token_iterator i3;
assert(i != std::cregex_token_iterator());
assert(i2 != std::cregex_token_iterator());
assert(i->str() == "start ");
assert(i2->str() == "start ");
i3 = i++;
assert(i != std::cregex_token_iterator());
assert(i2 != std::cregex_token_iterator());
assert(i3 != std::cregex_token_iterator());
assert(i->str() == ", ");
assert(i2->str() == "start ");
assert(i3->str() == "start ");
i3 = i++;
assert(i != std::cregex_token_iterator());
assert(i2 != std::cregex_token_iterator());
assert(i3 != std::cregex_token_iterator());
assert(i->str() == ", ");
assert(i2->str() == "start ");
assert(i3->str() == ", ");
i3 = i++;
assert(i != std::cregex_token_iterator());
assert(i2 != std::cregex_token_iterator());
assert(i3 != std::cregex_token_iterator());
assert(i->str() == " end");
assert(i2->str() == "start ");
assert(i3->str() == ", ");
i3 = i++;
assert(i == std::cregex_token_iterator());
assert(i2 != std::cregex_token_iterator());
assert(i3 != std::cregex_token_iterator());
assert(i2->str() == "start ");
assert(i3->str() == " end");
}
{
std::regex phone_numbers("\\d{3}-\\d{4}");
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
phone_numbers, -1);
std::cregex_token_iterator i2 = i;
std::cregex_token_iterator i3;
assert(i != std::cregex_token_iterator());
assert(i2 != std::cregex_token_iterator());
assert(i->str() == "start ");
assert(i2->str() == "start ");
i3 = i;
++i;
assert(i != std::cregex_token_iterator());
assert(i2 != std::cregex_token_iterator());
assert(i3 != std::cregex_token_iterator());
assert(i->str() == ", ");
assert(i2->str() == "start ");
assert(i3->str() == "start ");
i3 = i;
++i;
assert(i != std::cregex_token_iterator());
assert(i2 != std::cregex_token_iterator());
assert(i3 != std::cregex_token_iterator());
assert(i->str() == ", ");
assert(i2->str() == "start ");
assert(i3->str() == ", ");
i3 = i;
++i;
assert(i != std::cregex_token_iterator());
assert(i2 != std::cregex_token_iterator());
assert(i3 != std::cregex_token_iterator());
assert(i->str() == " end");
assert(i2->str() == "start ");
assert(i3->str() == ", ");
i3 = i;
++i;
assert(i == std::cregex_token_iterator());
assert(i2 != std::cregex_token_iterator());
assert(i3 != std::cregex_token_iterator());
assert(i2->str() == "start ");
assert(i3->str() == " end");
}
{
std::regex phone_numbers("\\d{3}-\\d{4}");
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
phone_numbers);
assert(i != std::cregex_token_iterator());
assert(i->str() == "555-1234");
i++;
assert(i != std::cregex_token_iterator());
assert(i->str() == "555-2345");
i++;
assert(i != std::cregex_token_iterator());
assert(i->str() == "555-3456");
i++;
assert(i == std::cregex_token_iterator());
}
{
std::regex phone_numbers("\\d{3}-(\\d{4})");
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
phone_numbers, 1);
assert(i != std::cregex_token_iterator());
assert(i->str() == "1234");
i++;
assert(i != std::cregex_token_iterator());
assert(i->str() == "2345");
i++;
assert(i != std::cregex_token_iterator());
assert(i->str() == "3456");
i++;
assert(i == std::cregex_token_iterator());
}
}

View File

@@ -0,0 +1,45 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <regex>
// template <class BidirectionalIterator,
// class charT = typename iterator_traits< BidirectionalIterator>::value_type,
// class traits = regex_traits<charT>>
// class regex_token_iterator
// {
// public:
// typedef basic_regex<charT, traits> regex_type;
// typedef sub_match<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_token_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::sub_match<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::sub_match<const CharT*>*>::value), "");
static_assert((std::is_same<typename I::reference, const std::sub_match<const CharT*>&>::value), "");
static_assert((std::is_same<typename I::iterator_category, std::forward_iterator_tag>::value), "");
}
int main()
{
test<char>();
test<wchar_t>();
}