Debian Codegraph @

libcxx/test/std/re/re.submatch/re.submatch.members/length.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 // difference_type length() 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 assert(sm.length() == 0);
26 const CharT s[] = {'1', '2', '3', 0};
27 sm.first = s;
28 sm.second = s + 3;
29 sm.matched = true;
30 assert(sm.length() == 3);
31 }
32 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
33 {
34 typedef wchar_t CharT;
35 typedef std::sub_match<const CharT*> SM;
36 SM sm = SM();
37 assert(sm.length() == 0);
38 const CharT s[] = {'1', '2', '3', 0};
39 sm.first = s;
40 sm.second = s + 3;
41 sm.matched = true;
42 assert(sm.length() == 3);
43 }
44 #endif
45
46 return 0;
47 }