1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <regex>
11 
12 // template <class BidirectionalIterator> class sub_match;
13 
14 // int compare(const sub_match& s) const;
15 
16 #include <regex>
17 #include <cassert>
18 #include "test_macros.h"
19 
main()20 int main()
21 {
22     {
23         typedef char CharT;
24         typedef std::sub_match<const CharT*> SM;
25         SM sm = SM();
26         SM sm2 = SM();
27         assert(sm.compare(sm2) == 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(sm2) > 0);
33         sm2.first = s;
34         sm2.second = s + 3;
35         sm2.matched = true;
36         assert(sm.compare(sm2) == 0);
37     }
38     {
39         typedef wchar_t CharT;
40         typedef std::sub_match<const CharT*> SM;
41         SM sm = SM();
42         SM sm2 = SM();
43         assert(sm.compare(sm2) == 0);
44         const CharT s[] = {'1', '2', '3', 0};
45         sm.first = s;
46         sm.second = s + 3;
47         sm.matched = true;
48         assert(sm.compare(sm2) > 0);
49         sm2.first = s;
50         sm2.second = s + 3;
51         sm2.matched = true;
52         assert(sm.compare(sm2) == 0);
53     }
54 }
55