OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 #include <sstream> | 12 #include <sstream> |
13 #include <string> | 13 #include <string> |
14 #include <utility> | 14 #include <utility> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
| 17 #include "webrtc/api/optional.h" |
17 #include "webrtc/rtc_base/gunit.h" | 18 #include "webrtc/rtc_base/gunit.h" |
18 #include "webrtc/rtc_base/optional.h" | |
19 | 19 |
20 namespace rtc { | 20 namespace rtc { |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 struct MyUnprintableType { | 24 struct MyUnprintableType { |
25 int value; | 25 int value; |
26 }; | 26 }; |
27 | 27 |
28 struct MyPrintableType { | 28 struct MyPrintableType { |
29 int value; | 29 int value; |
30 }; | 30 }; |
31 | 31 |
32 struct MyOstreamPrintableType { | 32 struct MyOstreamPrintableType { |
33 int value; | 33 int value; |
34 }; | 34 }; |
35 | 35 |
36 void PrintTo(const MyPrintableType& mpt, std::ostream* os) { | 36 void PrintTo(const MyPrintableType& mpt, std::ostream* os) { |
37 *os << "The value is " << mpt.value; | 37 *os << "The value is " << mpt.value; |
38 } | 38 } |
39 | 39 |
40 std::ostream& operator<<(std::ostream& os, | 40 std::ostream& operator<<(std::ostream& os, const MyPrintableType& mpt) { |
41 const MyPrintableType& mpt) { | |
42 os << mpt.value; | 41 os << mpt.value; |
43 return os; | 42 return os; |
44 } | 43 } |
45 | 44 |
46 std::ostream& operator<<(std::ostream& os, | 45 std::ostream& operator<<(std::ostream& os, const MyOstreamPrintableType& mpt) { |
47 const MyOstreamPrintableType& mpt) { | |
48 os << mpt.value; | 46 os << mpt.value; |
49 return os; | 47 return os; |
50 } | 48 } |
51 | 49 |
52 // Class whose instances logs various method calls (constructor, destructor, | 50 // Class whose instances logs various method calls (constructor, destructor, |
53 // etc.). Each instance has a unique ID (a simple global sequence number) and | 51 // etc.). Each instance has a unique ID (a simple global sequence number) and |
54 // an origin ID. When a copy is made, the new object gets a fresh ID but copies | 52 // an origin ID. When a copy is made, the new object gets a fresh ID but copies |
55 // the origin ID from the original. When a new Logger is created from scratch, | 53 // the origin ID from the original. When a new Logger is created from scratch, |
56 // it gets a fresh ID, and the origin ID is the same as the ID (default | 54 // it gets a fresh ID, and the origin ID is the same as the ID (default |
57 // constructor) or given as an argument (explicit constructor). | 55 // constructor) or given as an argument (explicit constructor). |
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 // for MyPrintableType never getting called. | 820 // for MyPrintableType never getting called. |
823 const MyPrintableType dont_warn{17}; | 821 const MyPrintableType dont_warn{17}; |
824 const MyOstreamPrintableType dont_warn2{18}; | 822 const MyOstreamPrintableType dont_warn2{18}; |
825 std::stringstream sstr; | 823 std::stringstream sstr; |
826 sstr << dont_warn; | 824 sstr << dont_warn; |
827 PrintTo(dont_warn, &sstr); | 825 PrintTo(dont_warn, &sstr); |
828 sstr << dont_warn2; | 826 sstr << dont_warn2; |
829 } | 827 } |
830 | 828 |
831 } // namespace rtc | 829 } // namespace rtc |
OLD | NEW |