Debian Codegraph @

libcxx/test/std/re/re.submatch/re.submatch.members/compare_sub_match.pass.cpp

raw
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 // <regex>
10
11 // template <class BidirectionalIterator> class sub_match;
12
13 // int compare(const sub_match& s) const;
14
15 #include <regex>
16 #include <cassert>
17 #include "test_macros.h"
18
19 int main(int, char**)
20 {
21 {
22 typedef char CharT;
23 typedef std::sub_match<const CharT*> SM;
24 SM sm = SM();
25 SM sm2 = SM();
26 assert(sm.compare(sm2) == 0);
27 const CharT s[] = {'1', '2', '3', 0};
28 sm.first = s;
29 sm.second = s + 3;
30 sm.matched = true;
31 assert(sm.compare(sm2) > 0);
32 sm2.first = s;
33 sm2.second = s + 3;
34 sm2.matched = true;
35 assert(sm.compare(sm2) == 0);
36 }
37 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
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 #endif
55
56 return 0;
57 }