blob: c14d5bcdefae7606860b523546e4c39b4d4421c4 [file] [log] [blame]
Howard Hinnantcd85b9e2010-06-29 18:37:43 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantcd85b9e2010-06-29 18:37:43 +00007//
8//===----------------------------------------------------------------------===//
9
10// <regex>
11
12// template <class BidirectionalIterator> class sub_match;
13
14// int compare(const string_type& s) const;
15
16#include <regex>
17#include <cassert>
Howard Hinnantcd85b9e2010-06-29 18:37:43 +000018
19int main()
20{
21 {
22 typedef char CharT;
23 typedef std::sub_match<const CharT*> SM;
24 typedef SM::string_type string;
25 SM sm = SM();
26 SM sm2 = SM();
27 assert(sm.compare(string()) == 0);
28 const CharT s[] = {'1', '2', '3', 0};
29 sm.first = s;
30 sm.second = s + 3;
31 sm.matched = true;
32 assert(sm.compare(string()) > 0);
33 assert(sm.compare(string("123")) == 0);
34 }
35 {
36 typedef wchar_t CharT;
37 typedef std::sub_match<const CharT*> SM;
38 typedef SM::string_type string;
39 SM sm = SM();
40 SM sm2 = SM();
41 assert(sm.compare(string()) == 0);
42 const CharT s[] = {'1', '2', '3', 0};
43 sm.first = s;
44 sm.second = s + 3;
45 sm.matched = true;
46 assert(sm.compare(string()) > 0);
47 assert(sm.compare(string(L"123")) == 0);
48 }
49}