[re.submatch]
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@107187 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -13,6 +13,8 @@
|
||||
|
||||
// basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript);
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
|
@@ -0,0 +1,49 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 sub_match;
|
||||
|
||||
// int compare(const string_type& s) const;
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef char CharT;
|
||||
typedef std::sub_match<const CharT*> SM;
|
||||
typedef SM::string_type string;
|
||||
SM sm = SM();
|
||||
SM sm2 = SM();
|
||||
assert(sm.compare(string()) == 0);
|
||||
const CharT s[] = {'1', '2', '3', 0};
|
||||
sm.first = s;
|
||||
sm.second = s + 3;
|
||||
sm.matched = true;
|
||||
assert(sm.compare(string()) > 0);
|
||||
assert(sm.compare(string("123")) == 0);
|
||||
}
|
||||
{
|
||||
typedef wchar_t CharT;
|
||||
typedef std::sub_match<const CharT*> SM;
|
||||
typedef SM::string_type string;
|
||||
SM sm = SM();
|
||||
SM sm2 = SM();
|
||||
assert(sm.compare(string()) == 0);
|
||||
const CharT s[] = {'1', '2', '3', 0};
|
||||
sm.first = s;
|
||||
sm.second = s + 3;
|
||||
sm.matched = true;
|
||||
assert(sm.compare(string()) > 0);
|
||||
assert(sm.compare(string(L"123")) == 0);
|
||||
}
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 sub_match;
|
||||
|
||||
// int compare(const sub_match& s) const;
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef char CharT;
|
||||
typedef std::sub_match<const CharT*> SM;
|
||||
SM sm = SM();
|
||||
SM sm2 = SM();
|
||||
assert(sm.compare(sm2) == 0);
|
||||
const CharT s[] = {'1', '2', '3', 0};
|
||||
sm.first = s;
|
||||
sm.second = s + 3;
|
||||
sm.matched = true;
|
||||
assert(sm.compare(sm2) > 0);
|
||||
sm2.first = s;
|
||||
sm2.second = s + 3;
|
||||
sm2.matched = true;
|
||||
assert(sm.compare(sm2) == 0);
|
||||
}
|
||||
{
|
||||
typedef wchar_t CharT;
|
||||
typedef std::sub_match<const CharT*> SM;
|
||||
SM sm = SM();
|
||||
SM sm2 = SM();
|
||||
assert(sm.compare(sm2) == 0);
|
||||
const CharT s[] = {'1', '2', '3', 0};
|
||||
sm.first = s;
|
||||
sm.second = s + 3;
|
||||
sm.matched = true;
|
||||
assert(sm.compare(sm2) > 0);
|
||||
sm2.first = s;
|
||||
sm2.second = s + 3;
|
||||
sm2.matched = true;
|
||||
assert(sm.compare(sm2) == 0);
|
||||
}
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 sub_match;
|
||||
|
||||
// int compare(const value_type* s) const;
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef char CharT;
|
||||
typedef std::sub_match<const CharT*> SM;
|
||||
SM sm = SM();
|
||||
SM sm2 = SM();
|
||||
assert(sm.compare("") == 0);
|
||||
const CharT s[] = {'1', '2', '3', 0};
|
||||
sm.first = s;
|
||||
sm.second = s + 3;
|
||||
sm.matched = true;
|
||||
assert(sm.compare("") > 0);
|
||||
assert(sm.compare("123") == 0);
|
||||
}
|
||||
{
|
||||
typedef wchar_t CharT;
|
||||
typedef std::sub_match<const CharT*> SM;
|
||||
SM sm = SM();
|
||||
SM sm2 = SM();
|
||||
assert(sm.compare(L"") == 0);
|
||||
const CharT s[] = {'1', '2', '3', 0};
|
||||
sm.first = s;
|
||||
sm.second = s + 3;
|
||||
sm.matched = true;
|
||||
assert(sm.compare(L"") > 0);
|
||||
assert(sm.compare(L"123") == 0);
|
||||
}
|
||||
}
|
43
test/re/re.submatch/re.submatch.members/length.pass.cpp
Normal file
43
test/re/re.submatch/re.submatch.members/length.pass.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 sub_match;
|
||||
|
||||
// difference_type length() const;
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef char CharT;
|
||||
typedef std::sub_match<const CharT*> SM;
|
||||
SM sm = SM();
|
||||
assert(sm.length() == 0);
|
||||
const CharT s[] = {'1', '2', '3', 0};
|
||||
sm.first = s;
|
||||
sm.second = s + 3;
|
||||
sm.matched = true;
|
||||
assert(sm.length() == 3);
|
||||
}
|
||||
{
|
||||
typedef wchar_t CharT;
|
||||
typedef std::sub_match<const CharT*> SM;
|
||||
SM sm = SM();
|
||||
assert(sm.length() == 0);
|
||||
const CharT s[] = {'1', '2', '3', 0};
|
||||
sm.first = s;
|
||||
sm.second = s + 3;
|
||||
sm.matched = true;
|
||||
assert(sm.length() == 3);
|
||||
}
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 sub_match;
|
||||
|
||||
// operator string_type() const;
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef char CharT;
|
||||
typedef std::sub_match<const CharT*> SM;
|
||||
SM sm = SM();
|
||||
SM::string_type str = sm;
|
||||
assert(str.empty());
|
||||
const CharT s[] = {'1', '2', '3', 0};
|
||||
sm.first = s;
|
||||
sm.second = s + 3;
|
||||
sm.matched = true;
|
||||
str = sm;
|
||||
assert(str == std::string("123"));
|
||||
}
|
||||
{
|
||||
typedef wchar_t CharT;
|
||||
typedef std::sub_match<const CharT*> SM;
|
||||
SM sm = SM();
|
||||
SM::string_type str = sm;
|
||||
assert(str.empty());
|
||||
const CharT s[] = {'1', '2', '3', 0};
|
||||
sm.first = s;
|
||||
sm.second = s + 3;
|
||||
sm.matched = true;
|
||||
str = sm;
|
||||
assert(str == std::wstring(L"123"));
|
||||
}
|
||||
}
|
47
test/re/re.submatch/re.submatch.members/str.pass.cpp
Normal file
47
test/re/re.submatch/re.submatch.members/str.pass.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 sub_match;
|
||||
|
||||
// string_type str() const;
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef char CharT;
|
||||
typedef std::sub_match<const CharT*> SM;
|
||||
SM sm = SM();
|
||||
SM::string_type str = sm.str();
|
||||
assert(str.empty());
|
||||
const CharT s[] = {'1', '2', '3', 0};
|
||||
sm.first = s;
|
||||
sm.second = s + 3;
|
||||
sm.matched = true;
|
||||
str = sm.str();
|
||||
assert(str == std::string("123"));
|
||||
}
|
||||
{
|
||||
typedef wchar_t CharT;
|
||||
typedef std::sub_match<const CharT*> SM;
|
||||
SM sm = SM();
|
||||
SM::string_type str = sm.str();
|
||||
assert(str.empty());
|
||||
const CharT s[] = {'1', '2', '3', 0};
|
||||
sm.first = s;
|
||||
sm.second = s + 3;
|
||||
sm.matched = true;
|
||||
str = sm.str();
|
||||
assert(str == std::wstring(L"123"));
|
||||
}
|
||||
}
|
283
test/re/re.submatch/re.submatch.op/compare.pass.cpp
Normal file
283
test/re/re.submatch/re.submatch.op/compare.pass.cpp
Normal file
@@ -0,0 +1,283 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 sub_match;
|
||||
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator==(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
|
||||
//
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator!=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
|
||||
//
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator<(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
|
||||
//
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator<=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
|
||||
//
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator>=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
|
||||
//
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
|
||||
//
|
||||
// template <class BiIter, class ST, class SA>
|
||||
// bool
|
||||
// operator==(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
|
||||
// const sub_match<BiIter>& rhs);
|
||||
//
|
||||
// template <class BiIter, class ST, class SA>
|
||||
// bool
|
||||
// operator!=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
|
||||
// const sub_match<BiIter>& rhs);
|
||||
//
|
||||
// template <class BiIter, class ST, class SA>
|
||||
// bool
|
||||
// operator<(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
|
||||
// const sub_match<BiIter>& rhs);
|
||||
//
|
||||
// template <class BiIter, class ST, class SA>
|
||||
// bool
|
||||
// operator>(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
|
||||
// const sub_match<BiIter>& rhs);
|
||||
//
|
||||
// template <class BiIter, class ST, class SA>
|
||||
// bool operator>=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
|
||||
// const sub_match<BiIter>& rhs);
|
||||
//
|
||||
// template <class BiIter, class ST, class SA>
|
||||
// bool
|
||||
// operator<=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
|
||||
// const sub_match<BiIter>& rhs);
|
||||
//
|
||||
// template <class BiIter, class ST, class SA>
|
||||
// bool
|
||||
// operator==(const sub_match<BiIter>& lhs,
|
||||
// const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
|
||||
//
|
||||
// template <class BiIter, class ST, class SA>
|
||||
// bool
|
||||
// operator!=(const sub_match<BiIter>& lhs,
|
||||
// const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
|
||||
//
|
||||
// template <class BiIter, class ST, class SA>
|
||||
// bool
|
||||
// operator<(const sub_match<BiIter>& lhs,
|
||||
// const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
|
||||
//
|
||||
// template <class BiIter, class ST, class SA>
|
||||
// bool operator>(const sub_match<BiIter>& lhs,
|
||||
// const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
|
||||
//
|
||||
// template <class BiIter, class ST, class SA>
|
||||
// bool
|
||||
// operator>=(const sub_match<BiIter>& lhs,
|
||||
// const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
|
||||
//
|
||||
// template <class BiIter, class ST, class SA>
|
||||
// bool
|
||||
// operator<=(const sub_match<BiIter>& lhs,
|
||||
// const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
|
||||
//
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator==(typename iterator_traits<BiIter>::value_type const* lhs,
|
||||
// const sub_match<BiIter>& rhs);
|
||||
//
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator!=(typename iterator_traits<BiIter>::value_type const* lhs,
|
||||
// const sub_match<BiIter>& rhs);
|
||||
//
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator<(typename iterator_traits<BiIter>::value_type const* lhs,
|
||||
// const sub_match<BiIter>& rhs);
|
||||
//
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator>(typename iterator_traits<BiIter>::value_type const* lhs,
|
||||
// const sub_match<BiIter>& rhs);
|
||||
//
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator>=(typename iterator_traits<BiIter>::value_type const* lhs,
|
||||
// const sub_match<BiIter>& rhs);
|
||||
//
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator<=(typename iterator_traits<BiIter>::value_type const* lhs,
|
||||
// const sub_match<BiIter>& rhs);
|
||||
//
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator==(const sub_match<BiIter>& lhs,
|
||||
// typename iterator_traits<BiIter>::value_type const* rhs);
|
||||
//
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator!=(const sub_match<BiIter>& lhs,
|
||||
// typename iterator_traits<BiIter>::value_type const* rhs);
|
||||
//
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator<(const sub_match<BiIter>& lhs,
|
||||
// typename iterator_traits<BiIter>::value_type const* rhs);
|
||||
//
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator>(const sub_match<BiIter>& lhs,
|
||||
// typename iterator_traits<BiIter>::value_type const* rhs);
|
||||
//
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator>=(const sub_match<BiIter>& lhs,
|
||||
// typename iterator_traits<BiIter>::value_type const* rhs);
|
||||
//
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator<=(const sub_match<BiIter>& lhs,
|
||||
// typename iterator_traits<BiIter>::value_type const* rhs);
|
||||
//
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator==(typename iterator_traits<BiIter>::value_type const& lhs,
|
||||
// const sub_match<BiIter>& rhs);
|
||||
//
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator!=(typename iterator_traits<BiIter>::value_type const& lhs,
|
||||
// const sub_match<BiIter>& rhs);
|
||||
//
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator<(typename iterator_traits<BiIter>::value_type const& lhs,
|
||||
// const sub_match<BiIter>& rhs);
|
||||
//
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator>(typename iterator_traits<BiIter>::value_type const& lhs,
|
||||
// const sub_match<BiIter>& rhs);
|
||||
//
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator>=(typename iterator_traits<BiIter>::value_type const& lhs,
|
||||
// const sub_match<BiIter>& rhs);
|
||||
//
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator<=(typename iterator_traits<BiIter>::value_type const& lhs,
|
||||
// const sub_match<BiIter>& rhs);
|
||||
//
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator==(const sub_match<BiIter>& lhs,
|
||||
// typename iterator_traits<BiIter>::value_type const& rhs);
|
||||
//
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator!=(const sub_match<BiIter>& lhs,
|
||||
// typename iterator_traits<BiIter>::value_type const& rhs);
|
||||
//
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator<(const sub_match<BiIter>& lhs,
|
||||
// typename iterator_traits<BiIter>::value_type const& rhs);
|
||||
//
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator>(const sub_match<BiIter>& lhs,
|
||||
// typename iterator_traits<BiIter>::value_type const& rhs);
|
||||
//
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator>=(const sub_match<BiIter>& lhs,
|
||||
// typename iterator_traits<BiIter>::value_type const& rhs);
|
||||
//
|
||||
// template <class BiIter>
|
||||
// bool
|
||||
// operator<=(const sub_match<BiIter>& lhs,
|
||||
// typename iterator_traits<BiIter>::value_type const& rhs);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
void
|
||||
test(const std::basic_string<CharT>& x, const std::basic_string<CharT>& y)
|
||||
{
|
||||
typedef std::basic_string<CharT> string;
|
||||
typedef std::sub_match<typename string::const_iterator> sub_match;
|
||||
sub_match sm1;
|
||||
sm1.first = x.begin();
|
||||
sm1.second = x.end();
|
||||
sm1.matched = true;
|
||||
sub_match sm2;
|
||||
sm2.first = y.begin();
|
||||
sm2.second = y.end();
|
||||
sm2.matched = true;
|
||||
assert((sm1 == sm2) == (x == y));
|
||||
assert((sm1 != sm2) == (x != y));
|
||||
assert((sm1 < sm2) == (x < y));
|
||||
assert((sm1 > sm2) == (x > y));
|
||||
assert((sm1 <= sm2) == (x <= y));
|
||||
assert((sm1 >= sm2) == (x >= y));
|
||||
assert((x == sm2) == (x == y));
|
||||
assert((x != sm2) == (x != y));
|
||||
assert((x < sm2) == (x < y));
|
||||
assert((x > sm2) == (x > y));
|
||||
assert((x <= sm2) == (x <= y));
|
||||
assert((x >= sm2) == (x >= y));
|
||||
assert((sm1 == y) == (x == y));
|
||||
assert((sm1 != y) == (x != y));
|
||||
assert((sm1 < y) == (x < y));
|
||||
assert((sm1 > y) == (x > y));
|
||||
assert((sm1 <= y) == (x <= y));
|
||||
assert((sm1 >= y) == (x >= y));
|
||||
assert((x.c_str() == sm2) == (x == y));
|
||||
assert((x.c_str() != sm2) == (x != y));
|
||||
assert((x.c_str() < sm2) == (x < y));
|
||||
assert((x.c_str() > sm2) == (x > y));
|
||||
assert((x.c_str() <= sm2) == (x <= y));
|
||||
assert((x.c_str() >= sm2) == (x >= y));
|
||||
assert((sm1 == y.c_str()) == (x == y));
|
||||
assert((sm1 != y.c_str()) == (x != y));
|
||||
assert((sm1 < y.c_str()) == (x < y));
|
||||
assert((sm1 > y.c_str()) == (x > y));
|
||||
assert((sm1 <= y.c_str()) == (x <= y));
|
||||
assert((sm1 >= y.c_str()) == (x >= y));
|
||||
assert((x[0] == sm2) == (string(1, x[0]) == y));
|
||||
assert((x[0] != sm2) == (string(1, x[0]) != y));
|
||||
assert((x[0] < sm2) == (string(1, x[0]) < y));
|
||||
assert((x[0] > sm2) == (string(1, x[0]) > y));
|
||||
assert((x[0] <= sm2) == (string(1, x[0]) <= y));
|
||||
assert((x[0] >= sm2) == (string(1, x[0]) >= y));
|
||||
assert((sm1 == y[0]) == (x == string(1, y[0])));
|
||||
assert((sm1 != y[0]) == (x != string(1, y[0])));
|
||||
assert((sm1 < y[0]) == (x < string(1, y[0])));
|
||||
assert((sm1 > y[0]) == (x > string(1, y[0])));
|
||||
assert((sm1 <= y[0]) == (x <= string(1, y[0])));
|
||||
assert((sm1 >= y[0]) == (x >= string(1, y[0])));
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test(std::string("123"), std::string("123"));
|
||||
test(std::string("1234"), std::string("123"));
|
||||
test(std::wstring(L"123"), std::wstring(L"123"));
|
||||
test(std::wstring(L"1234"), std::wstring(L"123"));
|
||||
}
|
42
test/re/re.submatch/re.submatch.op/stream.pass.cpp
Normal file
42
test/re/re.submatch/re.submatch.op/stream.pass.cpp
Normal file
@@ -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>
|
||||
|
||||
// template <class BidirectionalIterator> class sub_match;
|
||||
|
||||
// template <class charT, class ST, class BiIter>
|
||||
// basic_ostream<charT, ST>&
|
||||
// operator<<(basic_ostream<charT, ST>& os, const sub_match<BiIter>& m);
|
||||
|
||||
#include <regex>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
void
|
||||
test(const std::basic_string<CharT>& s)
|
||||
{
|
||||
typedef std::basic_string<CharT> string;
|
||||
typedef std::sub_match<typename string::const_iterator> SM;
|
||||
typedef std::basic_ostringstream<CharT> ostringstream;
|
||||
SM sm;
|
||||
sm.first = s.begin();
|
||||
sm.second = s.end();
|
||||
sm.matched = true;
|
||||
ostringstream os;
|
||||
os << sm;
|
||||
assert(os.str() == s);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test(std::string("123"));
|
||||
test(std::wstring(L"123"));
|
||||
}
|
64
test/re/re.submatch/types.pass.cpp
Normal file
64
test/re/re.submatch/types.pass.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 sub_match
|
||||
// : public pair<BidirectionalIterator, BidirectionalIterator>
|
||||
// {
|
||||
// public:
|
||||
// typedef BidirectionalIterator iterator;
|
||||
// typedef typename iterator_traits<iterator>::value_type value_type;
|
||||
// typedef typename iterator_traits<iterator>::difference_type difference_type;
|
||||
// typedef basic_string<value_type> string_type;
|
||||
//
|
||||
// bool matched;
|
||||
// ...
|
||||
// };
|
||||
|
||||
#include <regex>
|
||||
#include <type_traits>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::sub_match<char*> SM;
|
||||
static_assert((std::is_same<SM::iterator, char*>::value), "");
|
||||
static_assert((std::is_same<SM::value_type, char>::value), "");
|
||||
static_assert((std::is_same<SM::difference_type, std::ptrdiff_t>::value), "");
|
||||
static_assert((std::is_same<SM::string_type, std::string>::value), "");
|
||||
static_assert((std::is_convertible<SM*, std::pair<char*, char*>*>::value), "");
|
||||
|
||||
SM sm;
|
||||
sm.first = nullptr;
|
||||
sm.second = nullptr;
|
||||
sm.matched = false;
|
||||
}
|
||||
{
|
||||
typedef std::sub_match<wchar_t*> SM;
|
||||
static_assert((std::is_same<SM::iterator, wchar_t*>::value), "");
|
||||
static_assert((std::is_same<SM::value_type, wchar_t>::value), "");
|
||||
static_assert((std::is_same<SM::difference_type, std::ptrdiff_t>::value), "");
|
||||
static_assert((std::is_same<SM::string_type, std::wstring>::value), "");
|
||||
static_assert((std::is_convertible<SM*, std::pair<wchar_t*, wchar_t*>*>::value), "");
|
||||
|
||||
SM sm;
|
||||
sm.first = nullptr;
|
||||
sm.second = nullptr;
|
||||
sm.matched = false;
|
||||
}
|
||||
{
|
||||
static_assert((std::is_same<std::csub_match, std::sub_match<const char*> >::value), "");
|
||||
static_assert((std::is_same<std::wcsub_match, std::sub_match<const wchar_t*> >::value), "");
|
||||
static_assert((std::is_same<std::ssub_match, std::sub_match<std::string::const_iterator> >::value), "");
|
||||
static_assert((std::is_same<std::wssub_match, std::sub_match<std::wstring::const_iterator> >::value), "");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user