diff options
Diffstat (limited to 'libcxx/test/std/re/re.iter/re.regiter/re.regiter.cnstr')
3 files changed, 114 insertions, 0 deletions
diff --git a/libcxx/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.fail.cpp b/libcxx/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.fail.cpp new file mode 100644 index 00000000000..9c17287cdb8 --- /dev/null +++ b/libcxx/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.fail.cpp @@ -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 diff --git a/libcxx/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.pass.cpp b/libcxx/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.pass.cpp new file mode 100644 index 00000000000..c9fc7a3cd1c --- /dev/null +++ b/libcxx/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.pass.cpp @@ -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()); + } +} diff --git a/libcxx/test/std/re/re.iter/re.regiter/re.regiter.cnstr/default.pass.cpp b/libcxx/test/std/re/re.iter/re.regiter/re.regiter.cnstr/default.pass.cpp new file mode 100644 index 00000000000..9d4766dc876 --- /dev/null +++ b/libcxx/test/std/re/re.iter/re.regiter/re.regiter.cnstr/default.pass.cpp @@ -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>(); +} |