|
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
- <meta http-equiv="X-UA-Compatible" content="IE=9"/>
- <meta name="generator" content="Doxygen 1.8.14"/>
- <meta name="viewport" content="width=device-width, initial-scale=1"/>
- <title>uTL: test/eclipse-cygwin/lib/gtest/gtest-all.cc Source File</title>
- <link href="tabs.css" rel="stylesheet" type="text/css"/>
- <script type="text/javascript" src="jquery.js"></script>
- <script type="text/javascript" src="dynsections.js"></script>
- <link href="navtree.css" rel="stylesheet" type="text/css"/>
- <script type="text/javascript" src="resize.js"></script>
- <script type="text/javascript" src="navtreedata.js"></script>
- <script type="text/javascript" src="navtree.js"></script>
- <script type="text/javascript">
- /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
- $(document).ready(initResizable);
- /* @license-end */</script>
- <link href="search/search.css" rel="stylesheet" type="text/css"/>
- <script type="text/javascript" src="search/searchdata.js"></script>
- <script type="text/javascript" src="search/search.js"></script>
- <link href="doxygen.css" rel="stylesheet" type="text/css" />
- </head>
- <body>
- <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
- <div id="titlearea">
- <table cellspacing="0" cellpadding="0">
- <tbody>
- <tr style="height: 56px;">
- <td id="projectalign" style="padding-left: 0.5em;">
- <div id="projectname">uTL
- </div>
- <div id="projectbrief">micro Template library</div>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <!-- end header part -->
- <!-- Generated by Doxygen 1.8.14 -->
- <script type="text/javascript">
- /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
- var searchBox = new SearchBox("searchBox", "search",false,'Search');
- /* @license-end */
- </script>
- <script type="text/javascript" src="menudata.js"></script>
- <script type="text/javascript" src="menu.js"></script>
- <script type="text/javascript">
- /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
- $(function() {
- initMenu('',true,false,'search.php','Search');
- $(document).ready(function() { init_search(); });
- });
- /* @license-end */</script>
- <div id="main-nav"></div>
- </div><!-- top -->
- <div id="side-nav" class="ui-resizable side-nav-resizable">
- <div id="nav-tree">
- <div id="nav-tree-contents">
- <div id="nav-sync" class="sync"></div>
- </div>
- </div>
- <div id="splitbar" style="-moz-user-select:none;"
- class="ui-resizable-handle">
- </div>
- </div>
- <script type="text/javascript">
- /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
- $(document).ready(function(){initNavTree('gtest-all_8cc_source.html','');});
- /* @license-end */
- </script>
- <div id="doc-content">
- <!-- window showing the filter options -->
- <div id="MSearchSelectWindow"
- onmouseover="return searchBox.OnSearchSelectShow()"
- onmouseout="return searchBox.OnSearchSelectHide()"
- onkeydown="return searchBox.OnSearchSelectKey(event)">
- </div>
-
- <!-- iframe showing the search results (closed by default) -->
- <div id="MSearchResultsWindow">
- <iframe src="javascript:void(0)" frameborder="0"
- name="MSearchResults" id="MSearchResults">
- </iframe>
- </div>
-
- <div class="header">
- <div class="headertitle">
- <div class="title">gtest-all.cc</div> </div>
- </div><!--header-->
- <div class="contents">
- <a href="gtest-all_8cc.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="comment">// Copyright 2008, Google Inc.</span></div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span> <span class="comment">// All rights reserved.</span></div><div class="line"><a name="l00003"></a><span class="lineno"> 3</span> <span class="comment">//</span></div><div class="line"><a name="l00004"></a><span class="lineno"> 4</span> <span class="comment">// Redistribution and use in source and binary forms, with or without</span></div><div class="line"><a name="l00005"></a><span class="lineno"> 5</span> <span class="comment">// modification, are permitted provided that the following conditions are</span></div><div class="line"><a name="l00006"></a><span class="lineno"> 6</span> <span class="comment">// met:</span></div><div class="line"><a name="l00007"></a><span class="lineno"> 7</span> <span class="comment">//</span></div><div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <span class="comment">// * Redistributions of source code must retain the above copyright</span></div><div class="line"><a name="l00009"></a><span class="lineno"> 9</span> <span class="comment">// notice, this list of conditions and the following disclaimer.</span></div><div class="line"><a name="l00010"></a><span class="lineno"> 10</span> <span class="comment">// * Redistributions in binary form must reproduce the above</span></div><div class="line"><a name="l00011"></a><span class="lineno"> 11</span> <span class="comment">// copyright notice, this list of conditions and the following disclaimer</span></div><div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="comment">// in the documentation and/or other materials provided with the</span></div><div class="line"><a name="l00013"></a><span class="lineno"> 13</span> <span class="comment">// distribution.</span></div><div class="line"><a name="l00014"></a><span class="lineno"> 14</span> <span class="comment">// * Neither the name of Google Inc. nor the names of its</span></div><div class="line"><a name="l00015"></a><span class="lineno"> 15</span> <span class="comment">// contributors may be used to endorse or promote products derived from</span></div><div class="line"><a name="l00016"></a><span class="lineno"> 16</span> <span class="comment">// this software without specific prior written permission.</span></div><div class="line"><a name="l00017"></a><span class="lineno"> 17</span> <span class="comment">//</span></div><div class="line"><a name="l00018"></a><span class="lineno"> 18</span> <span class="comment">// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span></div><div class="line"><a name="l00019"></a><span class="lineno"> 19</span> <span class="comment">// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</span></div><div class="line"><a name="l00020"></a><span class="lineno"> 20</span> <span class="comment">// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR</span></div><div class="line"><a name="l00021"></a><span class="lineno"> 21</span> <span class="comment">// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT</span></div><div class="line"><a name="l00022"></a><span class="lineno"> 22</span> <span class="comment">// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span></div><div class="line"><a name="l00023"></a><span class="lineno"> 23</span> <span class="comment">// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</span></div><div class="line"><a name="l00024"></a><span class="lineno"> 24</span> <span class="comment">// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</span></div><div class="line"><a name="l00025"></a><span class="lineno"> 25</span> <span class="comment">// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY</span></div><div class="line"><a name="l00026"></a><span class="lineno"> 26</span> <span class="comment">// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span></div><div class="line"><a name="l00027"></a><span class="lineno"> 27</span> <span class="comment">// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE</span></div><div class="line"><a name="l00028"></a><span class="lineno"> 28</span> <span class="comment">// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span></div><div class="line"><a name="l00029"></a><span class="lineno"> 29</span> </div><div class="line"><a name="l00030"></a><span class="lineno"> 30</span> <span class="comment">//</span></div><div class="line"><a name="l00031"></a><span class="lineno"> 31</span> <span class="comment">// Google C++ Testing and Mocking Framework (Google Test)</span></div><div class="line"><a name="l00032"></a><span class="lineno"> 32</span> <span class="comment">//</span></div><div class="line"><a name="l00033"></a><span class="lineno"> 33</span> <span class="comment">// Sometimes it's desirable to build Google Test by compiling a single file.</span></div><div class="line"><a name="l00034"></a><span class="lineno"> 34</span> <span class="comment">// This file serves this purpose.</span></div><div class="line"><a name="l00035"></a><span class="lineno"> 35</span> </div><div class="line"><a name="l00036"></a><span class="lineno"> 36</span> <span class="comment">// This line ensures that gtest.h can be compiled on its own, even</span></div><div class="line"><a name="l00037"></a><span class="lineno"> 37</span> <span class="comment">// when it's fused.</span></div><div class="line"><a name="l00038"></a><span class="lineno"> 38</span> <span class="preprocessor">#include "<a class="code" href="gtest_8h.html">gtest.h</a>"</span></div><div class="line"><a name="l00039"></a><span class="lineno"> 39</span> </div><div class="line"><a name="l00040"></a><span class="lineno"> 40</span> <span class="comment">// The following lines pull in the real gtest *.cc files.</span></div><div class="line"><a name="l00041"></a><span class="lineno"> 41</span> <span class="comment">// Copyright 2005, Google Inc.</span></div><div class="line"><a name="l00042"></a><span class="lineno"> 42</span> <span class="comment">// All rights reserved.</span></div><div class="line"><a name="l00043"></a><span class="lineno"> 43</span> <span class="comment">//</span></div><div class="line"><a name="l00044"></a><span class="lineno"> 44</span> <span class="comment">// Redistribution and use in source and binary forms, with or without</span></div><div class="line"><a name="l00045"></a><span class="lineno"> 45</span> <span class="comment">// modification, are permitted provided that the following conditions are</span></div><div class="line"><a name="l00046"></a><span class="lineno"> 46</span> <span class="comment">// met:</span></div><div class="line"><a name="l00047"></a><span class="lineno"> 47</span> <span class="comment">//</span></div><div class="line"><a name="l00048"></a><span class="lineno"> 48</span> <span class="comment">// * Redistributions of source code must retain the above copyright</span></div><div class="line"><a name="l00049"></a><span class="lineno"> 49</span> <span class="comment">// notice, this list of conditions and the following disclaimer.</span></div><div class="line"><a name="l00050"></a><span class="lineno"> 50</span> <span class="comment">// * Redistributions in binary form must reproduce the above</span></div><div class="line"><a name="l00051"></a><span class="lineno"> 51</span> <span class="comment">// copyright notice, this list of conditions and the following disclaimer</span></div><div class="line"><a name="l00052"></a><span class="lineno"> 52</span> <span class="comment">// in the documentation and/or other materials provided with the</span></div><div class="line"><a name="l00053"></a><span class="lineno"> 53</span> <span class="comment">// distribution.</span></div><div class="line"><a name="l00054"></a><span class="lineno"> 54</span> <span class="comment">// * Neither the name of Google Inc. nor the names of its</span></div><div class="line"><a name="l00055"></a><span class="lineno"> 55</span> <span class="comment">// contributors may be used to endorse or promote products derived from</span></div><div class="line"><a name="l00056"></a><span class="lineno"> 56</span> <span class="comment">// this software without specific prior written permission.</span></div><div class="line"><a name="l00057"></a><span class="lineno"> 57</span> <span class="comment">//</span></div><div class="line"><a name="l00058"></a><span class="lineno"> 58</span> <span class="comment">// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span></div><div class="line"><a name="l00059"></a><span class="lineno"> 59</span> <span class="comment">// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</span></div><div class="line"><a name="l00060"></a><span class="lineno"> 60</span> <span class="comment">// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR</span></div><div class="line"><a name="l00061"></a><span class="lineno"> 61</span> <span class="comment">// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT</span></div><div class="line"><a name="l00062"></a><span class="lineno"> 62</span> <span class="comment">// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span></div><div class="line"><a name="l00063"></a><span class="lineno"> 63</span> <span class="comment">// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</span></div><div class="line"><a name="l00064"></a><span class="lineno"> 64</span> <span class="comment">// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</span></div><div class="line"><a name="l00065"></a><span class="lineno"> 65</span> <span class="comment">// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY</span></div><div class="line"><a name="l00066"></a><span class="lineno"> 66</span> <span class="comment">// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span></div><div class="line"><a name="l00067"></a><span class="lineno"> 67</span> <span class="comment">// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE</span></div><div class="line"><a name="l00068"></a><span class="lineno"> 68</span> <span class="comment">// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span></div><div class="line"><a name="l00069"></a><span class="lineno"> 69</span> </div><div class="line"><a name="l00070"></a><span class="lineno"> 70</span> <span class="comment">//</span></div><div class="line"><a name="l00071"></a><span class="lineno"> 71</span> <span class="comment">// The Google C++ Testing and Mocking Framework (Google Test)</span></div><div class="line"><a name="l00072"></a><span class="lineno"> 72</span> </div><div class="line"><a name="l00073"></a><span class="lineno"> 73</span> <span class="comment">// Copyright 2007, Google Inc.</span></div><div class="line"><a name="l00074"></a><span class="lineno"> 74</span> <span class="comment">// All rights reserved.</span></div><div class="line"><a name="l00075"></a><span class="lineno"> 75</span> <span class="comment">//</span></div><div class="line"><a name="l00076"></a><span class="lineno"> 76</span> <span class="comment">// Redistribution and use in source and binary forms, with or without</span></div><div class="line"><a name="l00077"></a><span class="lineno"> 77</span> <span class="comment">// modification, are permitted provided that the following conditions are</span></div><div class="line"><a name="l00078"></a><span class="lineno"> 78</span> <span class="comment">// met:</span></div><div class="line"><a name="l00079"></a><span class="lineno"> 79</span> <span class="comment">//</span></div><div class="line"><a name="l00080"></a><span class="lineno"> 80</span> <span class="comment">// * Redistributions of source code must retain the above copyright</span></div><div class="line"><a name="l00081"></a><span class="lineno"> 81</span> <span class="comment">// notice, this list of conditions and the following disclaimer.</span></div><div class="line"><a name="l00082"></a><span class="lineno"> 82</span> <span class="comment">// * Redistributions in binary form must reproduce the above</span></div><div class="line"><a name="l00083"></a><span class="lineno"> 83</span> <span class="comment">// copyright notice, this list of conditions and the following disclaimer</span></div><div class="line"><a name="l00084"></a><span class="lineno"> 84</span> <span class="comment">// in the documentation and/or other materials provided with the</span></div><div class="line"><a name="l00085"></a><span class="lineno"> 85</span> <span class="comment">// distribution.</span></div><div class="line"><a name="l00086"></a><span class="lineno"> 86</span> <span class="comment">// * Neither the name of Google Inc. nor the names of its</span></div><div class="line"><a name="l00087"></a><span class="lineno"> 87</span> <span class="comment">// contributors may be used to endorse or promote products derived from</span></div><div class="line"><a name="l00088"></a><span class="lineno"> 88</span> <span class="comment">// this software without specific prior written permission.</span></div><div class="line"><a name="l00089"></a><span class="lineno"> 89</span> <span class="comment">//</span></div><div class="line"><a name="l00090"></a><span class="lineno"> 90</span> <span class="comment">// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span></div><div class="line"><a name="l00091"></a><span class="lineno"> 91</span> <span class="comment">// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</span></div><div class="line"><a name="l00092"></a><span class="lineno"> 92</span> <span class="comment">// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR</span></div><div class="line"><a name="l00093"></a><span class="lineno"> 93</span> <span class="comment">// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT</span></div><div class="line"><a name="l00094"></a><span class="lineno"> 94</span> <span class="comment">// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span></div><div class="line"><a name="l00095"></a><span class="lineno"> 95</span> <span class="comment">// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</span></div><div class="line"><a name="l00096"></a><span class="lineno"> 96</span> <span class="comment">// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</span></div><div class="line"><a name="l00097"></a><span class="lineno"> 97</span> <span class="comment">// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY</span></div><div class="line"><a name="l00098"></a><span class="lineno"> 98</span> <span class="comment">// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span></div><div class="line"><a name="l00099"></a><span class="lineno"> 99</span> <span class="comment">// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE</span></div><div class="line"><a name="l00100"></a><span class="lineno"> 100</span> <span class="comment">// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span></div><div class="line"><a name="l00101"></a><span class="lineno"> 101</span> </div><div class="line"><a name="l00102"></a><span class="lineno"> 102</span> <span class="comment">//</span></div><div class="line"><a name="l00103"></a><span class="lineno"> 103</span> <span class="comment">// Utilities for testing Google Test itself and code that uses Google Test</span></div><div class="line"><a name="l00104"></a><span class="lineno"> 104</span> <span class="comment">// (e.g. frameworks built on top of Google Test).</span></div><div class="line"><a name="l00105"></a><span class="lineno"> 105</span> </div><div class="line"><a name="l00106"></a><span class="lineno"> 106</span> <span class="comment">// GOOGLETEST_CM0004 DO NOT DELETE</span></div><div class="line"><a name="l00107"></a><span class="lineno"> 107</span> </div><div class="line"><a name="l00108"></a><span class="lineno"> 108</span> <span class="preprocessor">#ifndef GTEST_INCLUDE_GTEST_GTEST_SPI_H_</span></div><div class="line"><a name="l00109"></a><span class="lineno"><a class="line" href="gtest-all_8cc.html#a2f159eaa9c00e7aa9fd6b296e520e35c"> 109</a></span> <span class="preprocessor">#define GTEST_INCLUDE_GTEST_GTEST_SPI_H_</span></div><div class="line"><a name="l00110"></a><span class="lineno"> 110</span> </div><div class="line"><a name="l00111"></a><span class="lineno"> 111</span> </div><div class="line"><a name="l00112"></a><span class="lineno"><a class="line" href="gtest-all_8cc.html#a88f79832f9d045112a76e9da8611cc13"> 112</a></span> <a class="code" href="gtest-all_8cc.html#a88f79832f9d045112a76e9da8611cc13">GTEST_DISABLE_MSC_WARNINGS_PUSH_</a>(4251 \</div><div class="line"><a name="l00113"></a><span class="lineno"> 113</span> <span class="comment">/* class A needs to have dll-interface to be used by clients of class B */</span>)</div><div class="line"><a name="l00114"></a><span class="lineno"> 114</span> </div><div class="line"><a name="l00115"></a><span class="lineno"> 115</span> namespace <a class="code" href="namespacetesting.html">testing</a> {</div><div class="line"><a name="l00116"></a><span class="lineno"> 116</span> </div><div class="line"><a name="l00117"></a><span class="lineno"> 117</span> <span class="comment">// This helper class can be used to mock out Google Test failure reporting</span></div><div class="line"><a name="l00118"></a><span class="lineno"> 118</span> <span class="comment">// so that we can test Google Test or code that builds on Google Test.</span></div><div class="line"><a name="l00119"></a><span class="lineno"> 119</span> <span class="comment">//</span></div><div class="line"><a name="l00120"></a><span class="lineno"> 120</span> <span class="comment">// An object of this class appends a TestPartResult object to the</span></div><div class="line"><a name="l00121"></a><span class="lineno"> 121</span> <span class="comment">// TestPartResultArray object given in the constructor whenever a Google Test</span></div><div class="line"><a name="l00122"></a><span class="lineno"> 122</span> <span class="comment">// failure is reported. It can either intercept only failures that are</span></div><div class="line"><a name="l00123"></a><span class="lineno"> 123</span> <span class="comment">// generated in the same thread that created this object or it can intercept</span></div><div class="line"><a name="l00124"></a><span class="lineno"> 124</span> <span class="comment">// all generated failures. The scope of this mock object can be controlled with</span></div><div class="line"><a name="l00125"></a><span class="lineno"> 125</span> <span class="comment">// the second argument to the two arguments constructor.</span></div><div class="line"><a name="l00126"></a><span class="lineno"> 126</span> <span class="keyword">class </span><a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> ScopedFakeTestPartResultReporter</div><div class="line"><a name="l00127"></a><span class="lineno"> 127</span>  : <span class="keyword">public</span> TestPartResultReporterInterface {</div><div class="line"><a name="l00128"></a><span class="lineno"> 128</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00129"></a><span class="lineno"> 129</span>  <span class="comment">// The two possible mocking modes of this object.</span></div><div class="line"><a name="l00130"></a><span class="lineno"> 130</span>  <span class="keyword">enum</span> InterceptMode {</div><div class="line"><a name="l00131"></a><span class="lineno"> 131</span>  INTERCEPT_ONLY_CURRENT_THREAD, <span class="comment">// Intercepts only thread local failures.</span></div><div class="line"><a name="l00132"></a><span class="lineno"> 132</span>  INTERCEPT_ALL_THREADS <span class="comment">// Intercepts all failures.</span></div><div class="line"><a name="l00133"></a><span class="lineno"> 133</span>  };</div><div class="line"><a name="l00134"></a><span class="lineno"> 134</span> </div><div class="line"><a name="l00135"></a><span class="lineno"> 135</span>  <span class="comment">// The c'tor sets this object as the test part result reporter used</span></div><div class="line"><a name="l00136"></a><span class="lineno"> 136</span>  <span class="comment">// by Google Test. The 'result' parameter specifies where to report the</span></div><div class="line"><a name="l00137"></a><span class="lineno"> 137</span>  <span class="comment">// results. This reporter will only catch failures generated in the current</span></div><div class="line"><a name="l00138"></a><span class="lineno"> 138</span>  <span class="comment">// thread. DEPRECATED</span></div><div class="line"><a name="l00139"></a><span class="lineno"> 139</span>  <span class="keyword">explicit</span> ScopedFakeTestPartResultReporter(TestPartResultArray* result);</div><div class="line"><a name="l00140"></a><span class="lineno"> 140</span> </div><div class="line"><a name="l00141"></a><span class="lineno"> 141</span>  <span class="comment">// Same as above, but you can choose the interception scope of this object.</span></div><div class="line"><a name="l00142"></a><span class="lineno"> 142</span>  ScopedFakeTestPartResultReporter(InterceptMode intercept_mode,</div><div class="line"><a name="l00143"></a><span class="lineno"> 143</span>  TestPartResultArray* result);</div><div class="line"><a name="l00144"></a><span class="lineno"> 144</span> </div><div class="line"><a name="l00145"></a><span class="lineno"> 145</span>  <span class="comment">// The d'tor restores the previous test part result reporter.</span></div><div class="line"><a name="l00146"></a><span class="lineno"> 146</span>  ~ScopedFakeTestPartResultReporter() <span class="keyword">override</span>;</div><div class="line"><a name="l00147"></a><span class="lineno"> 147</span> </div><div class="line"><a name="l00148"></a><span class="lineno"> 148</span>  <span class="comment">// Appends the TestPartResult object to the TestPartResultArray</span></div><div class="line"><a name="l00149"></a><span class="lineno"> 149</span>  <span class="comment">// received in the constructor.</span></div><div class="line"><a name="l00150"></a><span class="lineno"> 150</span>  <span class="comment">//</span></div><div class="line"><a name="l00151"></a><span class="lineno"> 151</span>  <span class="comment">// This method is from the TestPartResultReporterInterface</span></div><div class="line"><a name="l00152"></a><span class="lineno"> 152</span>  <span class="comment">// interface.</span></div><div class="line"><a name="l00153"></a><span class="lineno"> 153</span>  <span class="keywordtype">void</span> ReportTestPartResult(<span class="keyword">const</span> TestPartResult& result) <span class="keyword">override</span>;</div><div class="line"><a name="l00154"></a><span class="lineno"> 154</span> </div><div class="line"><a name="l00155"></a><span class="lineno"> 155</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l00156"></a><span class="lineno"> 156</span>  <span class="keywordtype">void</span> Init();</div><div class="line"><a name="l00157"></a><span class="lineno"> 157</span> </div><div class="line"><a name="l00158"></a><span class="lineno"> 158</span>  <span class="keyword">const</span> InterceptMode intercept_mode_;</div><div class="line"><a name="l00159"></a><span class="lineno"> 159</span>  TestPartResultReporterInterface* old_reporter_;</div><div class="line"><a name="l00160"></a><span class="lineno"> 160</span>  TestPartResultArray* <span class="keyword">const</span> result_;</div><div class="line"><a name="l00161"></a><span class="lineno"> 161</span> </div><div class="line"><a name="l00162"></a><span class="lineno"> 162</span>  <a class="code" href="gtest_8h.html#aed8c1888c32b588b0681e88b95031e29">GTEST_DISALLOW_COPY_AND_ASSIGN_</a>(ScopedFakeTestPartResultReporter);</div><div class="line"><a name="l00163"></a><span class="lineno"> 163</span> };</div><div class="line"><a name="l00164"></a><span class="lineno"> 164</span> </div><div class="line"><a name="l00165"></a><span class="lineno"> 165</span> <span class="keyword">namespace </span>internal {</div><div class="line"><a name="l00166"></a><span class="lineno"> 166</span> </div><div class="line"><a name="l00167"></a><span class="lineno"> 167</span> <span class="comment">// A helper class for implementing EXPECT_FATAL_FAILURE() and</span></div><div class="line"><a name="l00168"></a><span class="lineno"> 168</span> <span class="comment">// EXPECT_NONFATAL_FAILURE(). Its destructor verifies that the given</span></div><div class="line"><a name="l00169"></a><span class="lineno"> 169</span> <span class="comment">// TestPartResultArray contains exactly one failure that has the given</span></div><div class="line"><a name="l00170"></a><span class="lineno"> 170</span> <span class="comment">// type and contains the given substring. If that's not the case, a</span></div><div class="line"><a name="l00171"></a><span class="lineno"> 171</span> <span class="comment">// non-fatal failure will be generated.</span></div><div class="line"><a name="l00172"></a><span class="lineno"> 172</span> <span class="keyword">class </span><a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> SingleFailureChecker {</div><div class="line"><a name="l00173"></a><span class="lineno"> 173</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00174"></a><span class="lineno"> 174</span>  <span class="comment">// The constructor remembers the arguments.</span></div><div class="line"><a name="l00175"></a><span class="lineno"> 175</span>  SingleFailureChecker(<span class="keyword">const</span> TestPartResultArray* results,</div><div class="line"><a name="l00176"></a><span class="lineno"> 176</span>  TestPartResult::Type type, <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& substr);</div><div class="line"><a name="l00177"></a><span class="lineno"> 177</span>  ~SingleFailureChecker();</div><div class="line"><a name="l00178"></a><span class="lineno"> 178</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l00179"></a><span class="lineno"> 179</span>  <span class="keyword">const</span> TestPartResultArray* <span class="keyword">const</span> results_;</div><div class="line"><a name="l00180"></a><span class="lineno"> 180</span>  <span class="keyword">const</span> TestPartResult::Type type_;</div><div class="line"><a name="l00181"></a><span class="lineno"> 181</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> substr_;</div><div class="line"><a name="l00182"></a><span class="lineno"> 182</span> </div><div class="line"><a name="l00183"></a><span class="lineno"> 183</span>  <a class="code" href="gtest_8h.html#aed8c1888c32b588b0681e88b95031e29">GTEST_DISALLOW_COPY_AND_ASSIGN_</a>(SingleFailureChecker);</div><div class="line"><a name="l00184"></a><span class="lineno"> 184</span> };</div><div class="line"><a name="l00185"></a><span class="lineno"> 185</span> </div><div class="line"><a name="l00186"></a><span class="lineno"> 186</span> } <span class="comment">// namespace internal</span></div><div class="line"><a name="l00187"></a><span class="lineno"> 187</span> </div><div class="line"><a name="l00188"></a><span class="lineno"> 188</span> } <span class="comment">// namespace testing</span></div><div class="line"><a name="l00189"></a><span class="lineno"> 189</span> </div><div class="line"><a name="l00190"></a><span class="lineno"><a class="line" href="gtest-all_8cc.html#a789f37f9c345c2032699c194a58623d9"> 190</a></span> <a class="code" href="gtest-all_8cc.html#a789f37f9c345c2032699c194a58623d9">GTEST_DISABLE_MSC_WARNINGS_POP_</a>() <span class="comment">// 4251</span></div><div class="line"><a name="l00191"></a><span class="lineno"> 191</span> </div><div class="line"><a name="l00192"></a><span class="lineno"> 192</span> <span class="comment">// A set of macros for testing Google Test assertions or code that's expected</span></div><div class="line"><a name="l00193"></a><span class="lineno"> 193</span> <span class="comment">// to generate Google Test fatal failures. It verifies that the given</span></div><div class="line"><a name="l00194"></a><span class="lineno"> 194</span> <span class="comment">// statement will cause exactly one fatal Google Test failure with 'substr'</span></div><div class="line"><a name="l00195"></a><span class="lineno"> 195</span> <span class="comment">// being part of the failure message.</span></div><div class="line"><a name="l00196"></a><span class="lineno"> 196</span> <span class="comment">//</span></div><div class="line"><a name="l00197"></a><span class="lineno"> 197</span> <span class="comment">// There are two different versions of this macro. EXPECT_FATAL_FAILURE only</span></div><div class="line"><a name="l00198"></a><span class="lineno"> 198</span> <span class="comment">// affects and considers failures generated in the current thread and</span></div><div class="line"><a name="l00199"></a><span class="lineno"> 199</span> <span class="comment">// EXPECT_FATAL_FAILURE_ON_ALL_THREADS does the same but for all threads.</span></div><div class="line"><a name="l00200"></a><span class="lineno"> 200</span> <span class="comment">//</span></div><div class="line"><a name="l00201"></a><span class="lineno"> 201</span> <span class="comment">// The verification of the assertion is done correctly even when the statement</span></div><div class="line"><a name="l00202"></a><span class="lineno"> 202</span> <span class="comment">// throws an exception or aborts the current function.</span></div><div class="line"><a name="l00203"></a><span class="lineno"> 203</span> <span class="comment">//</span></div><div class="line"><a name="l00204"></a><span class="lineno"> 204</span> <span class="comment">// Known restrictions:</span></div><div class="line"><a name="l00205"></a><span class="lineno"> 205</span> <span class="comment">// - 'statement' cannot reference local non-static variables or</span></div><div class="line"><a name="l00206"></a><span class="lineno"> 206</span> <span class="comment">// non-static members of the current object.</span></div><div class="line"><a name="l00207"></a><span class="lineno"> 207</span> <span class="comment">// - 'statement' cannot return a value.</span></div><div class="line"><a name="l00208"></a><span class="lineno"> 208</span> <span class="comment">// - You cannot stream a failure message to this macro.</span></div><div class="line"><a name="l00209"></a><span class="lineno"> 209</span> <span class="comment">//</span></div><div class="line"><a name="l00210"></a><span class="lineno"> 210</span> <span class="comment">// Note that even though the implementations of the following two</span></div><div class="line"><a name="l00211"></a><span class="lineno"> 211</span> <span class="comment">// macros are much alike, we cannot refactor them to use a common</span></div><div class="line"><a name="l00212"></a><span class="lineno"> 212</span> <span class="comment">// helper macro, due to some peculiarity in how the preprocessor</span></div><div class="line"><a name="l00213"></a><span class="lineno"> 213</span> <span class="comment">// works. The AcceptsMacroThatExpandsToUnprotectedComma test in</span></div><div class="line"><a name="l00214"></a><span class="lineno"> 214</span> <span class="comment">// gtest_unittest.cc will fail to compile if we do that.</span></div><div class="line"><a name="l00215"></a><span class="lineno"> 215</span> <span class="preprocessor">#define EXPECT_FATAL_FAILURE(statement, substr) \</span></div><div class="line"><a name="l00216"></a><span class="lineno"> 216</span> <span class="preprocessor"> do { \</span></div><div class="line"><a name="l00217"></a><span class="lineno"> 217</span> <span class="preprocessor"> class GTestExpectFatalFailureHelper {\</span></div><div class="line"><a name="l00218"></a><span class="lineno"> 218</span> <span class="preprocessor"> public:\</span></div><div class="line"><a name="l00219"></a><span class="lineno"> 219</span> <span class="preprocessor"> static void Execute() { statement; }\</span></div><div class="line"><a name="l00220"></a><span class="lineno"> 220</span> <span class="preprocessor"> };\</span></div><div class="line"><a name="l00221"></a><span class="lineno"> 221</span> <span class="preprocessor"> ::testing::TestPartResultArray gtest_failures;\</span></div><div class="line"><a name="l00222"></a><span class="lineno"> 222</span> <span class="preprocessor"> ::testing::internal::SingleFailureChecker gtest_checker(\</span></div><div class="line"><a name="l00223"></a><span class="lineno"> 223</span> <span class="preprocessor"> &gtest_failures, ::testing::TestPartResult::kFatalFailure, (substr));\</span></div><div class="line"><a name="l00224"></a><span class="lineno"> 224</span> <span class="preprocessor"> {\</span></div><div class="line"><a name="l00225"></a><span class="lineno"> 225</span> <span class="preprocessor"> ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\</span></div><div class="line"><a name="l00226"></a><span class="lineno"> 226</span> <span class="preprocessor"> ::testing::ScopedFakeTestPartResultReporter:: \</span></div><div class="line"><a name="l00227"></a><span class="lineno"> 227</span> <span class="preprocessor"> INTERCEPT_ONLY_CURRENT_THREAD, &gtest_failures);\</span></div><div class="line"><a name="l00228"></a><span class="lineno"> 228</span> <span class="preprocessor"> GTestExpectFatalFailureHelper::Execute();\</span></div><div class="line"><a name="l00229"></a><span class="lineno"> 229</span> <span class="preprocessor"> }\</span></div><div class="line"><a name="l00230"></a><span class="lineno"> 230</span> <span class="preprocessor"> } while (::testing::internal::AlwaysFalse())</span></div><div class="line"><a name="l00231"></a><span class="lineno"> 231</span> </div><div class="line"><a name="l00232"></a><span class="lineno"> 232</span> <span class="preprocessor">#define EXPECT_FATAL_FAILURE_ON_ALL_THREADS(statement, substr) \</span></div><div class="line"><a name="l00233"></a><span class="lineno"> 233</span> <span class="preprocessor"> do { \</span></div><div class="line"><a name="l00234"></a><span class="lineno"> 234</span> <span class="preprocessor"> class GTestExpectFatalFailureHelper {\</span></div><div class="line"><a name="l00235"></a><span class="lineno"> 235</span> <span class="preprocessor"> public:\</span></div><div class="line"><a name="l00236"></a><span class="lineno"> 236</span> <span class="preprocessor"> static void Execute() { statement; }\</span></div><div class="line"><a name="l00237"></a><span class="lineno"> 237</span> <span class="preprocessor"> };\</span></div><div class="line"><a name="l00238"></a><span class="lineno"> 238</span> <span class="preprocessor"> ::testing::TestPartResultArray gtest_failures;\</span></div><div class="line"><a name="l00239"></a><span class="lineno"> 239</span> <span class="preprocessor"> ::testing::internal::SingleFailureChecker gtest_checker(\</span></div><div class="line"><a name="l00240"></a><span class="lineno"> 240</span> <span class="preprocessor"> &gtest_failures, ::testing::TestPartResult::kFatalFailure, (substr));\</span></div><div class="line"><a name="l00241"></a><span class="lineno"> 241</span> <span class="preprocessor"> {\</span></div><div class="line"><a name="l00242"></a><span class="lineno"> 242</span> <span class="preprocessor"> ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\</span></div><div class="line"><a name="l00243"></a><span class="lineno"> 243</span> <span class="preprocessor"> ::testing::ScopedFakeTestPartResultReporter:: \</span></div><div class="line"><a name="l00244"></a><span class="lineno"> 244</span> <span class="preprocessor"> INTERCEPT_ALL_THREADS, &gtest_failures);\</span></div><div class="line"><a name="l00245"></a><span class="lineno"> 245</span> <span class="preprocessor"> GTestExpectFatalFailureHelper::Execute();\</span></div><div class="line"><a name="l00246"></a><span class="lineno"> 246</span> <span class="preprocessor"> }\</span></div><div class="line"><a name="l00247"></a><span class="lineno"> 247</span> <span class="preprocessor"> } while (::testing::internal::AlwaysFalse())</span></div><div class="line"><a name="l00248"></a><span class="lineno"> 248</span> </div><div class="line"><a name="l00249"></a><span class="lineno"> 249</span> <span class="comment">// A macro for testing Google Test assertions or code that's expected to</span></div><div class="line"><a name="l00250"></a><span class="lineno"> 250</span> <span class="comment">// generate Google Test non-fatal failures. It asserts that the given</span></div><div class="line"><a name="l00251"></a><span class="lineno"> 251</span> <span class="comment">// statement will cause exactly one non-fatal Google Test failure with 'substr'</span></div><div class="line"><a name="l00252"></a><span class="lineno"> 252</span> <span class="comment">// being part of the failure message.</span></div><div class="line"><a name="l00253"></a><span class="lineno"> 253</span> <span class="comment">//</span></div><div class="line"><a name="l00254"></a><span class="lineno"> 254</span> <span class="comment">// There are two different versions of this macro. EXPECT_NONFATAL_FAILURE only</span></div><div class="line"><a name="l00255"></a><span class="lineno"> 255</span> <span class="comment">// affects and considers failures generated in the current thread and</span></div><div class="line"><a name="l00256"></a><span class="lineno"> 256</span> <span class="comment">// EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS does the same but for all threads.</span></div><div class="line"><a name="l00257"></a><span class="lineno"> 257</span> <span class="comment">//</span></div><div class="line"><a name="l00258"></a><span class="lineno"> 258</span> <span class="comment">// 'statement' is allowed to reference local variables and members of</span></div><div class="line"><a name="l00259"></a><span class="lineno"> 259</span> <span class="comment">// the current object.</span></div><div class="line"><a name="l00260"></a><span class="lineno"> 260</span> <span class="comment">//</span></div><div class="line"><a name="l00261"></a><span class="lineno"> 261</span> <span class="comment">// The verification of the assertion is done correctly even when the statement</span></div><div class="line"><a name="l00262"></a><span class="lineno"> 262</span> <span class="comment">// throws an exception or aborts the current function.</span></div><div class="line"><a name="l00263"></a><span class="lineno"> 263</span> <span class="comment">//</span></div><div class="line"><a name="l00264"></a><span class="lineno"> 264</span> <span class="comment">// Known restrictions:</span></div><div class="line"><a name="l00265"></a><span class="lineno"> 265</span> <span class="comment">// - You cannot stream a failure message to this macro.</span></div><div class="line"><a name="l00266"></a><span class="lineno"> 266</span> <span class="comment">//</span></div><div class="line"><a name="l00267"></a><span class="lineno"> 267</span> <span class="comment">// Note that even though the implementations of the following two</span></div><div class="line"><a name="l00268"></a><span class="lineno"> 268</span> <span class="comment">// macros are much alike, we cannot refactor them to use a common</span></div><div class="line"><a name="l00269"></a><span class="lineno"> 269</span> <span class="comment">// helper macro, due to some peculiarity in how the preprocessor</span></div><div class="line"><a name="l00270"></a><span class="lineno"> 270</span> <span class="comment">// works. If we do that, the code won't compile when the user gives</span></div><div class="line"><a name="l00271"></a><span class="lineno"> 271</span> <span class="comment">// EXPECT_NONFATAL_FAILURE() a statement that contains a macro that</span></div><div class="line"><a name="l00272"></a><span class="lineno"> 272</span> <span class="comment">// expands to code containing an unprotected comma. The</span></div><div class="line"><a name="l00273"></a><span class="lineno"> 273</span> <span class="comment">// AcceptsMacroThatExpandsToUnprotectedComma test in gtest_unittest.cc</span></div><div class="line"><a name="l00274"></a><span class="lineno"> 274</span> <span class="comment">// catches that.</span></div><div class="line"><a name="l00275"></a><span class="lineno"> 275</span> <span class="comment">//</span></div><div class="line"><a name="l00276"></a><span class="lineno"> 276</span> <span class="comment">// For the same reason, we have to write</span></div><div class="line"><a name="l00277"></a><span class="lineno"> 277</span> <span class="comment">// if (::testing::internal::AlwaysTrue()) { statement; }</span></div><div class="line"><a name="l00278"></a><span class="lineno"> 278</span> <span class="comment">// instead of</span></div><div class="line"><a name="l00279"></a><span class="lineno"> 279</span> <span class="comment">// GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)</span></div><div class="line"><a name="l00280"></a><span class="lineno"> 280</span> <span class="comment">// to avoid an MSVC warning on unreachable code.</span></div><div class="line"><a name="l00281"></a><span class="lineno"> 281</span> <span class="preprocessor">#define EXPECT_NONFATAL_FAILURE(statement, substr) \</span></div><div class="line"><a name="l00282"></a><span class="lineno"> 282</span> <span class="preprocessor"> do {\</span></div><div class="line"><a name="l00283"></a><span class="lineno"> 283</span> <span class="preprocessor"> ::testing::TestPartResultArray gtest_failures;\</span></div><div class="line"><a name="l00284"></a><span class="lineno"> 284</span> <span class="preprocessor"> ::testing::internal::SingleFailureChecker gtest_checker(\</span></div><div class="line"><a name="l00285"></a><span class="lineno"> 285</span> <span class="preprocessor"> &gtest_failures, ::testing::TestPartResult::kNonFatalFailure, \</span></div><div class="line"><a name="l00286"></a><span class="lineno"> 286</span> <span class="preprocessor"> (substr));\</span></div><div class="line"><a name="l00287"></a><span class="lineno"> 287</span> <span class="preprocessor"> {\</span></div><div class="line"><a name="l00288"></a><span class="lineno"> 288</span> <span class="preprocessor"> ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\</span></div><div class="line"><a name="l00289"></a><span class="lineno"> 289</span> <span class="preprocessor"> ::testing::ScopedFakeTestPartResultReporter:: \</span></div><div class="line"><a name="l00290"></a><span class="lineno"> 290</span> <span class="preprocessor"> INTERCEPT_ONLY_CURRENT_THREAD, &gtest_failures);\</span></div><div class="line"><a name="l00291"></a><span class="lineno"> 291</span> <span class="preprocessor"> if (::testing::internal::AlwaysTrue()) { statement; }\</span></div><div class="line"><a name="l00292"></a><span class="lineno"> 292</span> <span class="preprocessor"> }\</span></div><div class="line"><a name="l00293"></a><span class="lineno"> 293</span> <span class="preprocessor"> } while (::testing::internal::AlwaysFalse())</span></div><div class="line"><a name="l00294"></a><span class="lineno"> 294</span> </div><div class="line"><a name="l00295"></a><span class="lineno"> 295</span> <span class="preprocessor">#define EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(statement, substr) \</span></div><div class="line"><a name="l00296"></a><span class="lineno"> 296</span> <span class="preprocessor"> do {\</span></div><div class="line"><a name="l00297"></a><span class="lineno"> 297</span> <span class="preprocessor"> ::testing::TestPartResultArray gtest_failures;\</span></div><div class="line"><a name="l00298"></a><span class="lineno"> 298</span> <span class="preprocessor"> ::testing::internal::SingleFailureChecker gtest_checker(\</span></div><div class="line"><a name="l00299"></a><span class="lineno"> 299</span> <span class="preprocessor"> &gtest_failures, ::testing::TestPartResult::kNonFatalFailure, \</span></div><div class="line"><a name="l00300"></a><span class="lineno"> 300</span> <span class="preprocessor"> (substr));\</span></div><div class="line"><a name="l00301"></a><span class="lineno"> 301</span> <span class="preprocessor"> {\</span></div><div class="line"><a name="l00302"></a><span class="lineno"> 302</span> <span class="preprocessor"> ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\</span></div><div class="line"><a name="l00303"></a><span class="lineno"> 303</span> <span class="preprocessor"> ::testing::ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS, \</span></div><div class="line"><a name="l00304"></a><span class="lineno"> 304</span> <span class="preprocessor"> &gtest_failures);\</span></div><div class="line"><a name="l00305"></a><span class="lineno"> 305</span> <span class="preprocessor"> if (::testing::internal::AlwaysTrue()) { statement; }\</span></div><div class="line"><a name="l00306"></a><span class="lineno"> 306</span> <span class="preprocessor"> }\</span></div><div class="line"><a name="l00307"></a><span class="lineno"> 307</span> <span class="preprocessor"> } while (::testing::internal::AlwaysFalse())</span></div><div class="line"><a name="l00308"></a><span class="lineno"> 308</span> </div><div class="line"><a name="l00309"></a><span class="lineno"> 309</span> <span class="preprocessor">#endif // GTEST_INCLUDE_GTEST_GTEST_SPI_H_</span></div><div class="line"><a name="l00310"></a><span class="lineno"> 310</span> </div><div class="line"><a name="l00311"></a><span class="lineno"> 311</span> <span class="preprocessor">#include <ctype.h></span></div><div class="line"><a name="l00312"></a><span class="lineno"> 312</span> <span class="preprocessor">#include <math.h></span></div><div class="line"><a name="l00313"></a><span class="lineno"> 313</span> <span class="preprocessor">#include <stdarg.h></span></div><div class="line"><a name="l00314"></a><span class="lineno"> 314</span> <span class="preprocessor">#include <stdio.h></span></div><div class="line"><a name="l00315"></a><span class="lineno"> 315</span> <span class="preprocessor">#include <stdlib.h></span></div><div class="line"><a name="l00316"></a><span class="lineno"> 316</span> <span class="preprocessor">#include <time.h></span></div><div class="line"><a name="l00317"></a><span class="lineno"> 317</span> <span class="preprocessor">#include <wchar.h></span></div><div class="line"><a name="l00318"></a><span class="lineno"> 318</span> <span class="preprocessor">#include <wctype.h></span></div><div class="line"><a name="l00319"></a><span class="lineno"> 319</span> </div><div class="line"><a name="l00320"></a><span class="lineno"> 320</span> <span class="preprocessor">#include <algorithm></span></div><div class="line"><a name="l00321"></a><span class="lineno"> 321</span> <span class="preprocessor">#include <iomanip></span></div><div class="line"><a name="l00322"></a><span class="lineno"> 322</span> <span class="preprocessor">#include <limits></span></div><div class="line"><a name="l00323"></a><span class="lineno"> 323</span> <span class="preprocessor">#include <list></span></div><div class="line"><a name="l00324"></a><span class="lineno"> 324</span> <span class="preprocessor">#include <map></span></div><div class="line"><a name="l00325"></a><span class="lineno"> 325</span> <span class="preprocessor">#include <ostream></span> <span class="comment">// NOLINT</span></div><div class="line"><a name="l00326"></a><span class="lineno"> 326</span> <span class="preprocessor">#include <sstream></span></div><div class="line"><a name="l00327"></a><span class="lineno"> 327</span> <span class="preprocessor">#include <vector></span></div><div class="line"><a name="l00328"></a><span class="lineno"> 328</span> </div><div class="line"><a name="l00329"></a><span class="lineno"> 329</span> <span class="preprocessor">#if GTEST_OS_LINUX</span></div><div class="line"><a name="l00330"></a><span class="lineno"> 330</span> </div><div class="line"><a name="l00331"></a><span class="lineno"> 331</span> <span class="preprocessor"># define GTEST_HAS_GETTIMEOFDAY_ 1</span></div><div class="line"><a name="l00332"></a><span class="lineno"> 332</span> </div><div class="line"><a name="l00333"></a><span class="lineno"> 333</span> <span class="preprocessor"># include <fcntl.h></span> <span class="comment">// NOLINT</span></div><div class="line"><a name="l00334"></a><span class="lineno"> 334</span> <span class="preprocessor"># include <limits.h></span> <span class="comment">// NOLINT</span></div><div class="line"><a name="l00335"></a><span class="lineno"> 335</span> <span class="preprocessor"># include <sched.h></span> <span class="comment">// NOLINT</span></div><div class="line"><a name="l00336"></a><span class="lineno"> 336</span> <span class="comment">// Declares vsnprintf(). This header is not available on Windows.</span></div><div class="line"><a name="l00337"></a><span class="lineno"> 337</span> <span class="preprocessor"># include <strings.h></span> <span class="comment">// NOLINT</span></div><div class="line"><a name="l00338"></a><span class="lineno"> 338</span> <span class="preprocessor"># include <sys/mman.h></span> <span class="comment">// NOLINT</span></div><div class="line"><a name="l00339"></a><span class="lineno"> 339</span> <span class="preprocessor"># include <sys/time.h></span> <span class="comment">// NOLINT</span></div><div class="line"><a name="l00340"></a><span class="lineno"> 340</span> <span class="preprocessor"># include <unistd.h></span> <span class="comment">// NOLINT</span></div><div class="line"><a name="l00341"></a><span class="lineno"> 341</span> <span class="preprocessor"># include <string></span></div><div class="line"><a name="l00342"></a><span class="lineno"> 342</span> </div><div class="line"><a name="l00343"></a><span class="lineno"> 343</span> <span class="preprocessor">#elif GTEST_OS_ZOS</span></div><div class="line"><a name="l00344"></a><span class="lineno"> 344</span> <span class="preprocessor"># define GTEST_HAS_GETTIMEOFDAY_ 1</span></div><div class="line"><a name="l00345"></a><span class="lineno"> 345</span> <span class="preprocessor"># include <sys/time.h></span> <span class="comment">// NOLINT</span></div><div class="line"><a name="l00346"></a><span class="lineno"> 346</span> </div><div class="line"><a name="l00347"></a><span class="lineno"> 347</span> <span class="comment">// On z/OS we additionally need strings.h for strcasecmp.</span></div><div class="line"><a name="l00348"></a><span class="lineno"> 348</span> <span class="preprocessor"># include <strings.h></span> <span class="comment">// NOLINT</span></div><div class="line"><a name="l00349"></a><span class="lineno"> 349</span> </div><div class="line"><a name="l00350"></a><span class="lineno"> 350</span> <span class="preprocessor">#elif GTEST_OS_WINDOWS_MOBILE // We are on Windows CE.</span></div><div class="line"><a name="l00351"></a><span class="lineno"> 351</span> </div><div class="line"><a name="l00352"></a><span class="lineno"> 352</span> <span class="preprocessor"># include <windows.h></span> <span class="comment">// NOLINT</span></div><div class="line"><a name="l00353"></a><span class="lineno"> 353</span> <span class="preprocessor"># undef min</span></div><div class="line"><a name="l00354"></a><span class="lineno"> 354</span> </div><div class="line"><a name="l00355"></a><span class="lineno"> 355</span> <span class="preprocessor">#elif GTEST_OS_WINDOWS // We are on Windows proper.</span></div><div class="line"><a name="l00356"></a><span class="lineno"> 356</span> </div><div class="line"><a name="l00357"></a><span class="lineno"> 357</span> <span class="preprocessor"># include <io.h></span> <span class="comment">// NOLINT</span></div><div class="line"><a name="l00358"></a><span class="lineno"> 358</span> <span class="preprocessor"># include <sys/timeb.h></span> <span class="comment">// NOLINT</span></div><div class="line"><a name="l00359"></a><span class="lineno"> 359</span> <span class="preprocessor"># include <sys/types.h></span> <span class="comment">// NOLINT</span></div><div class="line"><a name="l00360"></a><span class="lineno"> 360</span> <span class="preprocessor"># include <sys/stat.h></span> <span class="comment">// NOLINT</span></div><div class="line"><a name="l00361"></a><span class="lineno"> 361</span> </div><div class="line"><a name="l00362"></a><span class="lineno"> 362</span> <span class="preprocessor"># if GTEST_OS_WINDOWS_MINGW</span></div><div class="line"><a name="l00363"></a><span class="lineno"> 363</span> <span class="comment">// MinGW has gettimeofday() but not _ftime64().</span></div><div class="line"><a name="l00364"></a><span class="lineno"> 364</span> <span class="preprocessor"># define GTEST_HAS_GETTIMEOFDAY_ 1</span></div><div class="line"><a name="l00365"></a><span class="lineno"> 365</span> <span class="preprocessor"># include <sys/time.h></span> <span class="comment">// NOLINT</span></div><div class="line"><a name="l00366"></a><span class="lineno"> 366</span> <span class="preprocessor"># endif // GTEST_OS_WINDOWS_MINGW</span></div><div class="line"><a name="l00367"></a><span class="lineno"> 367</span> </div><div class="line"><a name="l00368"></a><span class="lineno"> 368</span> <span class="comment">// cpplint thinks that the header is already included, so we want to</span></div><div class="line"><a name="l00369"></a><span class="lineno"> 369</span> <span class="comment">// silence it.</span></div><div class="line"><a name="l00370"></a><span class="lineno"> 370</span> <span class="preprocessor"># include <windows.h></span> <span class="comment">// NOLINT</span></div><div class="line"><a name="l00371"></a><span class="lineno"> 371</span> <span class="preprocessor"># undef min</span></div><div class="line"><a name="l00372"></a><span class="lineno"> 372</span> </div><div class="line"><a name="l00373"></a><span class="lineno"> 373</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l00374"></a><span class="lineno"> 374</span> </div><div class="line"><a name="l00375"></a><span class="lineno"> 375</span> <span class="comment">// Assume other platforms have gettimeofday().</span></div><div class="line"><a name="l00376"></a><span class="lineno"> 376</span> <span class="preprocessor"># define GTEST_HAS_GETTIMEOFDAY_ 1</span></div><div class="line"><a name="l00377"></a><span class="lineno"> 377</span> </div><div class="line"><a name="l00378"></a><span class="lineno"> 378</span> <span class="comment">// cpplint thinks that the header is already included, so we want to</span></div><div class="line"><a name="l00379"></a><span class="lineno"> 379</span> <span class="comment">// silence it.</span></div><div class="line"><a name="l00380"></a><span class="lineno"> 380</span> <span class="preprocessor"># include <sys/time.h></span> <span class="comment">// NOLINT</span></div><div class="line"><a name="l00381"></a><span class="lineno"> 381</span> <span class="preprocessor"># include <unistd.h></span> <span class="comment">// NOLINT</span></div><div class="line"><a name="l00382"></a><span class="lineno"> 382</span> </div><div class="line"><a name="l00383"></a><span class="lineno"> 383</span> <span class="preprocessor">#endif // GTEST_OS_LINUX</span></div><div class="line"><a name="l00384"></a><span class="lineno"> 384</span> </div><div class="line"><a name="l00385"></a><span class="lineno"> 385</span> <span class="preprocessor">#if GTEST_HAS_EXCEPTIONS</span></div><div class="line"><a name="l00386"></a><span class="lineno"> 386</span> <span class="preprocessor"># include <stdexcept></span></div><div class="line"><a name="l00387"></a><span class="lineno"> 387</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l00388"></a><span class="lineno"> 388</span> </div><div class="line"><a name="l00389"></a><span class="lineno"> 389</span> <span class="preprocessor">#if GTEST_CAN_STREAM_RESULTS_</span></div><div class="line"><a name="l00390"></a><span class="lineno"> 390</span> <span class="preprocessor"># include <arpa/inet.h></span> <span class="comment">// NOLINT</span></div><div class="line"><a name="l00391"></a><span class="lineno"> 391</span> <span class="preprocessor"># include <netdb.h></span> <span class="comment">// NOLINT</span></div><div class="line"><a name="l00392"></a><span class="lineno"> 392</span> <span class="preprocessor"># include <sys/socket.h></span> <span class="comment">// NOLINT</span></div><div class="line"><a name="l00393"></a><span class="lineno"> 393</span> <span class="preprocessor"># include <sys/types.h></span> <span class="comment">// NOLINT</span></div><div class="line"><a name="l00394"></a><span class="lineno"> 394</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l00395"></a><span class="lineno"> 395</span> </div><div class="line"><a name="l00396"></a><span class="lineno"> 396</span> <span class="comment">// Copyright 2005, Google Inc.</span></div><div class="line"><a name="l00397"></a><span class="lineno"> 397</span> <span class="comment">// All rights reserved.</span></div><div class="line"><a name="l00398"></a><span class="lineno"> 398</span> <span class="comment">//</span></div><div class="line"><a name="l00399"></a><span class="lineno"> 399</span> <span class="comment">// Redistribution and use in source and binary forms, with or without</span></div><div class="line"><a name="l00400"></a><span class="lineno"> 400</span> <span class="comment">// modification, are permitted provided that the following conditions are</span></div><div class="line"><a name="l00401"></a><span class="lineno"> 401</span> <span class="comment">// met:</span></div><div class="line"><a name="l00402"></a><span class="lineno"> 402</span> <span class="comment">//</span></div><div class="line"><a name="l00403"></a><span class="lineno"> 403</span> <span class="comment">// * Redistributions of source code must retain the above copyright</span></div><div class="line"><a name="l00404"></a><span class="lineno"> 404</span> <span class="comment">// notice, this list of conditions and the following disclaimer.</span></div><div class="line"><a name="l00405"></a><span class="lineno"> 405</span> <span class="comment">// * Redistributions in binary form must reproduce the above</span></div><div class="line"><a name="l00406"></a><span class="lineno"> 406</span> <span class="comment">// copyright notice, this list of conditions and the following disclaimer</span></div><div class="line"><a name="l00407"></a><span class="lineno"> 407</span> <span class="comment">// in the documentation and/or other materials provided with the</span></div><div class="line"><a name="l00408"></a><span class="lineno"> 408</span> <span class="comment">// distribution.</span></div><div class="line"><a name="l00409"></a><span class="lineno"> 409</span> <span class="comment">// * Neither the name of Google Inc. nor the names of its</span></div><div class="line"><a name="l00410"></a><span class="lineno"> 410</span> <span class="comment">// contributors may be used to endorse or promote products derived from</span></div><div class="line"><a name="l00411"></a><span class="lineno"> 411</span> <span class="comment">// this software without specific prior written permission.</span></div><div class="line"><a name="l00412"></a><span class="lineno"> 412</span> <span class="comment">//</span></div><div class="line"><a name="l00413"></a><span class="lineno"> 413</span> <span class="comment">// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span></div><div class="line"><a name="l00414"></a><span class="lineno"> 414</span> <span class="comment">// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</span></div><div class="line"><a name="l00415"></a><span class="lineno"> 415</span> <span class="comment">// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR</span></div><div class="line"><a name="l00416"></a><span class="lineno"> 416</span> <span class="comment">// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT</span></div><div class="line"><a name="l00417"></a><span class="lineno"> 417</span> <span class="comment">// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span></div><div class="line"><a name="l00418"></a><span class="lineno"> 418</span> <span class="comment">// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</span></div><div class="line"><a name="l00419"></a><span class="lineno"> 419</span> <span class="comment">// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</span></div><div class="line"><a name="l00420"></a><span class="lineno"> 420</span> <span class="comment">// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY</span></div><div class="line"><a name="l00421"></a><span class="lineno"> 421</span> <span class="comment">// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span></div><div class="line"><a name="l00422"></a><span class="lineno"> 422</span> <span class="comment">// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE</span></div><div class="line"><a name="l00423"></a><span class="lineno"> 423</span> <span class="comment">// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span></div><div class="line"><a name="l00424"></a><span class="lineno"> 424</span> </div><div class="line"><a name="l00425"></a><span class="lineno"> 425</span> <span class="comment">// Utility functions and classes used by the Google C++ testing framework.//</span></div><div class="line"><a name="l00426"></a><span class="lineno"> 426</span> <span class="comment">// This file contains purely Google Test's internal implementation. Please</span></div><div class="line"><a name="l00427"></a><span class="lineno"> 427</span> <span class="comment">// DO NOT #INCLUDE IT IN A USER PROGRAM.</span></div><div class="line"><a name="l00428"></a><span class="lineno"> 428</span> </div><div class="line"><a name="l00429"></a><span class="lineno"> 429</span> <span class="preprocessor">#ifndef GTEST_SRC_GTEST_INTERNAL_INL_H_</span></div><div class="line"><a name="l00430"></a><span class="lineno"> 430</span> <span class="preprocessor">#define GTEST_SRC_GTEST_INTERNAL_INL_H_</span></div><div class="line"><a name="l00431"></a><span class="lineno"> 431</span> </div><div class="line"><a name="l00432"></a><span class="lineno"> 432</span> <span class="preprocessor">#ifndef _WIN32_WCE</span></div><div class="line"><a name="l00433"></a><span class="lineno"> 433</span> <span class="preprocessor"># include <errno.h></span></div><div class="line"><a name="l00434"></a><span class="lineno"> 434</span> <span class="preprocessor">#endif // !_WIN32_WCE</span></div><div class="line"><a name="l00435"></a><span class="lineno"> 435</span> <span class="preprocessor">#include <stddef.h></span></div><div class="line"><a name="l00436"></a><span class="lineno"> 436</span> <span class="preprocessor">#include <stdlib.h></span> <span class="comment">// For strtoll/_strtoul64/malloc/free.</span></div><div class="line"><a name="l00437"></a><span class="lineno"> 437</span> <span class="preprocessor">#include <string.h></span> <span class="comment">// For memmove.</span></div><div class="line"><a name="l00438"></a><span class="lineno"> 438</span> </div><div class="line"><a name="l00439"></a><span class="lineno"> 439</span> <span class="preprocessor">#include <algorithm></span></div><div class="line"><a name="l00440"></a><span class="lineno"> 440</span> <span class="preprocessor">#include <memory></span></div><div class="line"><a name="l00441"></a><span class="lineno"> 441</span> <span class="preprocessor">#include <string></span></div><div class="line"><a name="l00442"></a><span class="lineno"> 442</span> <span class="preprocessor">#include <vector></span></div><div class="line"><a name="l00443"></a><span class="lineno"> 443</span> </div><div class="line"><a name="l00444"></a><span class="lineno"> 444</span> </div><div class="line"><a name="l00445"></a><span class="lineno"> 445</span> <span class="preprocessor">#if GTEST_CAN_STREAM_RESULTS_</span></div><div class="line"><a name="l00446"></a><span class="lineno"> 446</span> <span class="preprocessor"># include <arpa/inet.h></span> <span class="comment">// NOLINT</span></div><div class="line"><a name="l00447"></a><span class="lineno"> 447</span> <span class="preprocessor"># include <netdb.h></span> <span class="comment">// NOLINT</span></div><div class="line"><a name="l00448"></a><span class="lineno"> 448</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l00449"></a><span class="lineno"> 449</span> </div><div class="line"><a name="l00450"></a><span class="lineno"> 450</span> <span class="preprocessor">#if GTEST_OS_WINDOWS</span></div><div class="line"><a name="l00451"></a><span class="lineno"> 451</span> <span class="preprocessor"># include <windows.h></span> <span class="comment">// NOLINT</span></div><div class="line"><a name="l00452"></a><span class="lineno"> 452</span> <span class="preprocessor">#endif // GTEST_OS_WINDOWS</span></div><div class="line"><a name="l00453"></a><span class="lineno"> 453</span> </div><div class="line"><a name="l00454"></a><span class="lineno"> 454</span> </div><div class="line"><a name="l00455"></a><span class="lineno"> 455</span> <a class="code" href="gtest-all_8cc.html#a88f79832f9d045112a76e9da8611cc13">GTEST_DISABLE_MSC_WARNINGS_PUSH_</a>(4251 \</div><div class="line"><a name="l00456"></a><span class="lineno"> 456</span> <span class="comment">/* class A needs to have dll-interface to be used by clients of class B */</span>)</div><div class="line"><a name="l00457"></a><span class="lineno"> 457</span> </div><div class="line"><a name="l00458"></a><span class="lineno"> 458</span> namespace <a class="code" href="namespacetesting.html">testing</a> {</div><div class="line"><a name="l00459"></a><span class="lineno"> 459</span> </div><div class="line"><a name="l00460"></a><span class="lineno"> 460</span> <span class="comment">// Declares the flags.</span></div><div class="line"><a name="l00461"></a><span class="lineno"> 461</span> <span class="comment">//</span></div><div class="line"><a name="l00462"></a><span class="lineno"> 462</span> <span class="comment">// We don't want the users to modify this flag in the code, but want</span></div><div class="line"><a name="l00463"></a><span class="lineno"> 463</span> <span class="comment">// Google Test's own unit tests to be able to access it. Therefore we</span></div><div class="line"><a name="l00464"></a><span class="lineno"> 464</span> <span class="comment">// declare it here as opposed to in gtest.h.</span></div><div class="line"><a name="l00465"></a><span class="lineno"> 465</span> <a class="code" href="gtest_8h.html#a14eb0e9c6e0df765d1fbfd2db6966d14">GTEST_DECLARE_bool_</a>(death_test_use_fork);</div><div class="line"><a name="l00466"></a><span class="lineno"> 466</span> </div><div class="line"><a name="l00467"></a><span class="lineno"> 467</span> <span class="keyword">namespace </span>internal {</div><div class="line"><a name="l00468"></a><span class="lineno"> 468</span> </div><div class="line"><a name="l00469"></a><span class="lineno"> 469</span> <span class="comment">// The value of GetTestTypeId() as seen from within the Google Test</span></div><div class="line"><a name="l00470"></a><span class="lineno"> 470</span> <span class="comment">// library. This is solely for testing GetTestTypeId().</span></div><div class="line"><a name="l00471"></a><span class="lineno"> 471</span> <a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> <span class="keyword">extern</span> <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#ab1114197d3c657d8b7f8e0c5caa12d00">TypeId</a> kTestTypeIdInGoogleTest;</div><div class="line"><a name="l00472"></a><span class="lineno"> 472</span> </div><div class="line"><a name="l00473"></a><span class="lineno"> 473</span> <span class="comment">// Names of the flags (needed for parsing Google Test flags).</span></div><div class="line"><a name="l00474"></a><span class="lineno"> 474</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kAlsoRunDisabledTestsFlag[] = <span class="stringliteral">"also_run_disabled_tests"</span>;</div><div class="line"><a name="l00475"></a><span class="lineno"> 475</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kBreakOnFailureFlag[] = <span class="stringliteral">"break_on_failure"</span>;</div><div class="line"><a name="l00476"></a><span class="lineno"> 476</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kCatchExceptionsFlag[] = <span class="stringliteral">"catch_exceptions"</span>;</div><div class="line"><a name="l00477"></a><span class="lineno"> 477</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kColorFlag[] = <span class="stringliteral">"color"</span>;</div><div class="line"><a name="l00478"></a><span class="lineno"> 478</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kFilterFlag[] = <span class="stringliteral">"filter"</span>;</div><div class="line"><a name="l00479"></a><span class="lineno"> 479</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kListTestsFlag[] = <span class="stringliteral">"list_tests"</span>;</div><div class="line"><a name="l00480"></a><span class="lineno"> 480</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kOutputFlag[] = <span class="stringliteral">"output"</span>;</div><div class="line"><a name="l00481"></a><span class="lineno"> 481</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kPrintTimeFlag[] = <span class="stringliteral">"print_time"</span>;</div><div class="line"><a name="l00482"></a><span class="lineno"> 482</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kPrintUTF8Flag[] = <span class="stringliteral">"print_utf8"</span>;</div><div class="line"><a name="l00483"></a><span class="lineno"> 483</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kRandomSeedFlag[] = <span class="stringliteral">"random_seed"</span>;</div><div class="line"><a name="l00484"></a><span class="lineno"> 484</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kRepeatFlag[] = <span class="stringliteral">"repeat"</span>;</div><div class="line"><a name="l00485"></a><span class="lineno"> 485</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kShuffleFlag[] = <span class="stringliteral">"shuffle"</span>;</div><div class="line"><a name="l00486"></a><span class="lineno"> 486</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kStackTraceDepthFlag[] = <span class="stringliteral">"stack_trace_depth"</span>;</div><div class="line"><a name="l00487"></a><span class="lineno"> 487</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kStreamResultToFlag[] = <span class="stringliteral">"stream_result_to"</span>;</div><div class="line"><a name="l00488"></a><span class="lineno"> 488</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kThrowOnFailureFlag[] = <span class="stringliteral">"throw_on_failure"</span>;</div><div class="line"><a name="l00489"></a><span class="lineno"> 489</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kFlagfileFlag[] = <span class="stringliteral">"flagfile"</span>;</div><div class="line"><a name="l00490"></a><span class="lineno"> 490</span> </div><div class="line"><a name="l00491"></a><span class="lineno"> 491</span> <span class="comment">// A valid random seed must be in [1, kMaxRandomSeed].</span></div><div class="line"><a name="l00492"></a><span class="lineno"> 492</span> <span class="keyword">const</span> <span class="keywordtype">int</span> kMaxRandomSeed = 99999;</div><div class="line"><a name="l00493"></a><span class="lineno"> 493</span> </div><div class="line"><a name="l00494"></a><span class="lineno"> 494</span> <span class="comment">// g_help_flag is true iff the --help flag or an equivalent form is</span></div><div class="line"><a name="l00495"></a><span class="lineno"> 495</span> <span class="comment">// specified on the command line.</span></div><div class="line"><a name="l00496"></a><span class="lineno"> 496</span> <a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> <span class="keyword">extern</span> <span class="keywordtype">bool</span> g_help_flag;</div><div class="line"><a name="l00497"></a><span class="lineno"> 497</span> </div><div class="line"><a name="l00498"></a><span class="lineno"> 498</span> <span class="comment">// Returns the current time in milliseconds.</span></div><div class="line"><a name="l00499"></a><span class="lineno"> 499</span> <a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> <a class="code" href="namespacetesting_1_1internal.html#a66a845df404b38fe85c5e14a069f255a">TimeInMillis</a> GetTimeInMillis();</div><div class="line"><a name="l00500"></a><span class="lineno"> 500</span> </div><div class="line"><a name="l00501"></a><span class="lineno"> 501</span> <span class="comment">// Returns true iff Google Test should use colors in the output.</span></div><div class="line"><a name="l00502"></a><span class="lineno"> 502</span> <a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> <span class="keywordtype">bool</span> ShouldUseColor(<span class="keywordtype">bool</span> stdout_is_tty);</div><div class="line"><a name="l00503"></a><span class="lineno"> 503</span> </div><div class="line"><a name="l00504"></a><span class="lineno"> 504</span> <span class="comment">// Formats the given time in milliseconds as seconds.</span></div><div class="line"><a name="l00505"></a><span class="lineno"> 505</span> <a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> FormatTimeInMillisAsSeconds(<a class="code" href="namespacetesting_1_1internal.html#a66a845df404b38fe85c5e14a069f255a">TimeInMillis</a> ms);</div><div class="line"><a name="l00506"></a><span class="lineno"> 506</span> </div><div class="line"><a name="l00507"></a><span class="lineno"> 507</span> <span class="comment">// Converts the given time in milliseconds to a date string in the ISO 8601</span></div><div class="line"><a name="l00508"></a><span class="lineno"> 508</span> <span class="comment">// format, without the timezone information. N.B.: due to the use the</span></div><div class="line"><a name="l00509"></a><span class="lineno"> 509</span> <span class="comment">// non-reentrant localtime() function, this function is not thread safe. Do</span></div><div class="line"><a name="l00510"></a><span class="lineno"> 510</span> <span class="comment">// not use it in any code that can be called from multiple threads.</span></div><div class="line"><a name="l00511"></a><span class="lineno"> 511</span> <a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> FormatEpochTimeInMillisAsIso8601(<a class="code" href="namespacetesting_1_1internal.html#a66a845df404b38fe85c5e14a069f255a">TimeInMillis</a> ms);</div><div class="line"><a name="l00512"></a><span class="lineno"> 512</span> </div><div class="line"><a name="l00513"></a><span class="lineno"> 513</span> <span class="comment">// Parses a string for an Int32 flag, in the form of "--flag=value".</span></div><div class="line"><a name="l00514"></a><span class="lineno"> 514</span> <span class="comment">//</span></div><div class="line"><a name="l00515"></a><span class="lineno"> 515</span> <span class="comment">// On success, stores the value of the flag in *value, and returns</span></div><div class="line"><a name="l00516"></a><span class="lineno"> 516</span> <span class="comment">// true. On failure, returns false without changing *value.</span></div><div class="line"><a name="l00517"></a><span class="lineno"> 517</span> <a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> <span class="keywordtype">bool</span> ParseInt32Flag(</div><div class="line"><a name="l00518"></a><span class="lineno"> 518</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* str, <span class="keyword">const</span> <span class="keywordtype">char</span>* flag, <a class="code" href="namespacetesting_1_1internal.html#a8ee38faaf875f133358abaf9bc056cec">Int32</a>* value);</div><div class="line"><a name="l00519"></a><span class="lineno"> 519</span> </div><div class="line"><a name="l00520"></a><span class="lineno"> 520</span> <span class="comment">// Returns a random seed in range [1, kMaxRandomSeed] based on the</span></div><div class="line"><a name="l00521"></a><span class="lineno"> 521</span> <span class="comment">// given --gtest_random_seed flag value.</span></div><div class="line"><a name="l00522"></a><span class="lineno"> 522</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> GetRandomSeedFromFlag(<a class="code" href="namespacetesting_1_1internal.html#a8ee38faaf875f133358abaf9bc056cec">Int32</a> random_seed_flag) {</div><div class="line"><a name="l00523"></a><span class="lineno"> 523</span>  <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> raw_seed = (random_seed_flag == 0) ?</div><div class="line"><a name="l00524"></a><span class="lineno"> 524</span>  static_cast<unsigned int>(GetTimeInMillis()) :</div><div class="line"><a name="l00525"></a><span class="lineno"> 525</span>  static_cast<unsigned int>(random_seed_flag);</div><div class="line"><a name="l00526"></a><span class="lineno"> 526</span> </div><div class="line"><a name="l00527"></a><span class="lineno"> 527</span>  <span class="comment">// Normalizes the actual seed to range [1, kMaxRandomSeed] such that</span></div><div class="line"><a name="l00528"></a><span class="lineno"> 528</span>  <span class="comment">// it's easy to type.</span></div><div class="line"><a name="l00529"></a><span class="lineno"> 529</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> normalized_seed =</div><div class="line"><a name="l00530"></a><span class="lineno"> 530</span>  <span class="keyword">static_cast<</span><span class="keywordtype">int</span><span class="keyword">></span>((raw_seed - 1U) %</div><div class="line"><a name="l00531"></a><span class="lineno"> 531</span>  static_cast<unsigned int>(kMaxRandomSeed)) + 1;</div><div class="line"><a name="l00532"></a><span class="lineno"> 532</span>  <span class="keywordflow">return</span> normalized_seed;</div><div class="line"><a name="l00533"></a><span class="lineno"> 533</span> }</div><div class="line"><a name="l00534"></a><span class="lineno"> 534</span> </div><div class="line"><a name="l00535"></a><span class="lineno"> 535</span> <span class="comment">// Returns the first valid random seed after 'seed'. The behavior is</span></div><div class="line"><a name="l00536"></a><span class="lineno"> 536</span> <span class="comment">// undefined if 'seed' is invalid. The seed after kMaxRandomSeed is</span></div><div class="line"><a name="l00537"></a><span class="lineno"> 537</span> <span class="comment">// considered to be 1.</span></div><div class="line"><a name="l00538"></a><span class="lineno"> 538</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> GetNextRandomSeed(<span class="keywordtype">int</span> seed) {</div><div class="line"><a name="l00539"></a><span class="lineno"> 539</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(1 <= seed && seed <= kMaxRandomSeed)</div><div class="line"><a name="l00540"></a><span class="lineno"> 540</span>  << <span class="stringliteral">"Invalid random seed "</span> << seed << <span class="stringliteral">" - must be in [1, "</span></div><div class="line"><a name="l00541"></a><span class="lineno"> 541</span>  << kMaxRandomSeed << <span class="stringliteral">"]."</span>;</div><div class="line"><a name="l00542"></a><span class="lineno"> 542</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> next_seed = seed + 1;</div><div class="line"><a name="l00543"></a><span class="lineno"> 543</span>  <span class="keywordflow">return</span> (next_seed > kMaxRandomSeed) ? 1 : next_seed;</div><div class="line"><a name="l00544"></a><span class="lineno"> 544</span> }</div><div class="line"><a name="l00545"></a><span class="lineno"> 545</span> </div><div class="line"><a name="l00546"></a><span class="lineno"> 546</span> <span class="comment">// This class saves the values of all Google Test flags in its c'tor, and</span></div><div class="line"><a name="l00547"></a><span class="lineno"> 547</span> <span class="comment">// restores them in its d'tor.</span></div><div class="line"><a name="l00548"></a><span class="lineno"> 548</span> <span class="keyword">class </span>GTestFlagSaver {</div><div class="line"><a name="l00549"></a><span class="lineno"> 549</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00550"></a><span class="lineno"> 550</span>  <span class="comment">// The c'tor.</span></div><div class="line"><a name="l00551"></a><span class="lineno"> 551</span>  GTestFlagSaver() {</div><div class="line"><a name="l00552"></a><span class="lineno"> 552</span>  also_run_disabled_tests_ = <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(also_run_disabled_tests);</div><div class="line"><a name="l00553"></a><span class="lineno"> 553</span>  break_on_failure_ = <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(break_on_failure);</div><div class="line"><a name="l00554"></a><span class="lineno"> 554</span>  catch_exceptions_ = <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(catch_exceptions);</div><div class="line"><a name="l00555"></a><span class="lineno"> 555</span>  color_ = <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(color);</div><div class="line"><a name="l00556"></a><span class="lineno"> 556</span>  death_test_style_ = <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(death_test_style);</div><div class="line"><a name="l00557"></a><span class="lineno"> 557</span>  death_test_use_fork_ = <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(death_test_use_fork);</div><div class="line"><a name="l00558"></a><span class="lineno"> 558</span>  filter_ = <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(<a class="code" href="namespaceutl_1_1meta.html#ac72acc616316c322e750d20a46553ba4">filter</a>);</div><div class="line"><a name="l00559"></a><span class="lineno"> 559</span>  internal_run_death_test_ = <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(internal_run_death_test);</div><div class="line"><a name="l00560"></a><span class="lineno"> 560</span>  list_tests_ = <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(list_tests);</div><div class="line"><a name="l00561"></a><span class="lineno"> 561</span>  output_ = <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(output);</div><div class="line"><a name="l00562"></a><span class="lineno"> 562</span>  print_time_ = <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(print_time);</div><div class="line"><a name="l00563"></a><span class="lineno"> 563</span>  print_utf8_ = <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(print_utf8);</div><div class="line"><a name="l00564"></a><span class="lineno"> 564</span>  random_seed_ = <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(random_seed);</div><div class="line"><a name="l00565"></a><span class="lineno"> 565</span>  repeat_ = <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(<a class="code" href="namespaceutl_1_1meta.html#aa013c45afb59b5c132a72be54ba145fb">repeat</a>);</div><div class="line"><a name="l00566"></a><span class="lineno"> 566</span>  shuffle_ = <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(shuffle);</div><div class="line"><a name="l00567"></a><span class="lineno"> 567</span>  stack_trace_depth_ = <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(stack_trace_depth);</div><div class="line"><a name="l00568"></a><span class="lineno"> 568</span>  stream_result_to_ = <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(stream_result_to);</div><div class="line"><a name="l00569"></a><span class="lineno"> 569</span>  throw_on_failure_ = <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(throw_on_failure);</div><div class="line"><a name="l00570"></a><span class="lineno"> 570</span>  }</div><div class="line"><a name="l00571"></a><span class="lineno"> 571</span> </div><div class="line"><a name="l00572"></a><span class="lineno"> 572</span>  <span class="comment">// The d'tor is not virtual. DO NOT INHERIT FROM THIS CLASS.</span></div><div class="line"><a name="l00573"></a><span class="lineno"> 573</span>  ~GTestFlagSaver() {</div><div class="line"><a name="l00574"></a><span class="lineno"> 574</span>  <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(also_run_disabled_tests) = also_run_disabled_tests_;</div><div class="line"><a name="l00575"></a><span class="lineno"> 575</span>  <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(break_on_failure) = break_on_failure_;</div><div class="line"><a name="l00576"></a><span class="lineno"> 576</span>  <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(catch_exceptions) = catch_exceptions_;</div><div class="line"><a name="l00577"></a><span class="lineno"> 577</span>  <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(color) = color_;</div><div class="line"><a name="l00578"></a><span class="lineno"> 578</span>  <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(death_test_style) = death_test_style_;</div><div class="line"><a name="l00579"></a><span class="lineno"> 579</span>  <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(death_test_use_fork) = death_test_use_fork_;</div><div class="line"><a name="l00580"></a><span class="lineno"> 580</span>  <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(<a class="code" href="namespaceutl_1_1meta.html#ac72acc616316c322e750d20a46553ba4">filter</a>) = filter_;</div><div class="line"><a name="l00581"></a><span class="lineno"> 581</span>  <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(internal_run_death_test) = internal_run_death_test_;</div><div class="line"><a name="l00582"></a><span class="lineno"> 582</span>  <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(list_tests) = list_tests_;</div><div class="line"><a name="l00583"></a><span class="lineno"> 583</span>  <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(output) = output_;</div><div class="line"><a name="l00584"></a><span class="lineno"> 584</span>  <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(print_time) = print_time_;</div><div class="line"><a name="l00585"></a><span class="lineno"> 585</span>  <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(print_utf8) = print_utf8_;</div><div class="line"><a name="l00586"></a><span class="lineno"> 586</span>  <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(random_seed) = random_seed_;</div><div class="line"><a name="l00587"></a><span class="lineno"> 587</span>  <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(<a class="code" href="namespaceutl_1_1meta.html#aa013c45afb59b5c132a72be54ba145fb">repeat</a>) = repeat_;</div><div class="line"><a name="l00588"></a><span class="lineno"> 588</span>  <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(shuffle) = shuffle_;</div><div class="line"><a name="l00589"></a><span class="lineno"> 589</span>  <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(stack_trace_depth) = stack_trace_depth_;</div><div class="line"><a name="l00590"></a><span class="lineno"> 590</span>  <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(stream_result_to) = stream_result_to_;</div><div class="line"><a name="l00591"></a><span class="lineno"> 591</span>  <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(throw_on_failure) = throw_on_failure_;</div><div class="line"><a name="l00592"></a><span class="lineno"> 592</span>  }</div><div class="line"><a name="l00593"></a><span class="lineno"> 593</span> </div><div class="line"><a name="l00594"></a><span class="lineno"> 594</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l00595"></a><span class="lineno"> 595</span>  <span class="comment">// Fields for saving the original values of flags.</span></div><div class="line"><a name="l00596"></a><span class="lineno"> 596</span>  <span class="keywordtype">bool</span> also_run_disabled_tests_;</div><div class="line"><a name="l00597"></a><span class="lineno"> 597</span>  <span class="keywordtype">bool</span> break_on_failure_;</div><div class="line"><a name="l00598"></a><span class="lineno"> 598</span>  <span class="keywordtype">bool</span> catch_exceptions_;</div><div class="line"><a name="l00599"></a><span class="lineno"> 599</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> color_;</div><div class="line"><a name="l00600"></a><span class="lineno"> 600</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> death_test_style_;</div><div class="line"><a name="l00601"></a><span class="lineno"> 601</span>  <span class="keywordtype">bool</span> death_test_use_fork_;</div><div class="line"><a name="l00602"></a><span class="lineno"> 602</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> filter_;</div><div class="line"><a name="l00603"></a><span class="lineno"> 603</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> internal_run_death_test_;</div><div class="line"><a name="l00604"></a><span class="lineno"> 604</span>  <span class="keywordtype">bool</span> list_tests_;</div><div class="line"><a name="l00605"></a><span class="lineno"> 605</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> output_;</div><div class="line"><a name="l00606"></a><span class="lineno"> 606</span>  <span class="keywordtype">bool</span> print_time_;</div><div class="line"><a name="l00607"></a><span class="lineno"> 607</span>  <span class="keywordtype">bool</span> print_utf8_;</div><div class="line"><a name="l00608"></a><span class="lineno"> 608</span>  <a class="code" href="namespacetesting_1_1internal.html#a8ee38faaf875f133358abaf9bc056cec">internal::Int32</a> random_seed_;</div><div class="line"><a name="l00609"></a><span class="lineno"> 609</span>  <a class="code" href="namespacetesting_1_1internal.html#a8ee38faaf875f133358abaf9bc056cec">internal::Int32</a> repeat_;</div><div class="line"><a name="l00610"></a><span class="lineno"> 610</span>  <span class="keywordtype">bool</span> shuffle_;</div><div class="line"><a name="l00611"></a><span class="lineno"> 611</span>  <a class="code" href="namespacetesting_1_1internal.html#a8ee38faaf875f133358abaf9bc056cec">internal::Int32</a> stack_trace_depth_;</div><div class="line"><a name="l00612"></a><span class="lineno"> 612</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> stream_result_to_;</div><div class="line"><a name="l00613"></a><span class="lineno"> 613</span>  <span class="keywordtype">bool</span> throw_on_failure_;</div><div class="line"><a name="l00614"></a><span class="lineno"> 614</span> } <a class="code" href="gtest_8h.html#acdd47601a9376161c349a5881ccc6918">GTEST_ATTRIBUTE_UNUSED_</a>;</div><div class="line"><a name="l00615"></a><span class="lineno"> 615</span> </div><div class="line"><a name="l00616"></a><span class="lineno"> 616</span> <span class="comment">// Converts a Unicode code point to a narrow string in UTF-8 encoding.</span></div><div class="line"><a name="l00617"></a><span class="lineno"> 617</span> <span class="comment">// code_point parameter is of type UInt32 because wchar_t may not be</span></div><div class="line"><a name="l00618"></a><span class="lineno"> 618</span> <span class="comment">// wide enough to contain a code point.</span></div><div class="line"><a name="l00619"></a><span class="lineno"> 619</span> <span class="comment">// If the code_point is not a valid Unicode code point</span></div><div class="line"><a name="l00620"></a><span class="lineno"> 620</span> <span class="comment">// (i.e. outside of Unicode range U+0 to U+10FFFF) it will be converted</span></div><div class="line"><a name="l00621"></a><span class="lineno"> 621</span> <span class="comment">// to "(Invalid Unicode 0xXXXXXXXX)".</span></div><div class="line"><a name="l00622"></a><span class="lineno"> 622</span> <a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> CodePointToUtf8(<a class="code" href="namespacetesting_1_1internal.html#a40d4fffcd2bf56f18b1c380615aa85e3">UInt32</a> code_point);</div><div class="line"><a name="l00623"></a><span class="lineno"> 623</span> </div><div class="line"><a name="l00624"></a><span class="lineno"> 624</span> <span class="comment">// Converts a wide string to a narrow string in UTF-8 encoding.</span></div><div class="line"><a name="l00625"></a><span class="lineno"> 625</span> <span class="comment">// The wide string is assumed to have the following encoding:</span></div><div class="line"><a name="l00626"></a><span class="lineno"> 626</span> <span class="comment">// UTF-16 if sizeof(wchar_t) == 2 (on Windows, Cygwin)</span></div><div class="line"><a name="l00627"></a><span class="lineno"> 627</span> <span class="comment">// UTF-32 if sizeof(wchar_t) == 4 (on Linux)</span></div><div class="line"><a name="l00628"></a><span class="lineno"> 628</span> <span class="comment">// Parameter str points to a null-terminated wide string.</span></div><div class="line"><a name="l00629"></a><span class="lineno"> 629</span> <span class="comment">// Parameter num_chars may additionally limit the number</span></div><div class="line"><a name="l00630"></a><span class="lineno"> 630</span> <span class="comment">// of wchar_t characters processed. -1 is used when the entire string</span></div><div class="line"><a name="l00631"></a><span class="lineno"> 631</span> <span class="comment">// should be processed.</span></div><div class="line"><a name="l00632"></a><span class="lineno"> 632</span> <span class="comment">// If the string contains code points that are not valid Unicode code points</span></div><div class="line"><a name="l00633"></a><span class="lineno"> 633</span> <span class="comment">// (i.e. outside of Unicode range U+0 to U+10FFFF) they will be output</span></div><div class="line"><a name="l00634"></a><span class="lineno"> 634</span> <span class="comment">// as '(Invalid Unicode 0xXXXXXXXX)'. If the string is in UTF16 encoding</span></div><div class="line"><a name="l00635"></a><span class="lineno"> 635</span> <span class="comment">// and contains invalid UTF-16 surrogate pairs, values in those pairs</span></div><div class="line"><a name="l00636"></a><span class="lineno"> 636</span> <span class="comment">// will be encoded as individual Unicode characters from Basic Normal Plane.</span></div><div class="line"><a name="l00637"></a><span class="lineno"> 637</span> <a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> WideStringToUtf8(<span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* str, <span class="keywordtype">int</span> num_chars);</div><div class="line"><a name="l00638"></a><span class="lineno"> 638</span> </div><div class="line"><a name="l00639"></a><span class="lineno"> 639</span> <span class="comment">// Reads the GTEST_SHARD_STATUS_FILE environment variable, and creates the file</span></div><div class="line"><a name="l00640"></a><span class="lineno"> 640</span> <span class="comment">// if the variable is present. If a file already exists at this location, this</span></div><div class="line"><a name="l00641"></a><span class="lineno"> 641</span> <span class="comment">// function will write over it. If the variable is present, but the file cannot</span></div><div class="line"><a name="l00642"></a><span class="lineno"> 642</span> <span class="comment">// be created, prints an error and exits.</span></div><div class="line"><a name="l00643"></a><span class="lineno"> 643</span> <span class="keywordtype">void</span> WriteToShardStatusFileIfNeeded();</div><div class="line"><a name="l00644"></a><span class="lineno"> 644</span> </div><div class="line"><a name="l00645"></a><span class="lineno"> 645</span> <span class="comment">// Checks whether sharding is enabled by examining the relevant</span></div><div class="line"><a name="l00646"></a><span class="lineno"> 646</span> <span class="comment">// environment variable values. If the variables are present,</span></div><div class="line"><a name="l00647"></a><span class="lineno"> 647</span> <span class="comment">// but inconsistent (e.g., shard_index >= total_shards), prints</span></div><div class="line"><a name="l00648"></a><span class="lineno"> 648</span> <span class="comment">// an error and exits. If in_subprocess_for_death_test, sharding is</span></div><div class="line"><a name="l00649"></a><span class="lineno"> 649</span> <span class="comment">// disabled because it must only be applied to the original test</span></div><div class="line"><a name="l00650"></a><span class="lineno"> 650</span> <span class="comment">// process. Otherwise, we could filter out death tests we intended to execute.</span></div><div class="line"><a name="l00651"></a><span class="lineno"> 651</span> <a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> <span class="keywordtype">bool</span> ShouldShard(<span class="keyword">const</span> <span class="keywordtype">char</span>* total_shards_str,</div><div class="line"><a name="l00652"></a><span class="lineno"> 652</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* shard_index_str,</div><div class="line"><a name="l00653"></a><span class="lineno"> 653</span>  <span class="keywordtype">bool</span> in_subprocess_for_death_test);</div><div class="line"><a name="l00654"></a><span class="lineno"> 654</span> </div><div class="line"><a name="l00655"></a><span class="lineno"> 655</span> <span class="comment">// Parses the environment variable var as an Int32. If it is unset,</span></div><div class="line"><a name="l00656"></a><span class="lineno"> 656</span> <span class="comment">// returns default_val. If it is not an Int32, prints an error and</span></div><div class="line"><a name="l00657"></a><span class="lineno"> 657</span> <span class="comment">// and aborts.</span></div><div class="line"><a name="l00658"></a><span class="lineno"> 658</span> <a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> <a class="code" href="namespacetesting_1_1internal.html#a8ee38faaf875f133358abaf9bc056cec">Int32</a> Int32FromEnvOrDie(<span class="keyword">const</span> <span class="keywordtype">char</span>* env_var, <a class="code" href="namespacetesting_1_1internal.html#a8ee38faaf875f133358abaf9bc056cec">Int32</a> default_val);</div><div class="line"><a name="l00659"></a><span class="lineno"> 659</span> </div><div class="line"><a name="l00660"></a><span class="lineno"> 660</span> <span class="comment">// Given the total number of shards, the shard index, and the test id,</span></div><div class="line"><a name="l00661"></a><span class="lineno"> 661</span> <span class="comment">// returns true iff the test should be run on this shard. The test id is</span></div><div class="line"><a name="l00662"></a><span class="lineno"> 662</span> <span class="comment">// some arbitrary but unique non-negative integer assigned to each test</span></div><div class="line"><a name="l00663"></a><span class="lineno"> 663</span> <span class="comment">// method. Assumes that 0 <= shard_index < total_shards.</span></div><div class="line"><a name="l00664"></a><span class="lineno"> 664</span> <a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> <span class="keywordtype">bool</span> ShouldRunTestOnShard(</div><div class="line"><a name="l00665"></a><span class="lineno"> 665</span>  <span class="keywordtype">int</span> total_shards, <span class="keywordtype">int</span> shard_index, <span class="keywordtype">int</span> test_id);</div><div class="line"><a name="l00666"></a><span class="lineno"> 666</span> </div><div class="line"><a name="l00667"></a><span class="lineno"> 667</span> <span class="comment">// STL container utilities.</span></div><div class="line"><a name="l00668"></a><span class="lineno"> 668</span> </div><div class="line"><a name="l00669"></a><span class="lineno"> 669</span> <span class="comment">// Returns the number of elements in the given container that satisfy</span></div><div class="line"><a name="l00670"></a><span class="lineno"> 670</span> <span class="comment">// the given predicate.</span></div><div class="line"><a name="l00671"></a><span class="lineno"> 671</span> <span class="keyword">template</span> <<span class="keyword">class</span> Container, <span class="keyword">typename</span> Predicate></div><div class="line"><a name="l00672"></a><span class="lineno"> 672</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> CountIf(<span class="keyword">const</span> Container& c, <a class="code" href="namespaceutl.html#aae56a019cdd2006c4f07d2e207289195">Predicate</a> predicate) {</div><div class="line"><a name="l00673"></a><span class="lineno"> 673</span>  <span class="comment">// Implemented as an explicit loop since std::count_if() in libCstd on</span></div><div class="line"><a name="l00674"></a><span class="lineno"> 674</span>  <span class="comment">// Solaris has a non-standard signature.</span></div><div class="line"><a name="l00675"></a><span class="lineno"> 675</span>  <span class="keywordtype">int</span> <a class="code" href="namespaceutl_1_1meta.html#ab5508236016638fa8e6b97cd17dfc9c2">count</a> = 0;</div><div class="line"><a name="l00676"></a><span class="lineno"> 676</span>  <span class="keywordflow">for</span> (<span class="keyword">typename</span> Container::const_iterator it = c.begin(); it != c.end(); ++it) {</div><div class="line"><a name="l00677"></a><span class="lineno"> 677</span>  <span class="keywordflow">if</span> (predicate(*it))</div><div class="line"><a name="l00678"></a><span class="lineno"> 678</span>  ++<a class="code" href="namespaceutl_1_1meta.html#ab5508236016638fa8e6b97cd17dfc9c2">count</a>;</div><div class="line"><a name="l00679"></a><span class="lineno"> 679</span>  }</div><div class="line"><a name="l00680"></a><span class="lineno"> 680</span>  <span class="keywordflow">return</span> <a class="code" href="namespaceutl_1_1meta.html#ab5508236016638fa8e6b97cd17dfc9c2">count</a>;</div><div class="line"><a name="l00681"></a><span class="lineno"> 681</span> }</div><div class="line"><a name="l00682"></a><span class="lineno"> 682</span> </div><div class="line"><a name="l00683"></a><span class="lineno"> 683</span> <span class="comment">// Applies a function/functor to each element in the container.</span></div><div class="line"><a name="l00684"></a><span class="lineno"> 684</span> <span class="keyword">template</span> <<span class="keyword">class</span> Container, <span class="keyword">typename</span> Functor></div><div class="line"><a name="l00685"></a><span class="lineno"> 685</span> <span class="keywordtype">void</span> ForEach(<span class="keyword">const</span> Container& c, Functor functor) {</div><div class="line"><a name="l00686"></a><span class="lineno"> 686</span>  std::for_each(c.begin(), c.end(), functor);</div><div class="line"><a name="l00687"></a><span class="lineno"> 687</span> }</div><div class="line"><a name="l00688"></a><span class="lineno"> 688</span> </div><div class="line"><a name="l00689"></a><span class="lineno"> 689</span> <span class="comment">// Returns the i-th element of the vector, or default_value if i is not</span></div><div class="line"><a name="l00690"></a><span class="lineno"> 690</span> <span class="comment">// in range [0, v.size()).</span></div><div class="line"><a name="l00691"></a><span class="lineno"> 691</span> <span class="keyword">template</span> <<span class="keyword">typename</span> E></div><div class="line"><a name="l00692"></a><span class="lineno"> 692</span> <span class="keyword">inline</span> E GetElementOr(<span class="keyword">const</span> std::vector<E>& v, <span class="keywordtype">int</span> i, E default_value) {</div><div class="line"><a name="l00693"></a><span class="lineno"> 693</span>  <span class="keywordflow">return</span> (i < 0 || i >= static_cast<int>(v.size())) ? default_value : v[i];</div><div class="line"><a name="l00694"></a><span class="lineno"> 694</span> }</div><div class="line"><a name="l00695"></a><span class="lineno"> 695</span> </div><div class="line"><a name="l00696"></a><span class="lineno"> 696</span> <span class="comment">// Performs an in-place shuffle of a range of the vector's elements.</span></div><div class="line"><a name="l00697"></a><span class="lineno"> 697</span> <span class="comment">// 'begin' and 'end' are element indices as an STL-style range;</span></div><div class="line"><a name="l00698"></a><span class="lineno"> 698</span> <span class="comment">// i.e. [begin, end) are shuffled, where 'end' == size() means to</span></div><div class="line"><a name="l00699"></a><span class="lineno"> 699</span> <span class="comment">// shuffle to the end of the vector.</span></div><div class="line"><a name="l00700"></a><span class="lineno"> 700</span> <span class="keyword">template</span> <<span class="keyword">typename</span> E></div><div class="line"><a name="l00701"></a><span class="lineno"> 701</span> <span class="keywordtype">void</span> ShuffleRange(internal::Random* random, <span class="keywordtype">int</span> begin, <span class="keywordtype">int</span> end,</div><div class="line"><a name="l00702"></a><span class="lineno"> 702</span>  std::vector<E>* v) {</div><div class="line"><a name="l00703"></a><span class="lineno"> 703</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="namespaceutl_1_1meta.html#a0edfc2c15e42531e53c0822264d220ec">size</a> = <span class="keyword">static_cast<</span><span class="keywordtype">int</span><span class="keyword">></span>(v->size());</div><div class="line"><a name="l00704"></a><span class="lineno"> 704</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(0 <= begin && begin <= <a class="code" href="namespaceutl_1_1meta.html#a0edfc2c15e42531e53c0822264d220ec">size</a>)</div><div class="line"><a name="l00705"></a><span class="lineno"> 705</span>  << <span class="stringliteral">"Invalid shuffle range start "</span> << begin << <span class="stringliteral">": must be in range [0, "</span></div><div class="line"><a name="l00706"></a><span class="lineno"> 706</span>  << <a class="code" href="namespaceutl_1_1meta.html#a0edfc2c15e42531e53c0822264d220ec">size</a> << <span class="stringliteral">"]."</span>;</div><div class="line"><a name="l00707"></a><span class="lineno"> 707</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(begin <= end && end <= <a class="code" href="namespaceutl_1_1meta.html#a0edfc2c15e42531e53c0822264d220ec">size</a>)</div><div class="line"><a name="l00708"></a><span class="lineno"> 708</span>  << <span class="stringliteral">"Invalid shuffle range finish "</span> << end << <span class="stringliteral">": must be in range ["</span></div><div class="line"><a name="l00709"></a><span class="lineno"> 709</span>  << begin << <span class="stringliteral">", "</span> << <a class="code" href="namespaceutl_1_1meta.html#a0edfc2c15e42531e53c0822264d220ec">size</a> << <span class="stringliteral">"]."</span>;</div><div class="line"><a name="l00710"></a><span class="lineno"> 710</span> </div><div class="line"><a name="l00711"></a><span class="lineno"> 711</span>  <span class="comment">// Fisher-Yates shuffle, from</span></div><div class="line"><a name="l00712"></a><span class="lineno"> 712</span>  <span class="comment">// http://en.wikipedia.org/wiki/Fisher-Yates_shuffle</span></div><div class="line"><a name="l00713"></a><span class="lineno"> 713</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> range_width = end - begin; range_width >= 2; range_width--) {</div><div class="line"><a name="l00714"></a><span class="lineno"> 714</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> last_in_range = begin + range_width - 1;</div><div class="line"><a name="l00715"></a><span class="lineno"> 715</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> selected = begin + random->Generate(range_width);</div><div class="line"><a name="l00716"></a><span class="lineno"> 716</span>  <a class="code" href="namespaceutl.html#ae0f873b4883af7cc18cb23dd2810f4e6">std::swap</a>((*v)[selected], (*v)[last_in_range]);</div><div class="line"><a name="l00717"></a><span class="lineno"> 717</span>  }</div><div class="line"><a name="l00718"></a><span class="lineno"> 718</span> }</div><div class="line"><a name="l00719"></a><span class="lineno"> 719</span> </div><div class="line"><a name="l00720"></a><span class="lineno"> 720</span> <span class="comment">// Performs an in-place shuffle of the vector's elements.</span></div><div class="line"><a name="l00721"></a><span class="lineno"> 721</span> <span class="keyword">template</span> <<span class="keyword">typename</span> E></div><div class="line"><a name="l00722"></a><span class="lineno"> 722</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> Shuffle(internal::Random* random, std::vector<E>* v) {</div><div class="line"><a name="l00723"></a><span class="lineno"> 723</span>  ShuffleRange(random, 0, static_cast<int>(v->size()), v);</div><div class="line"><a name="l00724"></a><span class="lineno"> 724</span> }</div><div class="line"><a name="l00725"></a><span class="lineno"> 725</span> </div><div class="line"><a name="l00726"></a><span class="lineno"> 726</span> <span class="comment">// A function for deleting an object. Handy for being used as a</span></div><div class="line"><a name="l00727"></a><span class="lineno"> 727</span> <span class="comment">// functor.</span></div><div class="line"><a name="l00728"></a><span class="lineno"> 728</span> <span class="keyword">template</span> <<span class="keyword">typename</span> T></div><div class="line"><a name="l00729"></a><span class="lineno"> 729</span> <span class="keyword">static</span> <span class="keywordtype">void</span> Delete(T* x) {</div><div class="line"><a name="l00730"></a><span class="lineno"> 730</span>  <span class="keyword">delete</span> x;</div><div class="line"><a name="l00731"></a><span class="lineno"> 731</span> }</div><div class="line"><a name="l00732"></a><span class="lineno"> 732</span> </div><div class="line"><a name="l00733"></a><span class="lineno"> 733</span> <span class="comment">// A predicate that checks the key of a TestProperty against a known key.</span></div><div class="line"><a name="l00734"></a><span class="lineno"> 734</span> <span class="comment">//</span></div><div class="line"><a name="l00735"></a><span class="lineno"> 735</span> <span class="comment">// TestPropertyKeyIs is copyable.</span></div><div class="line"><a name="l00736"></a><span class="lineno"> 736</span> <span class="keyword">class </span>TestPropertyKeyIs {</div><div class="line"><a name="l00737"></a><span class="lineno"> 737</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00738"></a><span class="lineno"> 738</span>  <span class="comment">// Constructor.</span></div><div class="line"><a name="l00739"></a><span class="lineno"> 739</span>  <span class="comment">//</span></div><div class="line"><a name="l00740"></a><span class="lineno"> 740</span>  <span class="comment">// TestPropertyKeyIs has NO default constructor.</span></div><div class="line"><a name="l00741"></a><span class="lineno"> 741</span>  <span class="keyword">explicit</span> TestPropertyKeyIs(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& key) : key_(key) {}</div><div class="line"><a name="l00742"></a><span class="lineno"> 742</span> </div><div class="line"><a name="l00743"></a><span class="lineno"> 743</span>  <span class="comment">// Returns true iff the test name of test property matches on key_.</span></div><div class="line"><a name="l00744"></a><span class="lineno"> 744</span>  <span class="keywordtype">bool</span> operator()(<span class="keyword">const</span> TestProperty& test_property)<span class="keyword"> const </span>{</div><div class="line"><a name="l00745"></a><span class="lineno"> 745</span>  <span class="keywordflow">return</span> test_property.key() == key_;</div><div class="line"><a name="l00746"></a><span class="lineno"> 746</span>  }</div><div class="line"><a name="l00747"></a><span class="lineno"> 747</span> </div><div class="line"><a name="l00748"></a><span class="lineno"> 748</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l00749"></a><span class="lineno"> 749</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> key_;</div><div class="line"><a name="l00750"></a><span class="lineno"> 750</span> };</div><div class="line"><a name="l00751"></a><span class="lineno"> 751</span> </div><div class="line"><a name="l00752"></a><span class="lineno"> 752</span> <span class="comment">// Class UnitTestOptions.</span></div><div class="line"><a name="l00753"></a><span class="lineno"> 753</span> <span class="comment">//</span></div><div class="line"><a name="l00754"></a><span class="lineno"> 754</span> <span class="comment">// This class contains functions for processing options the user</span></div><div class="line"><a name="l00755"></a><span class="lineno"> 755</span> <span class="comment">// specifies when running the tests. It has only static members.</span></div><div class="line"><a name="l00756"></a><span class="lineno"> 756</span> <span class="comment">//</span></div><div class="line"><a name="l00757"></a><span class="lineno"> 757</span> <span class="comment">// In most cases, the user can specify an option using either an</span></div><div class="line"><a name="l00758"></a><span class="lineno"> 758</span> <span class="comment">// environment variable or a command line flag. E.g. you can set the</span></div><div class="line"><a name="l00759"></a><span class="lineno"> 759</span> <span class="comment">// test filter using either GTEST_FILTER or --gtest_filter. If both</span></div><div class="line"><a name="l00760"></a><span class="lineno"> 760</span> <span class="comment">// the variable and the flag are present, the latter overrides the</span></div><div class="line"><a name="l00761"></a><span class="lineno"> 761</span> <span class="comment">// former.</span></div><div class="line"><a name="l00762"></a><span class="lineno"> 762</span> <span class="keyword">class </span><a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> UnitTestOptions {</div><div class="line"><a name="l00763"></a><span class="lineno"> 763</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00764"></a><span class="lineno"> 764</span>  <span class="comment">// Functions for processing the gtest_output flag.</span></div><div class="line"><a name="l00765"></a><span class="lineno"> 765</span> </div><div class="line"><a name="l00766"></a><span class="lineno"> 766</span>  <span class="comment">// Returns the output format, or "" for normal printed output.</span></div><div class="line"><a name="l00767"></a><span class="lineno"> 767</span>  <span class="keyword">static</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> GetOutputFormat();</div><div class="line"><a name="l00768"></a><span class="lineno"> 768</span> </div><div class="line"><a name="l00769"></a><span class="lineno"> 769</span>  <span class="comment">// Returns the absolute path of the requested output file, or the</span></div><div class="line"><a name="l00770"></a><span class="lineno"> 770</span>  <span class="comment">// default (test_detail.xml in the original working directory) if</span></div><div class="line"><a name="l00771"></a><span class="lineno"> 771</span>  <span class="comment">// none was explicitly specified.</span></div><div class="line"><a name="l00772"></a><span class="lineno"> 772</span>  <span class="keyword">static</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> GetAbsolutePathToOutputFile();</div><div class="line"><a name="l00773"></a><span class="lineno"> 773</span> </div><div class="line"><a name="l00774"></a><span class="lineno"> 774</span>  <span class="comment">// Functions for processing the gtest_filter flag.</span></div><div class="line"><a name="l00775"></a><span class="lineno"> 775</span> </div><div class="line"><a name="l00776"></a><span class="lineno"> 776</span>  <span class="comment">// Returns true iff the wildcard pattern matches the string. The</span></div><div class="line"><a name="l00777"></a><span class="lineno"> 777</span>  <span class="comment">// first ':' or '\0' character in pattern marks the end of it.</span></div><div class="line"><a name="l00778"></a><span class="lineno"> 778</span>  <span class="comment">//</span></div><div class="line"><a name="l00779"></a><span class="lineno"> 779</span>  <span class="comment">// This recursive algorithm isn't very efficient, but is clear and</span></div><div class="line"><a name="l00780"></a><span class="lineno"> 780</span>  <span class="comment">// works well enough for matching test names, which are short.</span></div><div class="line"><a name="l00781"></a><span class="lineno"> 781</span>  <span class="keyword">static</span> <span class="keywordtype">bool</span> PatternMatchesString(<span class="keyword">const</span> <span class="keywordtype">char</span> *pattern, <span class="keyword">const</span> <span class="keywordtype">char</span> *str);</div><div class="line"><a name="l00782"></a><span class="lineno"> 782</span> </div><div class="line"><a name="l00783"></a><span class="lineno"> 783</span>  <span class="comment">// Returns true iff the user-specified filter matches the test suite</span></div><div class="line"><a name="l00784"></a><span class="lineno"> 784</span>  <span class="comment">// name and the test name.</span></div><div class="line"><a name="l00785"></a><span class="lineno"> 785</span>  <span class="keyword">static</span> <span class="keywordtype">bool</span> FilterMatchesTest(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& test_suite_name,</div><div class="line"><a name="l00786"></a><span class="lineno"> 786</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& test_name);</div><div class="line"><a name="l00787"></a><span class="lineno"> 787</span> </div><div class="line"><a name="l00788"></a><span class="lineno"> 788</span> <span class="preprocessor">#if GTEST_OS_WINDOWS</span></div><div class="line"><a name="l00789"></a><span class="lineno"> 789</span>  <span class="comment">// Function for supporting the gtest_catch_exception flag.</span></div><div class="line"><a name="l00790"></a><span class="lineno"> 790</span> </div><div class="line"><a name="l00791"></a><span class="lineno"> 791</span>  <span class="comment">// Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the</span></div><div class="line"><a name="l00792"></a><span class="lineno"> 792</span>  <span class="comment">// given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise.</span></div><div class="line"><a name="l00793"></a><span class="lineno"> 793</span>  <span class="comment">// This function is useful as an __except condition.</span></div><div class="line"><a name="l00794"></a><span class="lineno"> 794</span>  <span class="keyword">static</span> <span class="keywordtype">int</span> GTestShouldProcessSEH(DWORD exception_code);</div><div class="line"><a name="l00795"></a><span class="lineno"> 795</span> <span class="preprocessor">#endif // GTEST_OS_WINDOWS</span></div><div class="line"><a name="l00796"></a><span class="lineno"> 796</span> </div><div class="line"><a name="l00797"></a><span class="lineno"> 797</span>  <span class="comment">// Returns true if "name" matches the ':' separated list of glob-style</span></div><div class="line"><a name="l00798"></a><span class="lineno"> 798</span>  <span class="comment">// filters in "filter".</span></div><div class="line"><a name="l00799"></a><span class="lineno"> 799</span>  <span class="keyword">static</span> <span class="keywordtype">bool</span> MatchesFilter(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& name, <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="namespaceutl_1_1meta.html#ac72acc616316c322e750d20a46553ba4">filter</a>);</div><div class="line"><a name="l00800"></a><span class="lineno"> 800</span> };</div><div class="line"><a name="l00801"></a><span class="lineno"> 801</span> </div><div class="line"><a name="l00802"></a><span class="lineno"> 802</span> <span class="comment">// Returns the current application's name, removing directory path if that</span></div><div class="line"><a name="l00803"></a><span class="lineno"> 803</span> <span class="comment">// is present. Used by UnitTestOptions::GetOutputFile.</span></div><div class="line"><a name="l00804"></a><span class="lineno"> 804</span> <a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> FilePath GetCurrentExecutableName();</div><div class="line"><a name="l00805"></a><span class="lineno"> 805</span> </div><div class="line"><a name="l00806"></a><span class="lineno"> 806</span> <span class="comment">// The role interface for getting the OS stack trace as a string.</span></div><div class="line"><a name="l00807"></a><span class="lineno"> 807</span> <span class="keyword">class </span>OsStackTraceGetterInterface {</div><div class="line"><a name="l00808"></a><span class="lineno"> 808</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00809"></a><span class="lineno"> 809</span>  OsStackTraceGetterInterface() {}</div><div class="line"><a name="l00810"></a><span class="lineno"> 810</span>  <span class="keyword">virtual</span> ~OsStackTraceGetterInterface() {}</div><div class="line"><a name="l00811"></a><span class="lineno"> 811</span> </div><div class="line"><a name="l00812"></a><span class="lineno"> 812</span>  <span class="comment">// Returns the current OS stack trace as an std::string. Parameters:</span></div><div class="line"><a name="l00813"></a><span class="lineno"> 813</span>  <span class="comment">//</span></div><div class="line"><a name="l00814"></a><span class="lineno"> 814</span>  <span class="comment">// max_depth - the maximum number of stack frames to be included</span></div><div class="line"><a name="l00815"></a><span class="lineno"> 815</span>  <span class="comment">// in the trace.</span></div><div class="line"><a name="l00816"></a><span class="lineno"> 816</span>  <span class="comment">// skip_count - the number of top frames to be skipped; doesn't count</span></div><div class="line"><a name="l00817"></a><span class="lineno"> 817</span>  <span class="comment">// against max_depth.</span></div><div class="line"><a name="l00818"></a><span class="lineno"> 818</span>  <span class="keyword">virtual</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> CurrentStackTrace(<span class="keywordtype">int</span> max_depth, <span class="keywordtype">int</span> skip_count) = 0;</div><div class="line"><a name="l00819"></a><span class="lineno"> 819</span> </div><div class="line"><a name="l00820"></a><span class="lineno"> 820</span>  <span class="comment">// UponLeavingGTest() should be called immediately before Google Test calls</span></div><div class="line"><a name="l00821"></a><span class="lineno"> 821</span>  <span class="comment">// user code. It saves some information about the current stack that</span></div><div class="line"><a name="l00822"></a><span class="lineno"> 822</span>  <span class="comment">// CurrentStackTrace() will use to find and hide Google Test stack frames.</span></div><div class="line"><a name="l00823"></a><span class="lineno"> 823</span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> UponLeavingGTest() = 0;</div><div class="line"><a name="l00824"></a><span class="lineno"> 824</span> </div><div class="line"><a name="l00825"></a><span class="lineno"> 825</span>  <span class="comment">// This string is inserted in place of stack frames that are part of</span></div><div class="line"><a name="l00826"></a><span class="lineno"> 826</span>  <span class="comment">// Google Test's implementation.</span></div><div class="line"><a name="l00827"></a><span class="lineno"> 827</span>  <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> kElidedFramesMarker;</div><div class="line"><a name="l00828"></a><span class="lineno"> 828</span> </div><div class="line"><a name="l00829"></a><span class="lineno"> 829</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l00830"></a><span class="lineno"> 830</span>  <a class="code" href="gtest_8h.html#aed8c1888c32b588b0681e88b95031e29">GTEST_DISALLOW_COPY_AND_ASSIGN_</a>(OsStackTraceGetterInterface);</div><div class="line"><a name="l00831"></a><span class="lineno"> 831</span> };</div><div class="line"><a name="l00832"></a><span class="lineno"> 832</span> </div><div class="line"><a name="l00833"></a><span class="lineno"> 833</span> <span class="comment">// A working implementation of the OsStackTraceGetterInterface interface.</span></div><div class="line"><a name="l00834"></a><span class="lineno"> 834</span> <span class="keyword">class </span>OsStackTraceGetter : <span class="keyword">public</span> OsStackTraceGetterInterface {</div><div class="line"><a name="l00835"></a><span class="lineno"> 835</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00836"></a><span class="lineno"> 836</span>  OsStackTraceGetter() {}</div><div class="line"><a name="l00837"></a><span class="lineno"> 837</span> </div><div class="line"><a name="l00838"></a><span class="lineno"> 838</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> CurrentStackTrace(<span class="keywordtype">int</span> max_depth, <span class="keywordtype">int</span> skip_count) <span class="keyword">override</span>;</div><div class="line"><a name="l00839"></a><span class="lineno"> 839</span>  <span class="keywordtype">void</span> UponLeavingGTest() <span class="keyword">override</span>;</div><div class="line"><a name="l00840"></a><span class="lineno"> 840</span> </div><div class="line"><a name="l00841"></a><span class="lineno"> 841</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l00842"></a><span class="lineno"> 842</span> <span class="preprocessor">#if GTEST_HAS_ABSL</span></div><div class="line"><a name="l00843"></a><span class="lineno"> 843</span>  Mutex mutex_; <span class="comment">// Protects all internal state.</span></div><div class="line"><a name="l00844"></a><span class="lineno"> 844</span> </div><div class="line"><a name="l00845"></a><span class="lineno"> 845</span>  <span class="comment">// We save the stack frame below the frame that calls user code.</span></div><div class="line"><a name="l00846"></a><span class="lineno"> 846</span>  <span class="comment">// We do this because the address of the frame immediately below</span></div><div class="line"><a name="l00847"></a><span class="lineno"> 847</span>  <span class="comment">// the user code changes between the call to UponLeavingGTest()</span></div><div class="line"><a name="l00848"></a><span class="lineno"> 848</span>  <span class="comment">// and any calls to the stack trace code from within the user code.</span></div><div class="line"><a name="l00849"></a><span class="lineno"> 849</span>  <span class="keywordtype">void</span>* caller_frame_ = <span class="keyword">nullptr</span>;</div><div class="line"><a name="l00850"></a><span class="lineno"> 850</span> <span class="preprocessor">#endif // GTEST_HAS_ABSL</span></div><div class="line"><a name="l00851"></a><span class="lineno"> 851</span> </div><div class="line"><a name="l00852"></a><span class="lineno"> 852</span>  <a class="code" href="gtest_8h.html#aed8c1888c32b588b0681e88b95031e29">GTEST_DISALLOW_COPY_AND_ASSIGN_</a>(OsStackTraceGetter);</div><div class="line"><a name="l00853"></a><span class="lineno"> 853</span> };</div><div class="line"><a name="l00854"></a><span class="lineno"> 854</span> </div><div class="line"><a name="l00855"></a><span class="lineno"> 855</span> <span class="comment">// Information about a Google Test trace point.</span></div><div class="line"><a name="l00856"></a><span class="lineno"> 856</span> <span class="keyword">struct </span>TraceInfo {</div><div class="line"><a name="l00857"></a><span class="lineno"> 857</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* file;</div><div class="line"><a name="l00858"></a><span class="lineno"> 858</span>  <span class="keywordtype">int</span> line;</div><div class="line"><a name="l00859"></a><span class="lineno"> 859</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> message;</div><div class="line"><a name="l00860"></a><span class="lineno"> 860</span> };</div><div class="line"><a name="l00861"></a><span class="lineno"> 861</span> </div><div class="line"><a name="l00862"></a><span class="lineno"> 862</span> <span class="comment">// This is the default global test part result reporter used in UnitTestImpl.</span></div><div class="line"><a name="l00863"></a><span class="lineno"> 863</span> <span class="comment">// This class should only be used by UnitTestImpl.</span></div><div class="line"><a name="l00864"></a><span class="lineno"> 864</span> <span class="keyword">class </span>DefaultGlobalTestPartResultReporter</div><div class="line"><a name="l00865"></a><span class="lineno"> 865</span>  : <span class="keyword">public</span> TestPartResultReporterInterface {</div><div class="line"><a name="l00866"></a><span class="lineno"> 866</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00867"></a><span class="lineno"> 867</span>  <span class="keyword">explicit</span> DefaultGlobalTestPartResultReporter(UnitTestImpl* unit_test);</div><div class="line"><a name="l00868"></a><span class="lineno"> 868</span>  <span class="comment">// Implements the TestPartResultReporterInterface. Reports the test part</span></div><div class="line"><a name="l00869"></a><span class="lineno"> 869</span>  <span class="comment">// result in the current test.</span></div><div class="line"><a name="l00870"></a><span class="lineno"> 870</span>  <span class="keywordtype">void</span> ReportTestPartResult(<span class="keyword">const</span> TestPartResult& result) <span class="keyword">override</span>;</div><div class="line"><a name="l00871"></a><span class="lineno"> 871</span> </div><div class="line"><a name="l00872"></a><span class="lineno"> 872</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l00873"></a><span class="lineno"> 873</span>  UnitTestImpl* <span class="keyword">const</span> unit_test_;</div><div class="line"><a name="l00874"></a><span class="lineno"> 874</span> </div><div class="line"><a name="l00875"></a><span class="lineno"> 875</span>  <a class="code" href="gtest_8h.html#aed8c1888c32b588b0681e88b95031e29">GTEST_DISALLOW_COPY_AND_ASSIGN_</a>(DefaultGlobalTestPartResultReporter);</div><div class="line"><a name="l00876"></a><span class="lineno"> 876</span> };</div><div class="line"><a name="l00877"></a><span class="lineno"> 877</span> </div><div class="line"><a name="l00878"></a><span class="lineno"> 878</span> <span class="comment">// This is the default per thread test part result reporter used in</span></div><div class="line"><a name="l00879"></a><span class="lineno"> 879</span> <span class="comment">// UnitTestImpl. This class should only be used by UnitTestImpl.</span></div><div class="line"><a name="l00880"></a><span class="lineno"> 880</span> <span class="keyword">class </span>DefaultPerThreadTestPartResultReporter</div><div class="line"><a name="l00881"></a><span class="lineno"> 881</span>  : <span class="keyword">public</span> TestPartResultReporterInterface {</div><div class="line"><a name="l00882"></a><span class="lineno"> 882</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00883"></a><span class="lineno"> 883</span>  <span class="keyword">explicit</span> DefaultPerThreadTestPartResultReporter(UnitTestImpl* unit_test);</div><div class="line"><a name="l00884"></a><span class="lineno"> 884</span>  <span class="comment">// Implements the TestPartResultReporterInterface. The implementation just</span></div><div class="line"><a name="l00885"></a><span class="lineno"> 885</span>  <span class="comment">// delegates to the current global test part result reporter of *unit_test_.</span></div><div class="line"><a name="l00886"></a><span class="lineno"> 886</span>  <span class="keywordtype">void</span> ReportTestPartResult(<span class="keyword">const</span> TestPartResult& result) <span class="keyword">override</span>;</div><div class="line"><a name="l00887"></a><span class="lineno"> 887</span> </div><div class="line"><a name="l00888"></a><span class="lineno"> 888</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l00889"></a><span class="lineno"> 889</span>  UnitTestImpl* <span class="keyword">const</span> unit_test_;</div><div class="line"><a name="l00890"></a><span class="lineno"> 890</span> </div><div class="line"><a name="l00891"></a><span class="lineno"> 891</span>  <a class="code" href="gtest_8h.html#aed8c1888c32b588b0681e88b95031e29">GTEST_DISALLOW_COPY_AND_ASSIGN_</a>(DefaultPerThreadTestPartResultReporter);</div><div class="line"><a name="l00892"></a><span class="lineno"> 892</span> };</div><div class="line"><a name="l00893"></a><span class="lineno"> 893</span> </div><div class="line"><a name="l00894"></a><span class="lineno"> 894</span> <span class="comment">// The private implementation of the UnitTest class. We don't protect</span></div><div class="line"><a name="l00895"></a><span class="lineno"> 895</span> <span class="comment">// the methods under a mutex, as this class is not accessible by a</span></div><div class="line"><a name="l00896"></a><span class="lineno"> 896</span> <span class="comment">// user and the UnitTest class that delegates work to this class does</span></div><div class="line"><a name="l00897"></a><span class="lineno"> 897</span> <span class="comment">// proper locking.</span></div><div class="line"><a name="l00898"></a><span class="lineno"> 898</span> <span class="keyword">class </span><a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> UnitTestImpl {</div><div class="line"><a name="l00899"></a><span class="lineno"> 899</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00900"></a><span class="lineno"> 900</span>  <span class="keyword">explicit</span> UnitTestImpl(UnitTest* parent);</div><div class="line"><a name="l00901"></a><span class="lineno"> 901</span>  <span class="keyword">virtual</span> ~UnitTestImpl();</div><div class="line"><a name="l00902"></a><span class="lineno"> 902</span> </div><div class="line"><a name="l00903"></a><span class="lineno"> 903</span>  <span class="comment">// There are two different ways to register your own TestPartResultReporter.</span></div><div class="line"><a name="l00904"></a><span class="lineno"> 904</span>  <span class="comment">// You can register your own repoter to listen either only for test results</span></div><div class="line"><a name="l00905"></a><span class="lineno"> 905</span>  <span class="comment">// from the current thread or for results from all threads.</span></div><div class="line"><a name="l00906"></a><span class="lineno"> 906</span>  <span class="comment">// By default, each per-thread test result repoter just passes a new</span></div><div class="line"><a name="l00907"></a><span class="lineno"> 907</span>  <span class="comment">// TestPartResult to the global test result reporter, which registers the</span></div><div class="line"><a name="l00908"></a><span class="lineno"> 908</span>  <span class="comment">// test part result for the currently running test.</span></div><div class="line"><a name="l00909"></a><span class="lineno"> 909</span> </div><div class="line"><a name="l00910"></a><span class="lineno"> 910</span>  <span class="comment">// Returns the global test part result reporter.</span></div><div class="line"><a name="l00911"></a><span class="lineno"> 911</span>  TestPartResultReporterInterface* GetGlobalTestPartResultReporter();</div><div class="line"><a name="l00912"></a><span class="lineno"> 912</span> </div><div class="line"><a name="l00913"></a><span class="lineno"> 913</span>  <span class="comment">// Sets the global test part result reporter.</span></div><div class="line"><a name="l00914"></a><span class="lineno"> 914</span>  <span class="keywordtype">void</span> SetGlobalTestPartResultReporter(</div><div class="line"><a name="l00915"></a><span class="lineno"> 915</span>  TestPartResultReporterInterface* reporter);</div><div class="line"><a name="l00916"></a><span class="lineno"> 916</span> </div><div class="line"><a name="l00917"></a><span class="lineno"> 917</span>  <span class="comment">// Returns the test part result reporter for the current thread.</span></div><div class="line"><a name="l00918"></a><span class="lineno"> 918</span>  TestPartResultReporterInterface* GetTestPartResultReporterForCurrentThread();</div><div class="line"><a name="l00919"></a><span class="lineno"> 919</span> </div><div class="line"><a name="l00920"></a><span class="lineno"> 920</span>  <span class="comment">// Sets the test part result reporter for the current thread.</span></div><div class="line"><a name="l00921"></a><span class="lineno"> 921</span>  <span class="keywordtype">void</span> SetTestPartResultReporterForCurrentThread(</div><div class="line"><a name="l00922"></a><span class="lineno"> 922</span>  TestPartResultReporterInterface* reporter);</div><div class="line"><a name="l00923"></a><span class="lineno"> 923</span> </div><div class="line"><a name="l00924"></a><span class="lineno"> 924</span>  <span class="comment">// Gets the number of successful test suites.</span></div><div class="line"><a name="l00925"></a><span class="lineno"> 925</span>  <span class="keywordtype">int</span> successful_test_suite_count() <span class="keyword">const</span>;</div><div class="line"><a name="l00926"></a><span class="lineno"> 926</span> </div><div class="line"><a name="l00927"></a><span class="lineno"> 927</span>  <span class="comment">// Gets the number of failed test suites.</span></div><div class="line"><a name="l00928"></a><span class="lineno"> 928</span>  <span class="keywordtype">int</span> failed_test_suite_count() <span class="keyword">const</span>;</div><div class="line"><a name="l00929"></a><span class="lineno"> 929</span> </div><div class="line"><a name="l00930"></a><span class="lineno"> 930</span>  <span class="comment">// Gets the number of all test suites.</span></div><div class="line"><a name="l00931"></a><span class="lineno"> 931</span>  <span class="keywordtype">int</span> total_test_suite_count() <span class="keyword">const</span>;</div><div class="line"><a name="l00932"></a><span class="lineno"> 932</span> </div><div class="line"><a name="l00933"></a><span class="lineno"> 933</span>  <span class="comment">// Gets the number of all test suites that contain at least one test</span></div><div class="line"><a name="l00934"></a><span class="lineno"> 934</span>  <span class="comment">// that should run.</span></div><div class="line"><a name="l00935"></a><span class="lineno"> 935</span>  <span class="keywordtype">int</span> test_suite_to_run_count() <span class="keyword">const</span>;</div><div class="line"><a name="l00936"></a><span class="lineno"> 936</span> </div><div class="line"><a name="l00937"></a><span class="lineno"> 937</span>  <span class="comment">// Gets the number of successful tests.</span></div><div class="line"><a name="l00938"></a><span class="lineno"> 938</span>  <span class="keywordtype">int</span> successful_test_count() <span class="keyword">const</span>;</div><div class="line"><a name="l00939"></a><span class="lineno"> 939</span> </div><div class="line"><a name="l00940"></a><span class="lineno"> 940</span>  <span class="comment">// Gets the number of skipped tests.</span></div><div class="line"><a name="l00941"></a><span class="lineno"> 941</span>  <span class="keywordtype">int</span> skipped_test_count() <span class="keyword">const</span>;</div><div class="line"><a name="l00942"></a><span class="lineno"> 942</span> </div><div class="line"><a name="l00943"></a><span class="lineno"> 943</span>  <span class="comment">// Gets the number of failed tests.</span></div><div class="line"><a name="l00944"></a><span class="lineno"> 944</span>  <span class="keywordtype">int</span> failed_test_count() <span class="keyword">const</span>;</div><div class="line"><a name="l00945"></a><span class="lineno"> 945</span> </div><div class="line"><a name="l00946"></a><span class="lineno"> 946</span>  <span class="comment">// Gets the number of disabled tests that will be reported in the XML report.</span></div><div class="line"><a name="l00947"></a><span class="lineno"> 947</span>  <span class="keywordtype">int</span> reportable_disabled_test_count() <span class="keyword">const</span>;</div><div class="line"><a name="l00948"></a><span class="lineno"> 948</span> </div><div class="line"><a name="l00949"></a><span class="lineno"> 949</span>  <span class="comment">// Gets the number of disabled tests.</span></div><div class="line"><a name="l00950"></a><span class="lineno"> 950</span>  <span class="keywordtype">int</span> disabled_test_count() <span class="keyword">const</span>;</div><div class="line"><a name="l00951"></a><span class="lineno"> 951</span> </div><div class="line"><a name="l00952"></a><span class="lineno"> 952</span>  <span class="comment">// Gets the number of tests to be printed in the XML report.</span></div><div class="line"><a name="l00953"></a><span class="lineno"> 953</span>  <span class="keywordtype">int</span> reportable_test_count() <span class="keyword">const</span>;</div><div class="line"><a name="l00954"></a><span class="lineno"> 954</span> </div><div class="line"><a name="l00955"></a><span class="lineno"> 955</span>  <span class="comment">// Gets the number of all tests.</span></div><div class="line"><a name="l00956"></a><span class="lineno"> 956</span>  <span class="keywordtype">int</span> total_test_count() <span class="keyword">const</span>;</div><div class="line"><a name="l00957"></a><span class="lineno"> 957</span> </div><div class="line"><a name="l00958"></a><span class="lineno"> 958</span>  <span class="comment">// Gets the number of tests that should run.</span></div><div class="line"><a name="l00959"></a><span class="lineno"> 959</span>  <span class="keywordtype">int</span> test_to_run_count() <span class="keyword">const</span>;</div><div class="line"><a name="l00960"></a><span class="lineno"> 960</span> </div><div class="line"><a name="l00961"></a><span class="lineno"> 961</span>  <span class="comment">// Gets the time of the test program start, in ms from the start of the</span></div><div class="line"><a name="l00962"></a><span class="lineno"> 962</span>  <span class="comment">// UNIX epoch.</span></div><div class="line"><a name="l00963"></a><span class="lineno"> 963</span>  <a class="code" href="namespacetesting_1_1internal.html#a66a845df404b38fe85c5e14a069f255a">TimeInMillis</a> start_timestamp()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> start_timestamp_; }</div><div class="line"><a name="l00964"></a><span class="lineno"> 964</span> </div><div class="line"><a name="l00965"></a><span class="lineno"> 965</span>  <span class="comment">// Gets the elapsed time, in milliseconds.</span></div><div class="line"><a name="l00966"></a><span class="lineno"> 966</span>  <a class="code" href="namespacetesting_1_1internal.html#a66a845df404b38fe85c5e14a069f255a">TimeInMillis</a> elapsed_time()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> elapsed_time_; }</div><div class="line"><a name="l00967"></a><span class="lineno"> 967</span> </div><div class="line"><a name="l00968"></a><span class="lineno"> 968</span>  <span class="comment">// Returns true iff the unit test passed (i.e. all test suites passed).</span></div><div class="line"><a name="l00969"></a><span class="lineno"> 969</span>  <span class="keywordtype">bool</span> Passed()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> !Failed(); }</div><div class="line"><a name="l00970"></a><span class="lineno"> 970</span> </div><div class="line"><a name="l00971"></a><span class="lineno"> 971</span>  <span class="comment">// Returns true iff the unit test failed (i.e. some test suite failed</span></div><div class="line"><a name="l00972"></a><span class="lineno"> 972</span>  <span class="comment">// or something outside of all tests failed).</span></div><div class="line"><a name="l00973"></a><span class="lineno"> 973</span>  <span class="keywordtype">bool</span> Failed()<span class="keyword"> const </span>{</div><div class="line"><a name="l00974"></a><span class="lineno"> 974</span>  <span class="keywordflow">return</span> failed_test_suite_count() > 0 || ad_hoc_test_result()->Failed();</div><div class="line"><a name="l00975"></a><span class="lineno"> 975</span>  }</div><div class="line"><a name="l00976"></a><span class="lineno"> 976</span> </div><div class="line"><a name="l00977"></a><span class="lineno"> 977</span>  <span class="comment">// Gets the i-th test suite among all the test suites. i can range from 0 to</span></div><div class="line"><a name="l00978"></a><span class="lineno"> 978</span>  <span class="comment">// total_test_suite_count() - 1. If i is not in that range, returns NULL.</span></div><div class="line"><a name="l00979"></a><span class="lineno"> 979</span>  <span class="keyword">const</span> TestSuite* GetTestSuite(<span class="keywordtype">int</span> i)<span class="keyword"> const </span>{</div><div class="line"><a name="l00980"></a><span class="lineno"> 980</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> index = GetElementOr(test_suite_indices_, i, -1);</div><div class="line"><a name="l00981"></a><span class="lineno"> 981</span>  <span class="keywordflow">return</span> index < 0 ? nullptr : test_suites_[i];</div><div class="line"><a name="l00982"></a><span class="lineno"> 982</span>  }</div><div class="line"><a name="l00983"></a><span class="lineno"> 983</span> </div><div class="line"><a name="l00984"></a><span class="lineno"> 984</span>  <span class="comment">// Legacy API is deprecated but still available</span></div><div class="line"><a name="l00985"></a><span class="lineno"> 985</span> <span class="preprocessor">#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_</span></div><div class="line"><a name="l00986"></a><span class="lineno"> 986</span>  <span class="keyword">const</span> TestCase* GetTestCase(<span class="keywordtype">int</span> i)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> GetTestSuite(i); }</div><div class="line"><a name="l00987"></a><span class="lineno"> 987</span> <span class="preprocessor">#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_</span></div><div class="line"><a name="l00988"></a><span class="lineno"> 988</span> </div><div class="line"><a name="l00989"></a><span class="lineno"> 989</span>  <span class="comment">// Gets the i-th test suite among all the test suites. i can range from 0 to</span></div><div class="line"><a name="l00990"></a><span class="lineno"> 990</span>  <span class="comment">// total_test_suite_count() - 1. If i is not in that range, returns NULL.</span></div><div class="line"><a name="l00991"></a><span class="lineno"> 991</span>  TestSuite* GetMutableSuiteCase(<span class="keywordtype">int</span> i) {</div><div class="line"><a name="l00992"></a><span class="lineno"> 992</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> index = GetElementOr(test_suite_indices_, i, -1);</div><div class="line"><a name="l00993"></a><span class="lineno"> 993</span>  <span class="keywordflow">return</span> index < 0 ? nullptr : test_suites_[index];</div><div class="line"><a name="l00994"></a><span class="lineno"> 994</span>  }</div><div class="line"><a name="l00995"></a><span class="lineno"> 995</span> </div><div class="line"><a name="l00996"></a><span class="lineno"> 996</span>  <span class="comment">// Provides access to the event listener list.</span></div><div class="line"><a name="l00997"></a><span class="lineno"> 997</span>  TestEventListeners* listeners() { <span class="keywordflow">return</span> &listeners_; }</div><div class="line"><a name="l00998"></a><span class="lineno"> 998</span> </div><div class="line"><a name="l00999"></a><span class="lineno"> 999</span>  <span class="comment">// Returns the TestResult for the test that's currently running, or</span></div><div class="line"><a name="l01000"></a><span class="lineno"> 1000</span>  <span class="comment">// the TestResult for the ad hoc test if no test is running.</span></div><div class="line"><a name="l01001"></a><span class="lineno"> 1001</span>  TestResult* current_test_result();</div><div class="line"><a name="l01002"></a><span class="lineno"> 1002</span> </div><div class="line"><a name="l01003"></a><span class="lineno"> 1003</span>  <span class="comment">// Returns the TestResult for the ad hoc test.</span></div><div class="line"><a name="l01004"></a><span class="lineno"> 1004</span>  <span class="keyword">const</span> TestResult* ad_hoc_test_result()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> &ad_hoc_test_result_; }</div><div class="line"><a name="l01005"></a><span class="lineno"> 1005</span> </div><div class="line"><a name="l01006"></a><span class="lineno"> 1006</span>  <span class="comment">// Sets the OS stack trace getter.</span></div><div class="line"><a name="l01007"></a><span class="lineno"> 1007</span>  <span class="comment">//</span></div><div class="line"><a name="l01008"></a><span class="lineno"> 1008</span>  <span class="comment">// Does nothing if the input and the current OS stack trace getter</span></div><div class="line"><a name="l01009"></a><span class="lineno"> 1009</span>  <span class="comment">// are the same; otherwise, deletes the old getter and makes the</span></div><div class="line"><a name="l01010"></a><span class="lineno"> 1010</span>  <span class="comment">// input the current getter.</span></div><div class="line"><a name="l01011"></a><span class="lineno"> 1011</span>  <span class="keywordtype">void</span> set_os_stack_trace_getter(OsStackTraceGetterInterface* getter);</div><div class="line"><a name="l01012"></a><span class="lineno"> 1012</span> </div><div class="line"><a name="l01013"></a><span class="lineno"> 1013</span>  <span class="comment">// Returns the current OS stack trace getter if it is not NULL;</span></div><div class="line"><a name="l01014"></a><span class="lineno"> 1014</span>  <span class="comment">// otherwise, creates an OsStackTraceGetter, makes it the current</span></div><div class="line"><a name="l01015"></a><span class="lineno"> 1015</span>  <span class="comment">// getter, and returns it.</span></div><div class="line"><a name="l01016"></a><span class="lineno"> 1016</span>  OsStackTraceGetterInterface* os_stack_trace_getter();</div><div class="line"><a name="l01017"></a><span class="lineno"> 1017</span> </div><div class="line"><a name="l01018"></a><span class="lineno"> 1018</span>  <span class="comment">// Returns the current OS stack trace as an std::string.</span></div><div class="line"><a name="l01019"></a><span class="lineno"> 1019</span>  <span class="comment">//</span></div><div class="line"><a name="l01020"></a><span class="lineno"> 1020</span>  <span class="comment">// The maximum number of stack frames to be included is specified by</span></div><div class="line"><a name="l01021"></a><span class="lineno"> 1021</span>  <span class="comment">// the gtest_stack_trace_depth flag. The skip_count parameter</span></div><div class="line"><a name="l01022"></a><span class="lineno"> 1022</span>  <span class="comment">// specifies the number of top frames to be skipped, which doesn't</span></div><div class="line"><a name="l01023"></a><span class="lineno"> 1023</span>  <span class="comment">// count against the number of frames to be included.</span></div><div class="line"><a name="l01024"></a><span class="lineno"> 1024</span>  <span class="comment">//</span></div><div class="line"><a name="l01025"></a><span class="lineno"> 1025</span>  <span class="comment">// For example, if Foo() calls Bar(), which in turn calls</span></div><div class="line"><a name="l01026"></a><span class="lineno"> 1026</span>  <span class="comment">// CurrentOsStackTraceExceptTop(1), Foo() will be included in the</span></div><div class="line"><a name="l01027"></a><span class="lineno"> 1027</span>  <span class="comment">// trace but Bar() and CurrentOsStackTraceExceptTop() won't.</span></div><div class="line"><a name="l01028"></a><span class="lineno"> 1028</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> CurrentOsStackTraceExceptTop(<span class="keywordtype">int</span> skip_count) <a class="code" href="gtest_8h.html#a9945cbd967fbccb15f8de711f58955c7">GTEST_NO_INLINE_</a>;</div><div class="line"><a name="l01029"></a><span class="lineno"> 1029</span> </div><div class="line"><a name="l01030"></a><span class="lineno"> 1030</span>  <span class="comment">// Finds and returns a TestSuite with the given name. If one doesn't</span></div><div class="line"><a name="l01031"></a><span class="lineno"> 1031</span>  <span class="comment">// exist, creates one and returns it.</span></div><div class="line"><a name="l01032"></a><span class="lineno"> 1032</span>  <span class="comment">//</span></div><div class="line"><a name="l01033"></a><span class="lineno"> 1033</span>  <span class="comment">// Arguments:</span></div><div class="line"><a name="l01034"></a><span class="lineno"> 1034</span>  <span class="comment">//</span></div><div class="line"><a name="l01035"></a><span class="lineno"> 1035</span>  <span class="comment">// test_suite_name: name of the test suite</span></div><div class="line"><a name="l01036"></a><span class="lineno"> 1036</span>  <span class="comment">// type_param: the name of the test's type parameter, or NULL if</span></div><div class="line"><a name="l01037"></a><span class="lineno"> 1037</span>  <span class="comment">// this is not a typed or a type-parameterized test.</span></div><div class="line"><a name="l01038"></a><span class="lineno"> 1038</span>  <span class="comment">// set_up_tc: pointer to the function that sets up the test suite</span></div><div class="line"><a name="l01039"></a><span class="lineno"> 1039</span>  <span class="comment">// tear_down_tc: pointer to the function that tears down the test suite</span></div><div class="line"><a name="l01040"></a><span class="lineno"> 1040</span>  TestSuite* GetTestSuite(<span class="keyword">const</span> <span class="keywordtype">char</span>* test_suite_name, <span class="keyword">const</span> <span class="keywordtype">char</span>* type_param,</div><div class="line"><a name="l01041"></a><span class="lineno"> 1041</span>  <a class="code" href="namespacetesting_1_1internal.html#a83e4e0732ac6a9dcfe6ee299dc1b9fa2">internal::SetUpTestSuiteFunc</a> set_up_tc,</div><div class="line"><a name="l01042"></a><span class="lineno"> 1042</span>  <a class="code" href="namespacetesting_1_1internal.html#a8257a87aa42cebaa54b0c48a6ae657a5">internal::TearDownTestSuiteFunc</a> tear_down_tc);</div><div class="line"><a name="l01043"></a><span class="lineno"> 1043</span> </div><div class="line"><a name="l01044"></a><span class="lineno"> 1044</span> <span class="comment">// Legacy API is deprecated but still available</span></div><div class="line"><a name="l01045"></a><span class="lineno"> 1045</span> <span class="preprocessor">#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_</span></div><div class="line"><a name="l01046"></a><span class="lineno"> 1046</span>  TestCase* GetTestCase(<span class="keyword">const</span> <span class="keywordtype">char</span>* test_case_name, <span class="keyword">const</span> <span class="keywordtype">char</span>* type_param,</div><div class="line"><a name="l01047"></a><span class="lineno"> 1047</span>  <a class="code" href="namespacetesting_1_1internal.html#a83e4e0732ac6a9dcfe6ee299dc1b9fa2">internal::SetUpTestSuiteFunc</a> set_up_tc,</div><div class="line"><a name="l01048"></a><span class="lineno"> 1048</span>  <a class="code" href="namespacetesting_1_1internal.html#a8257a87aa42cebaa54b0c48a6ae657a5">internal::TearDownTestSuiteFunc</a> tear_down_tc) {</div><div class="line"><a name="l01049"></a><span class="lineno"> 1049</span>  <span class="keywordflow">return</span> GetTestSuite(test_case_name, type_param, set_up_tc, tear_down_tc);</div><div class="line"><a name="l01050"></a><span class="lineno"> 1050</span>  }</div><div class="line"><a name="l01051"></a><span class="lineno"> 1051</span> <span class="preprocessor">#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_</span></div><div class="line"><a name="l01052"></a><span class="lineno"> 1052</span> </div><div class="line"><a name="l01053"></a><span class="lineno"> 1053</span>  <span class="comment">// Adds a TestInfo to the unit test.</span></div><div class="line"><a name="l01054"></a><span class="lineno"> 1054</span>  <span class="comment">//</span></div><div class="line"><a name="l01055"></a><span class="lineno"> 1055</span>  <span class="comment">// Arguments:</span></div><div class="line"><a name="l01056"></a><span class="lineno"> 1056</span>  <span class="comment">//</span></div><div class="line"><a name="l01057"></a><span class="lineno"> 1057</span>  <span class="comment">// set_up_tc: pointer to the function that sets up the test suite</span></div><div class="line"><a name="l01058"></a><span class="lineno"> 1058</span>  <span class="comment">// tear_down_tc: pointer to the function that tears down the test suite</span></div><div class="line"><a name="l01059"></a><span class="lineno"> 1059</span>  <span class="comment">// test_info: the TestInfo object</span></div><div class="line"><a name="l01060"></a><span class="lineno"> 1060</span>  <span class="keywordtype">void</span> AddTestInfo(<a class="code" href="namespacetesting_1_1internal.html#a83e4e0732ac6a9dcfe6ee299dc1b9fa2">internal::SetUpTestSuiteFunc</a> set_up_tc,</div><div class="line"><a name="l01061"></a><span class="lineno"> 1061</span>  <a class="code" href="namespacetesting_1_1internal.html#a8257a87aa42cebaa54b0c48a6ae657a5">internal::TearDownTestSuiteFunc</a> tear_down_tc,</div><div class="line"><a name="l01062"></a><span class="lineno"> 1062</span>  TestInfo* test_info) {</div><div class="line"><a name="l01063"></a><span class="lineno"> 1063</span>  <span class="comment">// In order to support thread-safe death tests, we need to</span></div><div class="line"><a name="l01064"></a><span class="lineno"> 1064</span>  <span class="comment">// remember the original working directory when the test program</span></div><div class="line"><a name="l01065"></a><span class="lineno"> 1065</span>  <span class="comment">// was first invoked. We cannot do this in RUN_ALL_TESTS(), as</span></div><div class="line"><a name="l01066"></a><span class="lineno"> 1066</span>  <span class="comment">// the user may have changed the current directory before calling</span></div><div class="line"><a name="l01067"></a><span class="lineno"> 1067</span>  <span class="comment">// RUN_ALL_TESTS(). Therefore we capture the current directory in</span></div><div class="line"><a name="l01068"></a><span class="lineno"> 1068</span>  <span class="comment">// AddTestInfo(), which is called to register a TEST or TEST_F</span></div><div class="line"><a name="l01069"></a><span class="lineno"> 1069</span>  <span class="comment">// before main() is reached.</span></div><div class="line"><a name="l01070"></a><span class="lineno"> 1070</span>  <span class="keywordflow">if</span> (original_working_dir_.IsEmpty()) {</div><div class="line"><a name="l01071"></a><span class="lineno"> 1071</span>  original_working_dir_.Set(FilePath::GetCurrentDir());</div><div class="line"><a name="l01072"></a><span class="lineno"> 1072</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(!original_working_dir_.IsEmpty())</div><div class="line"><a name="l01073"></a><span class="lineno"> 1073</span>  << <span class="stringliteral">"Failed to get the current working directory."</span>;</div><div class="line"><a name="l01074"></a><span class="lineno"> 1074</span>  }</div><div class="line"><a name="l01075"></a><span class="lineno"> 1075</span> </div><div class="line"><a name="l01076"></a><span class="lineno"> 1076</span>  GetTestSuite(test_info->test_suite_name(), test_info->type_param(),</div><div class="line"><a name="l01077"></a><span class="lineno"> 1077</span>  set_up_tc, tear_down_tc)</div><div class="line"><a name="l01078"></a><span class="lineno"> 1078</span>  ->AddTestInfo(test_info);</div><div class="line"><a name="l01079"></a><span class="lineno"> 1079</span>  }</div><div class="line"><a name="l01080"></a><span class="lineno"> 1080</span> </div><div class="line"><a name="l01081"></a><span class="lineno"> 1081</span>  <span class="comment">// Returns ParameterizedTestSuiteRegistry object used to keep track of</span></div><div class="line"><a name="l01082"></a><span class="lineno"> 1082</span>  <span class="comment">// value-parameterized tests and instantiate and register them.</span></div><div class="line"><a name="l01083"></a><span class="lineno"> 1083</span>  internal::ParameterizedTestSuiteRegistry& parameterized_test_registry() {</div><div class="line"><a name="l01084"></a><span class="lineno"> 1084</span>  <span class="keywordflow">return</span> parameterized_test_registry_;</div><div class="line"><a name="l01085"></a><span class="lineno"> 1085</span>  }</div><div class="line"><a name="l01086"></a><span class="lineno"> 1086</span> </div><div class="line"><a name="l01087"></a><span class="lineno"> 1087</span>  <span class="comment">// Sets the TestSuite object for the test that's currently running.</span></div><div class="line"><a name="l01088"></a><span class="lineno"> 1088</span>  <span class="keywordtype">void</span> set_current_test_suite(TestSuite* a_current_test_suite) {</div><div class="line"><a name="l01089"></a><span class="lineno"> 1089</span>  current_test_suite_ = a_current_test_suite;</div><div class="line"><a name="l01090"></a><span class="lineno"> 1090</span>  }</div><div class="line"><a name="l01091"></a><span class="lineno"> 1091</span> </div><div class="line"><a name="l01092"></a><span class="lineno"> 1092</span>  <span class="comment">// Sets the TestInfo object for the test that's currently running. If</span></div><div class="line"><a name="l01093"></a><span class="lineno"> 1093</span>  <span class="comment">// current_test_info is NULL, the assertion results will be stored in</span></div><div class="line"><a name="l01094"></a><span class="lineno"> 1094</span>  <span class="comment">// ad_hoc_test_result_.</span></div><div class="line"><a name="l01095"></a><span class="lineno"> 1095</span>  <span class="keywordtype">void</span> set_current_test_info(TestInfo* a_current_test_info) {</div><div class="line"><a name="l01096"></a><span class="lineno"> 1096</span>  current_test_info_ = a_current_test_info;</div><div class="line"><a name="l01097"></a><span class="lineno"> 1097</span>  }</div><div class="line"><a name="l01098"></a><span class="lineno"> 1098</span> </div><div class="line"><a name="l01099"></a><span class="lineno"> 1099</span>  <span class="comment">// Registers all parameterized tests defined using TEST_P and</span></div><div class="line"><a name="l01100"></a><span class="lineno"> 1100</span>  <span class="comment">// INSTANTIATE_TEST_SUITE_P, creating regular tests for each test/parameter</span></div><div class="line"><a name="l01101"></a><span class="lineno"> 1101</span>  <span class="comment">// combination. This method can be called more then once; it has guards</span></div><div class="line"><a name="l01102"></a><span class="lineno"> 1102</span>  <span class="comment">// protecting from registering the tests more then once. If</span></div><div class="line"><a name="l01103"></a><span class="lineno"> 1103</span>  <span class="comment">// value-parameterized tests are disabled, RegisterParameterizedTests is</span></div><div class="line"><a name="l01104"></a><span class="lineno"> 1104</span>  <span class="comment">// present but does nothing.</span></div><div class="line"><a name="l01105"></a><span class="lineno"> 1105</span>  <span class="keywordtype">void</span> RegisterParameterizedTests();</div><div class="line"><a name="l01106"></a><span class="lineno"> 1106</span> </div><div class="line"><a name="l01107"></a><span class="lineno"> 1107</span>  <span class="comment">// Runs all tests in this UnitTest object, prints the result, and</span></div><div class="line"><a name="l01108"></a><span class="lineno"> 1108</span>  <span class="comment">// returns true if all tests are successful. If any exception is</span></div><div class="line"><a name="l01109"></a><span class="lineno"> 1109</span>  <span class="comment">// thrown during a test, this test is considered to be failed, but</span></div><div class="line"><a name="l01110"></a><span class="lineno"> 1110</span>  <span class="comment">// the rest of the tests will still be run.</span></div><div class="line"><a name="l01111"></a><span class="lineno"> 1111</span>  <span class="keywordtype">bool</span> RunAllTests();</div><div class="line"><a name="l01112"></a><span class="lineno"> 1112</span> </div><div class="line"><a name="l01113"></a><span class="lineno"> 1113</span>  <span class="comment">// Clears the results of all tests, except the ad hoc tests.</span></div><div class="line"><a name="l01114"></a><span class="lineno"> 1114</span>  <span class="keywordtype">void</span> ClearNonAdHocTestResult() {</div><div class="line"><a name="l01115"></a><span class="lineno"> 1115</span>  ForEach(test_suites_, TestSuite::ClearTestSuiteResult);</div><div class="line"><a name="l01116"></a><span class="lineno"> 1116</span>  }</div><div class="line"><a name="l01117"></a><span class="lineno"> 1117</span> </div><div class="line"><a name="l01118"></a><span class="lineno"> 1118</span>  <span class="comment">// Clears the results of ad-hoc test assertions.</span></div><div class="line"><a name="l01119"></a><span class="lineno"> 1119</span>  <span class="keywordtype">void</span> ClearAdHocTestResult() {</div><div class="line"><a name="l01120"></a><span class="lineno"> 1120</span>  ad_hoc_test_result_.Clear();</div><div class="line"><a name="l01121"></a><span class="lineno"> 1121</span>  }</div><div class="line"><a name="l01122"></a><span class="lineno"> 1122</span> </div><div class="line"><a name="l01123"></a><span class="lineno"> 1123</span>  <span class="comment">// Adds a TestProperty to the current TestResult object when invoked in a</span></div><div class="line"><a name="l01124"></a><span class="lineno"> 1124</span>  <span class="comment">// context of a test or a test suite, or to the global property set. If the</span></div><div class="line"><a name="l01125"></a><span class="lineno"> 1125</span>  <span class="comment">// result already contains a property with the same key, the value will be</span></div><div class="line"><a name="l01126"></a><span class="lineno"> 1126</span>  <span class="comment">// updated.</span></div><div class="line"><a name="l01127"></a><span class="lineno"> 1127</span>  <span class="keywordtype">void</span> RecordProperty(<span class="keyword">const</span> TestProperty& test_property);</div><div class="line"><a name="l01128"></a><span class="lineno"> 1128</span> </div><div class="line"><a name="l01129"></a><span class="lineno"> 1129</span>  <span class="keyword">enum</span> ReactionToSharding {</div><div class="line"><a name="l01130"></a><span class="lineno"> 1130</span>  HONOR_SHARDING_PROTOCOL,</div><div class="line"><a name="l01131"></a><span class="lineno"> 1131</span>  IGNORE_SHARDING_PROTOCOL</div><div class="line"><a name="l01132"></a><span class="lineno"> 1132</span>  };</div><div class="line"><a name="l01133"></a><span class="lineno"> 1133</span> </div><div class="line"><a name="l01134"></a><span class="lineno"> 1134</span>  <span class="comment">// Matches the full name of each test against the user-specified</span></div><div class="line"><a name="l01135"></a><span class="lineno"> 1135</span>  <span class="comment">// filter to decide whether the test should run, then records the</span></div><div class="line"><a name="l01136"></a><span class="lineno"> 1136</span>  <span class="comment">// result in each TestSuite and TestInfo object.</span></div><div class="line"><a name="l01137"></a><span class="lineno"> 1137</span>  <span class="comment">// If shard_tests == HONOR_SHARDING_PROTOCOL, further filters tests</span></div><div class="line"><a name="l01138"></a><span class="lineno"> 1138</span>  <span class="comment">// based on sharding variables in the environment.</span></div><div class="line"><a name="l01139"></a><span class="lineno"> 1139</span>  <span class="comment">// Returns the number of tests that should run.</span></div><div class="line"><a name="l01140"></a><span class="lineno"> 1140</span>  <span class="keywordtype">int</span> FilterTests(ReactionToSharding shard_tests);</div><div class="line"><a name="l01141"></a><span class="lineno"> 1141</span> </div><div class="line"><a name="l01142"></a><span class="lineno"> 1142</span>  <span class="comment">// Prints the names of the tests matching the user-specified filter flag.</span></div><div class="line"><a name="l01143"></a><span class="lineno"> 1143</span>  <span class="keywordtype">void</span> ListTestsMatchingFilter();</div><div class="line"><a name="l01144"></a><span class="lineno"> 1144</span> </div><div class="line"><a name="l01145"></a><span class="lineno"> 1145</span>  <span class="keyword">const</span> TestSuite* current_test_suite()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> current_test_suite_; }</div><div class="line"><a name="l01146"></a><span class="lineno"> 1146</span>  TestInfo* current_test_info() { <span class="keywordflow">return</span> current_test_info_; }</div><div class="line"><a name="l01147"></a><span class="lineno"> 1147</span>  <span class="keyword">const</span> TestInfo* current_test_info()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> current_test_info_; }</div><div class="line"><a name="l01148"></a><span class="lineno"> 1148</span> </div><div class="line"><a name="l01149"></a><span class="lineno"> 1149</span>  <span class="comment">// Returns the vector of environments that need to be set-up/torn-down</span></div><div class="line"><a name="l01150"></a><span class="lineno"> 1150</span>  <span class="comment">// before/after the tests are run.</span></div><div class="line"><a name="l01151"></a><span class="lineno"> 1151</span>  std::vector<Environment*>& environments() { <span class="keywordflow">return</span> environments_; }</div><div class="line"><a name="l01152"></a><span class="lineno"> 1152</span> </div><div class="line"><a name="l01153"></a><span class="lineno"> 1153</span>  <span class="comment">// Getters for the per-thread Google Test trace stack.</span></div><div class="line"><a name="l01154"></a><span class="lineno"> 1154</span>  std::vector<TraceInfo>& gtest_trace_stack() {</div><div class="line"><a name="l01155"></a><span class="lineno"> 1155</span>  <span class="keywordflow">return</span> *(gtest_trace_stack_.pointer());</div><div class="line"><a name="l01156"></a><span class="lineno"> 1156</span>  }</div><div class="line"><a name="l01157"></a><span class="lineno"> 1157</span>  <span class="keyword">const</span> std::vector<TraceInfo>& gtest_trace_stack()<span class="keyword"> const </span>{</div><div class="line"><a name="l01158"></a><span class="lineno"> 1158</span>  <span class="keywordflow">return</span> gtest_trace_stack_.get();</div><div class="line"><a name="l01159"></a><span class="lineno"> 1159</span>  }</div><div class="line"><a name="l01160"></a><span class="lineno"> 1160</span> </div><div class="line"><a name="l01161"></a><span class="lineno"> 1161</span> <span class="preprocessor">#if GTEST_HAS_DEATH_TEST</span></div><div class="line"><a name="l01162"></a><span class="lineno"> 1162</span>  <span class="keywordtype">void</span> InitDeathTestSubprocessControlInfo() {</div><div class="line"><a name="l01163"></a><span class="lineno"> 1163</span>  internal_run_death_test_flag_.reset(ParseInternalRunDeathTestFlag());</div><div class="line"><a name="l01164"></a><span class="lineno"> 1164</span>  }</div><div class="line"><a name="l01165"></a><span class="lineno"> 1165</span>  <span class="comment">// Returns a pointer to the parsed --gtest_internal_run_death_test</span></div><div class="line"><a name="l01166"></a><span class="lineno"> 1166</span>  <span class="comment">// flag, or NULL if that flag was not specified.</span></div><div class="line"><a name="l01167"></a><span class="lineno"> 1167</span>  <span class="comment">// This information is useful only in a death test child process.</span></div><div class="line"><a name="l01168"></a><span class="lineno"> 1168</span>  <span class="comment">// Must not be called before a call to InitGoogleTest.</span></div><div class="line"><a name="l01169"></a><span class="lineno"> 1169</span>  <span class="keyword">const</span> InternalRunDeathTestFlag* internal_run_death_test_flag()<span class="keyword"> const </span>{</div><div class="line"><a name="l01170"></a><span class="lineno"> 1170</span>  <span class="keywordflow">return</span> internal_run_death_test_flag_.get();</div><div class="line"><a name="l01171"></a><span class="lineno"> 1171</span>  }</div><div class="line"><a name="l01172"></a><span class="lineno"> 1172</span> </div><div class="line"><a name="l01173"></a><span class="lineno"> 1173</span>  <span class="comment">// Returns a pointer to the current death test factory.</span></div><div class="line"><a name="l01174"></a><span class="lineno"> 1174</span>  internal::DeathTestFactory* death_test_factory() {</div><div class="line"><a name="l01175"></a><span class="lineno"> 1175</span>  <span class="keywordflow">return</span> death_test_factory_.get();</div><div class="line"><a name="l01176"></a><span class="lineno"> 1176</span>  }</div><div class="line"><a name="l01177"></a><span class="lineno"> 1177</span> </div><div class="line"><a name="l01178"></a><span class="lineno"> 1178</span>  <span class="keywordtype">void</span> SuppressTestEventsIfInSubprocess();</div><div class="line"><a name="l01179"></a><span class="lineno"> 1179</span> </div><div class="line"><a name="l01180"></a><span class="lineno"> 1180</span>  <span class="keyword">friend</span> <span class="keyword">class </span>ReplaceDeathTestFactory;</div><div class="line"><a name="l01181"></a><span class="lineno"> 1181</span> <span class="preprocessor">#endif // GTEST_HAS_DEATH_TEST</span></div><div class="line"><a name="l01182"></a><span class="lineno"> 1182</span> </div><div class="line"><a name="l01183"></a><span class="lineno"> 1183</span>  <span class="comment">// Initializes the event listener performing XML output as specified by</span></div><div class="line"><a name="l01184"></a><span class="lineno"> 1184</span>  <span class="comment">// UnitTestOptions. Must not be called before InitGoogleTest.</span></div><div class="line"><a name="l01185"></a><span class="lineno"> 1185</span>  <span class="keywordtype">void</span> ConfigureXmlOutput();</div><div class="line"><a name="l01186"></a><span class="lineno"> 1186</span> </div><div class="line"><a name="l01187"></a><span class="lineno"> 1187</span> <span class="preprocessor">#if GTEST_CAN_STREAM_RESULTS_</span></div><div class="line"><a name="l01188"></a><span class="lineno"> 1188</span>  <span class="comment">// Initializes the event listener for streaming test results to a socket.</span></div><div class="line"><a name="l01189"></a><span class="lineno"> 1189</span>  <span class="comment">// Must not be called before InitGoogleTest.</span></div><div class="line"><a name="l01190"></a><span class="lineno"> 1190</span>  <span class="keywordtype">void</span> ConfigureStreamingOutput();</div><div class="line"><a name="l01191"></a><span class="lineno"> 1191</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l01192"></a><span class="lineno"> 1192</span> </div><div class="line"><a name="l01193"></a><span class="lineno"> 1193</span>  <span class="comment">// Performs initialization dependent upon flag values obtained in</span></div><div class="line"><a name="l01194"></a><span class="lineno"> 1194</span>  <span class="comment">// ParseGoogleTestFlagsOnly. Is called from InitGoogleTest after the call to</span></div><div class="line"><a name="l01195"></a><span class="lineno"> 1195</span>  <span class="comment">// ParseGoogleTestFlagsOnly. In case a user neglects to call InitGoogleTest</span></div><div class="line"><a name="l01196"></a><span class="lineno"> 1196</span>  <span class="comment">// this function is also called from RunAllTests. Since this function can be</span></div><div class="line"><a name="l01197"></a><span class="lineno"> 1197</span>  <span class="comment">// called more than once, it has to be idempotent.</span></div><div class="line"><a name="l01198"></a><span class="lineno"> 1198</span>  <span class="keywordtype">void</span> PostFlagParsingInit();</div><div class="line"><a name="l01199"></a><span class="lineno"> 1199</span> </div><div class="line"><a name="l01200"></a><span class="lineno"> 1200</span>  <span class="comment">// Gets the random seed used at the start of the current test iteration.</span></div><div class="line"><a name="l01201"></a><span class="lineno"> 1201</span>  <span class="keywordtype">int</span> random_seed()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> random_seed_; }</div><div class="line"><a name="l01202"></a><span class="lineno"> 1202</span> </div><div class="line"><a name="l01203"></a><span class="lineno"> 1203</span>  <span class="comment">// Gets the random number generator.</span></div><div class="line"><a name="l01204"></a><span class="lineno"> 1204</span>  internal::Random* random() { <span class="keywordflow">return</span> &random_; }</div><div class="line"><a name="l01205"></a><span class="lineno"> 1205</span> </div><div class="line"><a name="l01206"></a><span class="lineno"> 1206</span>  <span class="comment">// Shuffles all test suites, and the tests within each test suite,</span></div><div class="line"><a name="l01207"></a><span class="lineno"> 1207</span>  <span class="comment">// making sure that death tests are still run first.</span></div><div class="line"><a name="l01208"></a><span class="lineno"> 1208</span>  <span class="keywordtype">void</span> ShuffleTests();</div><div class="line"><a name="l01209"></a><span class="lineno"> 1209</span> </div><div class="line"><a name="l01210"></a><span class="lineno"> 1210</span>  <span class="comment">// Restores the test suites and tests to their order before the first shuffle.</span></div><div class="line"><a name="l01211"></a><span class="lineno"> 1211</span>  <span class="keywordtype">void</span> UnshuffleTests();</div><div class="line"><a name="l01212"></a><span class="lineno"> 1212</span> </div><div class="line"><a name="l01213"></a><span class="lineno"> 1213</span>  <span class="comment">// Returns the value of GTEST_FLAG(catch_exceptions) at the moment</span></div><div class="line"><a name="l01214"></a><span class="lineno"> 1214</span>  <span class="comment">// UnitTest::Run() starts.</span></div><div class="line"><a name="l01215"></a><span class="lineno"> 1215</span>  <span class="keywordtype">bool</span> catch_exceptions()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> catch_exceptions_; }</div><div class="line"><a name="l01216"></a><span class="lineno"> 1216</span> </div><div class="line"><a name="l01217"></a><span class="lineno"> 1217</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l01218"></a><span class="lineno"> 1218</span>  <span class="keyword">friend</span> class ::testing::UnitTest;</div><div class="line"><a name="l01219"></a><span class="lineno"> 1219</span> </div><div class="line"><a name="l01220"></a><span class="lineno"> 1220</span>  <span class="comment">// Used by UnitTest::Run() to capture the state of</span></div><div class="line"><a name="l01221"></a><span class="lineno"> 1221</span>  <span class="comment">// GTEST_FLAG(catch_exceptions) at the moment it starts.</span></div><div class="line"><a name="l01222"></a><span class="lineno"> 1222</span>  <span class="keywordtype">void</span> set_catch_exceptions(<span class="keywordtype">bool</span> value) { catch_exceptions_ = value; }</div><div class="line"><a name="l01223"></a><span class="lineno"> 1223</span> </div><div class="line"><a name="l01224"></a><span class="lineno"> 1224</span>  <span class="comment">// The UnitTest object that owns this implementation object.</span></div><div class="line"><a name="l01225"></a><span class="lineno"> 1225</span>  UnitTest* <span class="keyword">const</span> parent_;</div><div class="line"><a name="l01226"></a><span class="lineno"> 1226</span> </div><div class="line"><a name="l01227"></a><span class="lineno"> 1227</span>  <span class="comment">// The working directory when the first TEST() or TEST_F() was</span></div><div class="line"><a name="l01228"></a><span class="lineno"> 1228</span>  <span class="comment">// executed.</span></div><div class="line"><a name="l01229"></a><span class="lineno"> 1229</span>  internal::FilePath original_working_dir_;</div><div class="line"><a name="l01230"></a><span class="lineno"> 1230</span> </div><div class="line"><a name="l01231"></a><span class="lineno"> 1231</span>  <span class="comment">// The default test part result reporters.</span></div><div class="line"><a name="l01232"></a><span class="lineno"> 1232</span>  DefaultGlobalTestPartResultReporter default_global_test_part_result_reporter_;</div><div class="line"><a name="l01233"></a><span class="lineno"> 1233</span>  DefaultPerThreadTestPartResultReporter</div><div class="line"><a name="l01234"></a><span class="lineno"> 1234</span>  default_per_thread_test_part_result_reporter_;</div><div class="line"><a name="l01235"></a><span class="lineno"> 1235</span> </div><div class="line"><a name="l01236"></a><span class="lineno"> 1236</span>  <span class="comment">// Points to (but doesn't own) the global test part result reporter.</span></div><div class="line"><a name="l01237"></a><span class="lineno"> 1237</span>  TestPartResultReporterInterface* global_test_part_result_repoter_;</div><div class="line"><a name="l01238"></a><span class="lineno"> 1238</span> </div><div class="line"><a name="l01239"></a><span class="lineno"> 1239</span>  <span class="comment">// Protects read and write access to global_test_part_result_reporter_.</span></div><div class="line"><a name="l01240"></a><span class="lineno"> 1240</span>  internal::Mutex global_test_part_result_reporter_mutex_;</div><div class="line"><a name="l01241"></a><span class="lineno"> 1241</span> </div><div class="line"><a name="l01242"></a><span class="lineno"> 1242</span>  <span class="comment">// Points to (but doesn't own) the per-thread test part result reporter.</span></div><div class="line"><a name="l01243"></a><span class="lineno"> 1243</span>  internal::ThreadLocal<TestPartResultReporterInterface*></div><div class="line"><a name="l01244"></a><span class="lineno"> 1244</span>  per_thread_test_part_result_reporter_;</div><div class="line"><a name="l01245"></a><span class="lineno"> 1245</span> </div><div class="line"><a name="l01246"></a><span class="lineno"> 1246</span>  <span class="comment">// The vector of environments that need to be set-up/torn-down</span></div><div class="line"><a name="l01247"></a><span class="lineno"> 1247</span>  <span class="comment">// before/after the tests are run.</span></div><div class="line"><a name="l01248"></a><span class="lineno"> 1248</span>  std::vector<Environment*> environments_;</div><div class="line"><a name="l01249"></a><span class="lineno"> 1249</span> </div><div class="line"><a name="l01250"></a><span class="lineno"> 1250</span>  <span class="comment">// The vector of TestSuites in their original order. It owns the</span></div><div class="line"><a name="l01251"></a><span class="lineno"> 1251</span>  <span class="comment">// elements in the vector.</span></div><div class="line"><a name="l01252"></a><span class="lineno"> 1252</span>  std::vector<TestSuite*> test_suites_;</div><div class="line"><a name="l01253"></a><span class="lineno"> 1253</span> </div><div class="line"><a name="l01254"></a><span class="lineno"> 1254</span>  <span class="comment">// Provides a level of indirection for the test suite list to allow</span></div><div class="line"><a name="l01255"></a><span class="lineno"> 1255</span>  <span class="comment">// easy shuffling and restoring the test suite order. The i-th</span></div><div class="line"><a name="l01256"></a><span class="lineno"> 1256</span>  <span class="comment">// element of this vector is the index of the i-th test suite in the</span></div><div class="line"><a name="l01257"></a><span class="lineno"> 1257</span>  <span class="comment">// shuffled order.</span></div><div class="line"><a name="l01258"></a><span class="lineno"> 1258</span>  std::vector<int> test_suite_indices_;</div><div class="line"><a name="l01259"></a><span class="lineno"> 1259</span> </div><div class="line"><a name="l01260"></a><span class="lineno"> 1260</span>  <span class="comment">// ParameterizedTestRegistry object used to register value-parameterized</span></div><div class="line"><a name="l01261"></a><span class="lineno"> 1261</span>  <span class="comment">// tests.</span></div><div class="line"><a name="l01262"></a><span class="lineno"> 1262</span>  internal::ParameterizedTestSuiteRegistry parameterized_test_registry_;</div><div class="line"><a name="l01263"></a><span class="lineno"> 1263</span> </div><div class="line"><a name="l01264"></a><span class="lineno"> 1264</span>  <span class="comment">// Indicates whether RegisterParameterizedTests() has been called already.</span></div><div class="line"><a name="l01265"></a><span class="lineno"> 1265</span>  <span class="keywordtype">bool</span> parameterized_tests_registered_;</div><div class="line"><a name="l01266"></a><span class="lineno"> 1266</span> </div><div class="line"><a name="l01267"></a><span class="lineno"> 1267</span>  <span class="comment">// Index of the last death test suite registered. Initially -1.</span></div><div class="line"><a name="l01268"></a><span class="lineno"> 1268</span>  <span class="keywordtype">int</span> last_death_test_suite_;</div><div class="line"><a name="l01269"></a><span class="lineno"> 1269</span> </div><div class="line"><a name="l01270"></a><span class="lineno"> 1270</span>  <span class="comment">// This points to the TestSuite for the currently running test. It</span></div><div class="line"><a name="l01271"></a><span class="lineno"> 1271</span>  <span class="comment">// changes as Google Test goes through one test suite after another.</span></div><div class="line"><a name="l01272"></a><span class="lineno"> 1272</span>  <span class="comment">// When no test is running, this is set to NULL and Google Test</span></div><div class="line"><a name="l01273"></a><span class="lineno"> 1273</span>  <span class="comment">// stores assertion results in ad_hoc_test_result_. Initially NULL.</span></div><div class="line"><a name="l01274"></a><span class="lineno"> 1274</span>  TestSuite* current_test_suite_;</div><div class="line"><a name="l01275"></a><span class="lineno"> 1275</span> </div><div class="line"><a name="l01276"></a><span class="lineno"> 1276</span>  <span class="comment">// This points to the TestInfo for the currently running test. It</span></div><div class="line"><a name="l01277"></a><span class="lineno"> 1277</span>  <span class="comment">// changes as Google Test goes through one test after another. When</span></div><div class="line"><a name="l01278"></a><span class="lineno"> 1278</span>  <span class="comment">// no test is running, this is set to NULL and Google Test stores</span></div><div class="line"><a name="l01279"></a><span class="lineno"> 1279</span>  <span class="comment">// assertion results in ad_hoc_test_result_. Initially NULL.</span></div><div class="line"><a name="l01280"></a><span class="lineno"> 1280</span>  TestInfo* current_test_info_;</div><div class="line"><a name="l01281"></a><span class="lineno"> 1281</span> </div><div class="line"><a name="l01282"></a><span class="lineno"> 1282</span>  <span class="comment">// Normally, a user only writes assertions inside a TEST or TEST_F,</span></div><div class="line"><a name="l01283"></a><span class="lineno"> 1283</span>  <span class="comment">// or inside a function called by a TEST or TEST_F. Since Google</span></div><div class="line"><a name="l01284"></a><span class="lineno"> 1284</span>  <span class="comment">// Test keeps track of which test is current running, it can</span></div><div class="line"><a name="l01285"></a><span class="lineno"> 1285</span>  <span class="comment">// associate such an assertion with the test it belongs to.</span></div><div class="line"><a name="l01286"></a><span class="lineno"> 1286</span>  <span class="comment">//</span></div><div class="line"><a name="l01287"></a><span class="lineno"> 1287</span>  <span class="comment">// If an assertion is encountered when no TEST or TEST_F is running,</span></div><div class="line"><a name="l01288"></a><span class="lineno"> 1288</span>  <span class="comment">// Google Test attributes the assertion result to an imaginary "ad hoc"</span></div><div class="line"><a name="l01289"></a><span class="lineno"> 1289</span>  <span class="comment">// test, and records the result in ad_hoc_test_result_.</span></div><div class="line"><a name="l01290"></a><span class="lineno"> 1290</span>  TestResult ad_hoc_test_result_;</div><div class="line"><a name="l01291"></a><span class="lineno"> 1291</span> </div><div class="line"><a name="l01292"></a><span class="lineno"> 1292</span>  <span class="comment">// The list of event listeners that can be used to track events inside</span></div><div class="line"><a name="l01293"></a><span class="lineno"> 1293</span>  <span class="comment">// Google Test.</span></div><div class="line"><a name="l01294"></a><span class="lineno"> 1294</span>  TestEventListeners listeners_;</div><div class="line"><a name="l01295"></a><span class="lineno"> 1295</span> </div><div class="line"><a name="l01296"></a><span class="lineno"> 1296</span>  <span class="comment">// The OS stack trace getter. Will be deleted when the UnitTest</span></div><div class="line"><a name="l01297"></a><span class="lineno"> 1297</span>  <span class="comment">// object is destructed. By default, an OsStackTraceGetter is used,</span></div><div class="line"><a name="l01298"></a><span class="lineno"> 1298</span>  <span class="comment">// but the user can set this field to use a custom getter if that is</span></div><div class="line"><a name="l01299"></a><span class="lineno"> 1299</span>  <span class="comment">// desired.</span></div><div class="line"><a name="l01300"></a><span class="lineno"> 1300</span>  OsStackTraceGetterInterface* os_stack_trace_getter_;</div><div class="line"><a name="l01301"></a><span class="lineno"> 1301</span> </div><div class="line"><a name="l01302"></a><span class="lineno"> 1302</span>  <span class="comment">// True iff PostFlagParsingInit() has been called.</span></div><div class="line"><a name="l01303"></a><span class="lineno"> 1303</span>  <span class="keywordtype">bool</span> post_flag_parse_init_performed_;</div><div class="line"><a name="l01304"></a><span class="lineno"> 1304</span> </div><div class="line"><a name="l01305"></a><span class="lineno"> 1305</span>  <span class="comment">// The random number seed used at the beginning of the test run.</span></div><div class="line"><a name="l01306"></a><span class="lineno"> 1306</span>  <span class="keywordtype">int</span> random_seed_;</div><div class="line"><a name="l01307"></a><span class="lineno"> 1307</span> </div><div class="line"><a name="l01308"></a><span class="lineno"> 1308</span>  <span class="comment">// Our random number generator.</span></div><div class="line"><a name="l01309"></a><span class="lineno"> 1309</span>  internal::Random random_;</div><div class="line"><a name="l01310"></a><span class="lineno"> 1310</span> </div><div class="line"><a name="l01311"></a><span class="lineno"> 1311</span>  <span class="comment">// The time of the test program start, in ms from the start of the</span></div><div class="line"><a name="l01312"></a><span class="lineno"> 1312</span>  <span class="comment">// UNIX epoch.</span></div><div class="line"><a name="l01313"></a><span class="lineno"> 1313</span>  <a class="code" href="namespacetesting_1_1internal.html#a66a845df404b38fe85c5e14a069f255a">TimeInMillis</a> start_timestamp_;</div><div class="line"><a name="l01314"></a><span class="lineno"> 1314</span> </div><div class="line"><a name="l01315"></a><span class="lineno"> 1315</span>  <span class="comment">// How long the test took to run, in milliseconds.</span></div><div class="line"><a name="l01316"></a><span class="lineno"> 1316</span>  <a class="code" href="namespacetesting_1_1internal.html#a66a845df404b38fe85c5e14a069f255a">TimeInMillis</a> elapsed_time_;</div><div class="line"><a name="l01317"></a><span class="lineno"> 1317</span> </div><div class="line"><a name="l01318"></a><span class="lineno"> 1318</span> <span class="preprocessor">#if GTEST_HAS_DEATH_TEST</span></div><div class="line"><a name="l01319"></a><span class="lineno"> 1319</span>  <span class="comment">// The decomposed components of the gtest_internal_run_death_test flag,</span></div><div class="line"><a name="l01320"></a><span class="lineno"> 1320</span>  <span class="comment">// parsed when RUN_ALL_TESTS is called.</span></div><div class="line"><a name="l01321"></a><span class="lineno"> 1321</span>  std::unique_ptr<InternalRunDeathTestFlag> internal_run_death_test_flag_;</div><div class="line"><a name="l01322"></a><span class="lineno"> 1322</span>  std::unique_ptr<internal::DeathTestFactory> death_test_factory_;</div><div class="line"><a name="l01323"></a><span class="lineno"> 1323</span> <span class="preprocessor">#endif // GTEST_HAS_DEATH_TEST</span></div><div class="line"><a name="l01324"></a><span class="lineno"> 1324</span> </div><div class="line"><a name="l01325"></a><span class="lineno"> 1325</span>  <span class="comment">// A per-thread stack of traces created by the SCOPED_TRACE() macro.</span></div><div class="line"><a name="l01326"></a><span class="lineno"> 1326</span>  internal::ThreadLocal<std::vector<TraceInfo> > gtest_trace_stack_;</div><div class="line"><a name="l01327"></a><span class="lineno"> 1327</span> </div><div class="line"><a name="l01328"></a><span class="lineno"> 1328</span>  <span class="comment">// The value of GTEST_FLAG(catch_exceptions) at the moment RunAllTests()</span></div><div class="line"><a name="l01329"></a><span class="lineno"> 1329</span>  <span class="comment">// starts.</span></div><div class="line"><a name="l01330"></a><span class="lineno"> 1330</span>  <span class="keywordtype">bool</span> catch_exceptions_;</div><div class="line"><a name="l01331"></a><span class="lineno"> 1331</span> </div><div class="line"><a name="l01332"></a><span class="lineno"> 1332</span>  <a class="code" href="gtest_8h.html#aed8c1888c32b588b0681e88b95031e29">GTEST_DISALLOW_COPY_AND_ASSIGN_</a>(UnitTestImpl);</div><div class="line"><a name="l01333"></a><span class="lineno"> 1333</span> }; <span class="comment">// class UnitTestImpl</span></div><div class="line"><a name="l01334"></a><span class="lineno"> 1334</span> </div><div class="line"><a name="l01335"></a><span class="lineno"> 1335</span> <span class="comment">// Convenience function for accessing the global UnitTest</span></div><div class="line"><a name="l01336"></a><span class="lineno"> 1336</span> <span class="comment">// implementation object.</span></div><div class="line"><a name="l01337"></a><span class="lineno"> 1337</span> <span class="keyword">inline</span> UnitTestImpl* GetUnitTestImpl() {</div><div class="line"><a name="l01338"></a><span class="lineno"> 1338</span>  <span class="keywordflow">return</span> UnitTest::GetInstance()->impl();</div><div class="line"><a name="l01339"></a><span class="lineno"> 1339</span> }</div><div class="line"><a name="l01340"></a><span class="lineno"> 1340</span> </div><div class="line"><a name="l01341"></a><span class="lineno"> 1341</span> <span class="preprocessor">#if GTEST_USES_SIMPLE_RE</span></div><div class="line"><a name="l01342"></a><span class="lineno"> 1342</span> </div><div class="line"><a name="l01343"></a><span class="lineno"> 1343</span> <span class="comment">// Internal helper functions for implementing the simple regular</span></div><div class="line"><a name="l01344"></a><span class="lineno"> 1344</span> <span class="comment">// expression matcher.</span></div><div class="line"><a name="l01345"></a><span class="lineno"> 1345</span> <a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> <span class="keywordtype">bool</span> IsInSet(<span class="keywordtype">char</span> ch, <span class="keyword">const</span> <span class="keywordtype">char</span>* str);</div><div class="line"><a name="l01346"></a><span class="lineno"> 1346</span> <a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> <span class="keywordtype">bool</span> IsAsciiDigit(<span class="keywordtype">char</span> ch);</div><div class="line"><a name="l01347"></a><span class="lineno"> 1347</span> <a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> <span class="keywordtype">bool</span> IsAsciiPunct(<span class="keywordtype">char</span> ch);</div><div class="line"><a name="l01348"></a><span class="lineno"> 1348</span> <a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> <span class="keywordtype">bool</span> IsRepeat(<span class="keywordtype">char</span> ch);</div><div class="line"><a name="l01349"></a><span class="lineno"> 1349</span> <a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> <span class="keywordtype">bool</span> IsAsciiWhiteSpace(<span class="keywordtype">char</span> ch);</div><div class="line"><a name="l01350"></a><span class="lineno"> 1350</span> <a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> <span class="keywordtype">bool</span> IsAsciiWordChar(<span class="keywordtype">char</span> ch);</div><div class="line"><a name="l01351"></a><span class="lineno"> 1351</span> <a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> <span class="keywordtype">bool</span> IsValidEscape(<span class="keywordtype">char</span> ch);</div><div class="line"><a name="l01352"></a><span class="lineno"> 1352</span> <a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> <span class="keywordtype">bool</span> AtomMatchesChar(<span class="keywordtype">bool</span> escaped, <span class="keywordtype">char</span> pattern, <span class="keywordtype">char</span> ch);</div><div class="line"><a name="l01353"></a><span class="lineno"> 1353</span> <a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> <span class="keywordtype">bool</span> ValidateRegex(<span class="keyword">const</span> <span class="keywordtype">char</span>* regex);</div><div class="line"><a name="l01354"></a><span class="lineno"> 1354</span> <a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> <span class="keywordtype">bool</span> MatchRegexAtHead(<span class="keyword">const</span> <span class="keywordtype">char</span>* regex, <span class="keyword">const</span> <span class="keywordtype">char</span>* str);</div><div class="line"><a name="l01355"></a><span class="lineno"> 1355</span> <a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> <span class="keywordtype">bool</span> MatchRepetitionAndRegexAtHead(</div><div class="line"><a name="l01356"></a><span class="lineno"> 1356</span>  <span class="keywordtype">bool</span> escaped, <span class="keywordtype">char</span> ch, <span class="keywordtype">char</span> <a class="code" href="namespaceutl_1_1meta.html#aa013c45afb59b5c132a72be54ba145fb">repeat</a>, <span class="keyword">const</span> <span class="keywordtype">char</span>* regex, <span class="keyword">const</span> <span class="keywordtype">char</span>* str);</div><div class="line"><a name="l01357"></a><span class="lineno"> 1357</span> <a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> <span class="keywordtype">bool</span> MatchRegexAnywhere(<span class="keyword">const</span> <span class="keywordtype">char</span>* regex, <span class="keyword">const</span> <span class="keywordtype">char</span>* str);</div><div class="line"><a name="l01358"></a><span class="lineno"> 1358</span> </div><div class="line"><a name="l01359"></a><span class="lineno"> 1359</span> <span class="preprocessor">#endif // GTEST_USES_SIMPLE_RE</span></div><div class="line"><a name="l01360"></a><span class="lineno"> 1360</span> </div><div class="line"><a name="l01361"></a><span class="lineno"> 1361</span> <span class="comment">// Parses the command line for Google Test flags, without initializing</span></div><div class="line"><a name="l01362"></a><span class="lineno"> 1362</span> <span class="comment">// other parts of Google Test.</span></div><div class="line"><a name="l01363"></a><span class="lineno"> 1363</span> <a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> <span class="keywordtype">void</span> ParseGoogleTestFlagsOnly(<span class="keywordtype">int</span>* argc, <span class="keywordtype">char</span>** argv);</div><div class="line"><a name="l01364"></a><span class="lineno"> 1364</span> <a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> <span class="keywordtype">void</span> ParseGoogleTestFlagsOnly(<span class="keywordtype">int</span>* argc, <span class="keywordtype">wchar_t</span>** argv);</div><div class="line"><a name="l01365"></a><span class="lineno"> 1365</span> </div><div class="line"><a name="l01366"></a><span class="lineno"> 1366</span> <span class="preprocessor">#if GTEST_HAS_DEATH_TEST</span></div><div class="line"><a name="l01367"></a><span class="lineno"> 1367</span> </div><div class="line"><a name="l01368"></a><span class="lineno"> 1368</span> <span class="comment">// Returns the message describing the last system error, regardless of the</span></div><div class="line"><a name="l01369"></a><span class="lineno"> 1369</span> <span class="comment">// platform.</span></div><div class="line"><a name="l01370"></a><span class="lineno"> 1370</span> <a class="code" href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> GetLastErrnoDescription();</div><div class="line"><a name="l01371"></a><span class="lineno"> 1371</span> </div><div class="line"><a name="l01372"></a><span class="lineno"> 1372</span> <span class="comment">// Attempts to parse a string into a positive integer pointed to by the</span></div><div class="line"><a name="l01373"></a><span class="lineno"> 1373</span> <span class="comment">// number parameter. Returns true if that is possible.</span></div><div class="line"><a name="l01374"></a><span class="lineno"> 1374</span> <span class="comment">// GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we can use</span></div><div class="line"><a name="l01375"></a><span class="lineno"> 1375</span> <span class="comment">// it here.</span></div><div class="line"><a name="l01376"></a><span class="lineno"> 1376</span> <span class="keyword">template</span> <<span class="keyword">typename</span> Integer></div><div class="line"><a name="l01377"></a><span class="lineno"> 1377</span> <span class="keywordtype">bool</span> ParseNaturalNumber(<a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">const ::std::string</a>& str, Integer* number) {</div><div class="line"><a name="l01378"></a><span class="lineno"> 1378</span>  <span class="comment">// Fail fast if the given string does not begin with a digit;</span></div><div class="line"><a name="l01379"></a><span class="lineno"> 1379</span>  <span class="comment">// this bypasses strtoXXX's "optional leading whitespace and plus</span></div><div class="line"><a name="l01380"></a><span class="lineno"> 1380</span>  <span class="comment">// or minus sign" semantics, which are undesirable here.</span></div><div class="line"><a name="l01381"></a><span class="lineno"> 1381</span>  <span class="keywordflow">if</span> (str.empty() || !<a class="code" href="namespacetesting_1_1internal.html#a4bd96b7fa6486802d33ddc217af55a39">IsDigit</a>(str[0])) {</div><div class="line"><a name="l01382"></a><span class="lineno"> 1382</span>  <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l01383"></a><span class="lineno"> 1383</span>  }</div><div class="line"><a name="l01384"></a><span class="lineno"> 1384</span>  errno = 0;</div><div class="line"><a name="l01385"></a><span class="lineno"> 1385</span> </div><div class="line"><a name="l01386"></a><span class="lineno"> 1386</span>  <span class="keywordtype">char</span>* end;</div><div class="line"><a name="l01387"></a><span class="lineno"> 1387</span>  <span class="comment">// BiggestConvertible is the largest integer type that system-provided</span></div><div class="line"><a name="l01388"></a><span class="lineno"> 1388</span>  <span class="comment">// string-to-number conversion routines can return.</span></div><div class="line"><a name="l01389"></a><span class="lineno"> 1389</span> </div><div class="line"><a name="l01390"></a><span class="lineno"> 1390</span> <span class="preprocessor"># if GTEST_OS_WINDOWS && !defined(__GNUC__)</span></div><div class="line"><a name="l01391"></a><span class="lineno"> 1391</span> </div><div class="line"><a name="l01392"></a><span class="lineno"> 1392</span>  <span class="comment">// MSVC and C++ Builder define __int64 instead of the standard long long.</span></div><div class="line"><a name="l01393"></a><span class="lineno"> 1393</span>  <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> __int64 BiggestConvertible;</div><div class="line"><a name="l01394"></a><span class="lineno"> 1394</span>  <span class="keyword">const</span> BiggestConvertible parsed = _strtoui64(str.c_str(), &end, 10);</div><div class="line"><a name="l01395"></a><span class="lineno"> 1395</span> </div><div class="line"><a name="l01396"></a><span class="lineno"> 1396</span> <span class="preprocessor"># else</span></div><div class="line"><a name="l01397"></a><span class="lineno"> 1397</span> </div><div class="line"><a name="l01398"></a><span class="lineno"> 1398</span>  <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> BiggestConvertible; <span class="comment">// NOLINT</span></div><div class="line"><a name="l01399"></a><span class="lineno"> 1399</span>  <span class="keyword">const</span> BiggestConvertible parsed = strtoull(str.c_str(), &end, 10);</div><div class="line"><a name="l01400"></a><span class="lineno"> 1400</span> </div><div class="line"><a name="l01401"></a><span class="lineno"> 1401</span> <span class="preprocessor"># endif // GTEST_OS_WINDOWS && !defined(__GNUC__)</span></div><div class="line"><a name="l01402"></a><span class="lineno"> 1402</span> </div><div class="line"><a name="l01403"></a><span class="lineno"> 1403</span>  <span class="keyword">const</span> <span class="keywordtype">bool</span> parse_success = *end == <span class="charliteral">'\0'</span> && errno == 0;</div><div class="line"><a name="l01404"></a><span class="lineno"> 1404</span> </div><div class="line"><a name="l01405"></a><span class="lineno"> 1405</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(<span class="keyword">sizeof</span>(Integer) <= <span class="keyword">sizeof</span>(parsed));</div><div class="line"><a name="l01406"></a><span class="lineno"> 1406</span> </div><div class="line"><a name="l01407"></a><span class="lineno"> 1407</span>  <span class="keyword">const</span> Integer result = <span class="keyword">static_cast<</span>Integer<span class="keyword">></span>(parsed);</div><div class="line"><a name="l01408"></a><span class="lineno"> 1408</span>  <span class="keywordflow">if</span> (parse_success && static_cast<BiggestConvertible>(result) == parsed) {</div><div class="line"><a name="l01409"></a><span class="lineno"> 1409</span>  *number = result;</div><div class="line"><a name="l01410"></a><span class="lineno"> 1410</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l01411"></a><span class="lineno"> 1411</span>  }</div><div class="line"><a name="l01412"></a><span class="lineno"> 1412</span>  <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l01413"></a><span class="lineno"> 1413</span> }</div><div class="line"><a name="l01414"></a><span class="lineno"> 1414</span> <span class="preprocessor">#endif // GTEST_HAS_DEATH_TEST</span></div><div class="line"><a name="l01415"></a><span class="lineno"> 1415</span> </div><div class="line"><a name="l01416"></a><span class="lineno"> 1416</span> <span class="comment">// TestResult contains some private methods that should be hidden from</span></div><div class="line"><a name="l01417"></a><span class="lineno"> 1417</span> <span class="comment">// Google Test user but are required for testing. This class allow our tests</span></div><div class="line"><a name="l01418"></a><span class="lineno"> 1418</span> <span class="comment">// to access them.</span></div><div class="line"><a name="l01419"></a><span class="lineno"> 1419</span> <span class="comment">//</span></div><div class="line"><a name="l01420"></a><span class="lineno"> 1420</span> <span class="comment">// This class is supplied only for the purpose of testing Google Test's own</span></div><div class="line"><a name="l01421"></a><span class="lineno"> 1421</span> <span class="comment">// constructs. Do not use it in user tests, either directly or indirectly.</span></div><div class="line"><a name="l01422"></a><span class="lineno"> 1422</span> <span class="keyword">class </span>TestResultAccessor {</div><div class="line"><a name="l01423"></a><span class="lineno"> 1423</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l01424"></a><span class="lineno"> 1424</span>  <span class="keyword">static</span> <span class="keywordtype">void</span> RecordProperty(TestResult* test_result,</div><div class="line"><a name="l01425"></a><span class="lineno"> 1425</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& xml_element,</div><div class="line"><a name="l01426"></a><span class="lineno"> 1426</span>  <span class="keyword">const</span> TestProperty& property) {</div><div class="line"><a name="l01427"></a><span class="lineno"> 1427</span>  test_result->RecordProperty(xml_element, property);</div><div class="line"><a name="l01428"></a><span class="lineno"> 1428</span>  }</div><div class="line"><a name="l01429"></a><span class="lineno"> 1429</span> </div><div class="line"><a name="l01430"></a><span class="lineno"> 1430</span>  <span class="keyword">static</span> <span class="keywordtype">void</span> ClearTestPartResults(TestResult* test_result) {</div><div class="line"><a name="l01431"></a><span class="lineno"> 1431</span>  test_result->ClearTestPartResults();</div><div class="line"><a name="l01432"></a><span class="lineno"> 1432</span>  }</div><div class="line"><a name="l01433"></a><span class="lineno"> 1433</span> </div><div class="line"><a name="l01434"></a><span class="lineno"> 1434</span>  <span class="keyword">static</span> <span class="keyword">const</span> std::vector<testing::TestPartResult>& test_part_results(</div><div class="line"><a name="l01435"></a><span class="lineno"> 1435</span>  <span class="keyword">const</span> TestResult& test_result) {</div><div class="line"><a name="l01436"></a><span class="lineno"> 1436</span>  <span class="keywordflow">return</span> test_result.test_part_results();</div><div class="line"><a name="l01437"></a><span class="lineno"> 1437</span>  }</div><div class="line"><a name="l01438"></a><span class="lineno"> 1438</span> };</div><div class="line"><a name="l01439"></a><span class="lineno"> 1439</span> </div><div class="line"><a name="l01440"></a><span class="lineno"> 1440</span> <span class="preprocessor">#if GTEST_CAN_STREAM_RESULTS_</span></div><div class="line"><a name="l01441"></a><span class="lineno"> 1441</span> </div><div class="line"><a name="l01442"></a><span class="lineno"> 1442</span> <span class="comment">// Streams test results to the given port on the given host machine.</span></div><div class="line"><a name="l01443"></a><span class="lineno"> 1443</span> <span class="keyword">class </span>StreamingListener : <span class="keyword">public</span> EmptyTestEventListener {</div><div class="line"><a name="l01444"></a><span class="lineno"> 1444</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l01445"></a><span class="lineno"> 1445</span>  <span class="comment">// Abstract base class for writing strings to a socket.</span></div><div class="line"><a name="l01446"></a><span class="lineno"> 1446</span>  <span class="keyword">class </span>AbstractSocketWriter {</div><div class="line"><a name="l01447"></a><span class="lineno"> 1447</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l01448"></a><span class="lineno"> 1448</span>  <span class="keyword">virtual</span> ~AbstractSocketWriter() {}</div><div class="line"><a name="l01449"></a><span class="lineno"> 1449</span> </div><div class="line"><a name="l01450"></a><span class="lineno"> 1450</span>  <span class="comment">// Sends a string to the socket.</span></div><div class="line"><a name="l01451"></a><span class="lineno"> 1451</span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> Send(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& message) = 0;</div><div class="line"><a name="l01452"></a><span class="lineno"> 1452</span> </div><div class="line"><a name="l01453"></a><span class="lineno"> 1453</span>  <span class="comment">// Closes the socket.</span></div><div class="line"><a name="l01454"></a><span class="lineno"> 1454</span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> CloseConnection() {}</div><div class="line"><a name="l01455"></a><span class="lineno"> 1455</span> </div><div class="line"><a name="l01456"></a><span class="lineno"> 1456</span>  <span class="comment">// Sends a string and a newline to the socket.</span></div><div class="line"><a name="l01457"></a><span class="lineno"> 1457</span>  <span class="keywordtype">void</span> SendLn(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& message) { Send(message + <span class="stringliteral">"\n"</span>); }</div><div class="line"><a name="l01458"></a><span class="lineno"> 1458</span>  };</div><div class="line"><a name="l01459"></a><span class="lineno"> 1459</span> </div><div class="line"><a name="l01460"></a><span class="lineno"> 1460</span>  <span class="comment">// Concrete class for actually writing strings to a socket.</span></div><div class="line"><a name="l01461"></a><span class="lineno"> 1461</span>  <span class="keyword">class </span>SocketWriter : <span class="keyword">public</span> AbstractSocketWriter {</div><div class="line"><a name="l01462"></a><span class="lineno"> 1462</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l01463"></a><span class="lineno"> 1463</span>  SocketWriter(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& host, <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& port)</div><div class="line"><a name="l01464"></a><span class="lineno"> 1464</span>  : sockfd_(-1), host_name_(host), port_num_(port) {</div><div class="line"><a name="l01465"></a><span class="lineno"> 1465</span>  MakeConnection();</div><div class="line"><a name="l01466"></a><span class="lineno"> 1466</span>  }</div><div class="line"><a name="l01467"></a><span class="lineno"> 1467</span> </div><div class="line"><a name="l01468"></a><span class="lineno"> 1468</span>  ~SocketWriter()<span class="keyword"> override </span>{</div><div class="line"><a name="l01469"></a><span class="lineno"> 1469</span>  <span class="keywordflow">if</span> (sockfd_ != -1)</div><div class="line"><a name="l01470"></a><span class="lineno"> 1470</span>  CloseConnection();</div><div class="line"><a name="l01471"></a><span class="lineno"> 1471</span>  }</div><div class="line"><a name="l01472"></a><span class="lineno"> 1472</span> </div><div class="line"><a name="l01473"></a><span class="lineno"> 1473</span>  <span class="comment">// Sends a string to the socket.</span></div><div class="line"><a name="l01474"></a><span class="lineno"> 1474</span>  <span class="keywordtype">void</span> Send(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& message)<span class="keyword"> override </span>{</div><div class="line"><a name="l01475"></a><span class="lineno"> 1475</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(sockfd_ != -1)</div><div class="line"><a name="l01476"></a><span class="lineno"> 1476</span>  << <span class="stringliteral">"Send() can be called only when there is a connection."</span>;</div><div class="line"><a name="l01477"></a><span class="lineno"> 1477</span> </div><div class="line"><a name="l01478"></a><span class="lineno"> 1478</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> len = <span class="keyword">static_cast<</span><span class="keywordtype">int</span><span class="keyword">></span>(message.length());</div><div class="line"><a name="l01479"></a><span class="lineno"> 1479</span>  <span class="keywordflow">if</span> (write(sockfd_, message.c_str(), len) != len) {</div><div class="line"><a name="l01480"></a><span class="lineno"> 1480</span>  <a class="code" href="gtest_8h.html#a8ef4cb4c465db8c15464aecc6d9510ef">GTEST_LOG_</a>(WARNING)</div><div class="line"><a name="l01481"></a><span class="lineno"> 1481</span>  << <span class="stringliteral">"stream_result_to: failed to stream to "</span></div><div class="line"><a name="l01482"></a><span class="lineno"> 1482</span>  << host_name_ << <span class="stringliteral">":"</span> << port_num_;</div><div class="line"><a name="l01483"></a><span class="lineno"> 1483</span>  }</div><div class="line"><a name="l01484"></a><span class="lineno"> 1484</span>  }</div><div class="line"><a name="l01485"></a><span class="lineno"> 1485</span> </div><div class="line"><a name="l01486"></a><span class="lineno"> 1486</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l01487"></a><span class="lineno"> 1487</span>  <span class="comment">// Creates a client socket and connects to the server.</span></div><div class="line"><a name="l01488"></a><span class="lineno"> 1488</span>  <span class="keywordtype">void</span> MakeConnection();</div><div class="line"><a name="l01489"></a><span class="lineno"> 1489</span> </div><div class="line"><a name="l01490"></a><span class="lineno"> 1490</span>  <span class="comment">// Closes the socket.</span></div><div class="line"><a name="l01491"></a><span class="lineno"> 1491</span>  <span class="keywordtype">void</span> CloseConnection()<span class="keyword"> override </span>{</div><div class="line"><a name="l01492"></a><span class="lineno"> 1492</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(sockfd_ != -1)</div><div class="line"><a name="l01493"></a><span class="lineno"> 1493</span>  << <span class="stringliteral">"CloseConnection() can be called only when there is a connection."</span>;</div><div class="line"><a name="l01494"></a><span class="lineno"> 1494</span> </div><div class="line"><a name="l01495"></a><span class="lineno"> 1495</span>  close(sockfd_);</div><div class="line"><a name="l01496"></a><span class="lineno"> 1496</span>  sockfd_ = -1;</div><div class="line"><a name="l01497"></a><span class="lineno"> 1497</span>  }</div><div class="line"><a name="l01498"></a><span class="lineno"> 1498</span> </div><div class="line"><a name="l01499"></a><span class="lineno"> 1499</span>  <span class="keywordtype">int</span> sockfd_; <span class="comment">// socket file descriptor</span></div><div class="line"><a name="l01500"></a><span class="lineno"> 1500</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> host_name_;</div><div class="line"><a name="l01501"></a><span class="lineno"> 1501</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> port_num_;</div><div class="line"><a name="l01502"></a><span class="lineno"> 1502</span> </div><div class="line"><a name="l01503"></a><span class="lineno"> 1503</span>  <a class="code" href="gtest_8h.html#aed8c1888c32b588b0681e88b95031e29">GTEST_DISALLOW_COPY_AND_ASSIGN_</a>(SocketWriter);</div><div class="line"><a name="l01504"></a><span class="lineno"> 1504</span>  }; <span class="comment">// class SocketWriter</span></div><div class="line"><a name="l01505"></a><span class="lineno"> 1505</span> </div><div class="line"><a name="l01506"></a><span class="lineno"> 1506</span>  <span class="comment">// Escapes '=', '&', '%', and '\n' characters in str as "%xx".</span></div><div class="line"><a name="l01507"></a><span class="lineno"> 1507</span>  <span class="keyword">static</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> UrlEncode(<span class="keyword">const</span> <span class="keywordtype">char</span>* str);</div><div class="line"><a name="l01508"></a><span class="lineno"> 1508</span> </div><div class="line"><a name="l01509"></a><span class="lineno"> 1509</span>  StreamingListener(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& host, <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& port)</div><div class="line"><a name="l01510"></a><span class="lineno"> 1510</span>  : socket_writer_(<span class="keyword">new</span> SocketWriter(host, port)) {</div><div class="line"><a name="l01511"></a><span class="lineno"> 1511</span>  Start();</div><div class="line"><a name="l01512"></a><span class="lineno"> 1512</span>  }</div><div class="line"><a name="l01513"></a><span class="lineno"> 1513</span> </div><div class="line"><a name="l01514"></a><span class="lineno"> 1514</span>  <span class="keyword">explicit</span> StreamingListener(AbstractSocketWriter* socket_writer)</div><div class="line"><a name="l01515"></a><span class="lineno"> 1515</span>  : socket_writer_(socket_writer) { Start(); }</div><div class="line"><a name="l01516"></a><span class="lineno"> 1516</span> </div><div class="line"><a name="l01517"></a><span class="lineno"> 1517</span>  <span class="keywordtype">void</span> OnTestProgramStart(<span class="keyword">const</span> UnitTest& <span class="comment">/* unit_test */</span>)<span class="keyword"> override </span>{</div><div class="line"><a name="l01518"></a><span class="lineno"> 1518</span>  SendLn(<span class="stringliteral">"event=TestProgramStart"</span>);</div><div class="line"><a name="l01519"></a><span class="lineno"> 1519</span>  }</div><div class="line"><a name="l01520"></a><span class="lineno"> 1520</span> </div><div class="line"><a name="l01521"></a><span class="lineno"> 1521</span>  <span class="keywordtype">void</span> OnTestProgramEnd(<span class="keyword">const</span> UnitTest& unit_test)<span class="keyword"> override </span>{</div><div class="line"><a name="l01522"></a><span class="lineno"> 1522</span>  <span class="comment">// Note that Google Test current only report elapsed time for each</span></div><div class="line"><a name="l01523"></a><span class="lineno"> 1523</span>  <span class="comment">// test iteration, not for the entire test program.</span></div><div class="line"><a name="l01524"></a><span class="lineno"> 1524</span>  SendLn(<span class="stringliteral">"event=TestProgramEnd&passed="</span> + FormatBool(unit_test.Passed()));</div><div class="line"><a name="l01525"></a><span class="lineno"> 1525</span> </div><div class="line"><a name="l01526"></a><span class="lineno"> 1526</span>  <span class="comment">// Notify the streaming server to stop.</span></div><div class="line"><a name="l01527"></a><span class="lineno"> 1527</span>  socket_writer_->CloseConnection();</div><div class="line"><a name="l01528"></a><span class="lineno"> 1528</span>  }</div><div class="line"><a name="l01529"></a><span class="lineno"> 1529</span> </div><div class="line"><a name="l01530"></a><span class="lineno"> 1530</span>  <span class="keywordtype">void</span> OnTestIterationStart(<span class="keyword">const</span> UnitTest& <span class="comment">/* unit_test */</span>,</div><div class="line"><a name="l01531"></a><span class="lineno"> 1531</span>  <span class="keywordtype">int</span> iteration)<span class="keyword"> override </span>{</div><div class="line"><a name="l01532"></a><span class="lineno"> 1532</span>  SendLn(<span class="stringliteral">"event=TestIterationStart&iteration="</span> +</div><div class="line"><a name="l01533"></a><span class="lineno"> 1533</span>  <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(iteration));</div><div class="line"><a name="l01534"></a><span class="lineno"> 1534</span>  }</div><div class="line"><a name="l01535"></a><span class="lineno"> 1535</span> </div><div class="line"><a name="l01536"></a><span class="lineno"> 1536</span>  <span class="keywordtype">void</span> OnTestIterationEnd(<span class="keyword">const</span> UnitTest& unit_test,</div><div class="line"><a name="l01537"></a><span class="lineno"> 1537</span>  <span class="keywordtype">int</span> <span class="comment">/* iteration */</span>)<span class="keyword"> override </span>{</div><div class="line"><a name="l01538"></a><span class="lineno"> 1538</span>  SendLn(<span class="stringliteral">"event=TestIterationEnd&passed="</span> +</div><div class="line"><a name="l01539"></a><span class="lineno"> 1539</span>  FormatBool(unit_test.Passed()) + <span class="stringliteral">"&elapsed_time="</span> +</div><div class="line"><a name="l01540"></a><span class="lineno"> 1540</span>  <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(unit_test.elapsed_time()) + <span class="stringliteral">"ms"</span>);</div><div class="line"><a name="l01541"></a><span class="lineno"> 1541</span>  }</div><div class="line"><a name="l01542"></a><span class="lineno"> 1542</span> </div><div class="line"><a name="l01543"></a><span class="lineno"> 1543</span>  <span class="comment">// Note that "event=TestCaseStart" is a wire format and has to remain</span></div><div class="line"><a name="l01544"></a><span class="lineno"> 1544</span>  <span class="comment">// "case" for compatibilty</span></div><div class="line"><a name="l01545"></a><span class="lineno"> 1545</span>  <span class="keywordtype">void</span> OnTestCaseStart(<span class="keyword">const</span> TestCase& test_case)<span class="keyword"> override </span>{</div><div class="line"><a name="l01546"></a><span class="lineno"> 1546</span>  SendLn(<a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(<span class="stringliteral">"event=TestCaseStart&name="</span>) + test_case.name());</div><div class="line"><a name="l01547"></a><span class="lineno"> 1547</span>  }</div><div class="line"><a name="l01548"></a><span class="lineno"> 1548</span> </div><div class="line"><a name="l01549"></a><span class="lineno"> 1549</span>  <span class="comment">// Note that "event=TestCaseEnd" is a wire format and has to remain</span></div><div class="line"><a name="l01550"></a><span class="lineno"> 1550</span>  <span class="comment">// "case" for compatibilty</span></div><div class="line"><a name="l01551"></a><span class="lineno"> 1551</span>  <span class="keywordtype">void</span> OnTestCaseEnd(<span class="keyword">const</span> TestCase& test_case)<span class="keyword"> override </span>{</div><div class="line"><a name="l01552"></a><span class="lineno"> 1552</span>  SendLn(<span class="stringliteral">"event=TestCaseEnd&passed="</span> + FormatBool(test_case.Passed()) +</div><div class="line"><a name="l01553"></a><span class="lineno"> 1553</span>  <span class="stringliteral">"&elapsed_time="</span> + <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(test_case.elapsed_time()) +</div><div class="line"><a name="l01554"></a><span class="lineno"> 1554</span>  <span class="stringliteral">"ms"</span>);</div><div class="line"><a name="l01555"></a><span class="lineno"> 1555</span>  }</div><div class="line"><a name="l01556"></a><span class="lineno"> 1556</span> </div><div class="line"><a name="l01557"></a><span class="lineno"> 1557</span>  <span class="keywordtype">void</span> OnTestStart(<span class="keyword">const</span> TestInfo& test_info)<span class="keyword"> override </span>{</div><div class="line"><a name="l01558"></a><span class="lineno"> 1558</span>  SendLn(<a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(<span class="stringliteral">"event=TestStart&name="</span>) + test_info.name());</div><div class="line"><a name="l01559"></a><span class="lineno"> 1559</span>  }</div><div class="line"><a name="l01560"></a><span class="lineno"> 1560</span> </div><div class="line"><a name="l01561"></a><span class="lineno"> 1561</span>  <span class="keywordtype">void</span> OnTestEnd(<span class="keyword">const</span> TestInfo& test_info)<span class="keyword"> override </span>{</div><div class="line"><a name="l01562"></a><span class="lineno"> 1562</span>  SendLn(<span class="stringliteral">"event=TestEnd&passed="</span> +</div><div class="line"><a name="l01563"></a><span class="lineno"> 1563</span>  FormatBool((test_info.result())->Passed()) +</div><div class="line"><a name="l01564"></a><span class="lineno"> 1564</span>  <span class="stringliteral">"&elapsed_time="</span> +</div><div class="line"><a name="l01565"></a><span class="lineno"> 1565</span>  <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>((test_info.result())->elapsed_time()) + <span class="stringliteral">"ms"</span>);</div><div class="line"><a name="l01566"></a><span class="lineno"> 1566</span>  }</div><div class="line"><a name="l01567"></a><span class="lineno"> 1567</span> </div><div class="line"><a name="l01568"></a><span class="lineno"> 1568</span>  <span class="keywordtype">void</span> OnTestPartResult(<span class="keyword">const</span> TestPartResult& test_part_result)<span class="keyword"> override </span>{</div><div class="line"><a name="l01569"></a><span class="lineno"> 1569</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* file_name = test_part_result.file_name();</div><div class="line"><a name="l01570"></a><span class="lineno"> 1570</span>  <span class="keywordflow">if</span> (file_name == <span class="keyword">nullptr</span>) file_name = <span class="stringliteral">""</span>;</div><div class="line"><a name="l01571"></a><span class="lineno"> 1571</span>  SendLn(<span class="stringliteral">"event=TestPartResult&file="</span> + UrlEncode(file_name) +</div><div class="line"><a name="l01572"></a><span class="lineno"> 1572</span>  <span class="stringliteral">"&line="</span> + <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(test_part_result.line_number()) +</div><div class="line"><a name="l01573"></a><span class="lineno"> 1573</span>  <span class="stringliteral">"&message="</span> + UrlEncode(test_part_result.message()));</div><div class="line"><a name="l01574"></a><span class="lineno"> 1574</span>  }</div><div class="line"><a name="l01575"></a><span class="lineno"> 1575</span> </div><div class="line"><a name="l01576"></a><span class="lineno"> 1576</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l01577"></a><span class="lineno"> 1577</span>  <span class="comment">// Sends the given message and a newline to the socket.</span></div><div class="line"><a name="l01578"></a><span class="lineno"> 1578</span>  <span class="keywordtype">void</span> SendLn(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& message) { socket_writer_->SendLn(message); }</div><div class="line"><a name="l01579"></a><span class="lineno"> 1579</span> </div><div class="line"><a name="l01580"></a><span class="lineno"> 1580</span>  <span class="comment">// Called at the start of streaming to notify the receiver what</span></div><div class="line"><a name="l01581"></a><span class="lineno"> 1581</span>  <span class="comment">// protocol we are using.</span></div><div class="line"><a name="l01582"></a><span class="lineno"> 1582</span>  <span class="keywordtype">void</span> Start() { SendLn(<span class="stringliteral">"gtest_streaming_protocol_version=1.0"</span>); }</div><div class="line"><a name="l01583"></a><span class="lineno"> 1583</span> </div><div class="line"><a name="l01584"></a><span class="lineno"> 1584</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> FormatBool(<span class="keywordtype">bool</span> value) { <span class="keywordflow">return</span> value ? <span class="stringliteral">"1"</span> : <span class="stringliteral">"0"</span>; }</div><div class="line"><a name="l01585"></a><span class="lineno"> 1585</span> </div><div class="line"><a name="l01586"></a><span class="lineno"> 1586</span>  <span class="keyword">const</span> std::unique_ptr<AbstractSocketWriter> socket_writer_;</div><div class="line"><a name="l01587"></a><span class="lineno"> 1587</span> </div><div class="line"><a name="l01588"></a><span class="lineno"> 1588</span>  <a class="code" href="gtest_8h.html#aed8c1888c32b588b0681e88b95031e29">GTEST_DISALLOW_COPY_AND_ASSIGN_</a>(StreamingListener);</div><div class="line"><a name="l01589"></a><span class="lineno"> 1589</span> }; <span class="comment">// class StreamingListener</span></div><div class="line"><a name="l01590"></a><span class="lineno"> 1590</span> </div><div class="line"><a name="l01591"></a><span class="lineno"> 1591</span> <span class="preprocessor">#endif // GTEST_CAN_STREAM_RESULTS_</span></div><div class="line"><a name="l01592"></a><span class="lineno"> 1592</span> </div><div class="line"><a name="l01593"></a><span class="lineno"> 1593</span> } <span class="comment">// namespace internal</span></div><div class="line"><a name="l01594"></a><span class="lineno"> 1594</span> } <span class="comment">// namespace testing</span></div><div class="line"><a name="l01595"></a><span class="lineno"> 1595</span> </div><div class="line"><a name="l01596"></a><span class="lineno"> 1596</span> <a class="code" href="gtest-all_8cc.html#a789f37f9c345c2032699c194a58623d9">GTEST_DISABLE_MSC_WARNINGS_POP_</a>() <span class="comment">// 4251</span></div><div class="line"><a name="l01597"></a><span class="lineno"> 1597</span> </div><div class="line"><a name="l01598"></a><span class="lineno"> 1598</span> <span class="preprocessor">#endif // GTEST_SRC_GTEST_INTERNAL_INL_H_</span></div><div class="line"><a name="l01599"></a><span class="lineno"> 1599</span> </div><div class="line"><a name="l01600"></a><span class="lineno"> 1600</span> <span class="preprocessor">#if GTEST_OS_WINDOWS</span></div><div class="line"><a name="l01601"></a><span class="lineno"> 1601</span> <span class="preprocessor"># define vsnprintf _vsnprintf</span></div><div class="line"><a name="l01602"></a><span class="lineno"> 1602</span> <span class="preprocessor">#endif // GTEST_OS_WINDOWS</span></div><div class="line"><a name="l01603"></a><span class="lineno"> 1603</span> </div><div class="line"><a name="l01604"></a><span class="lineno"> 1604</span> <span class="preprocessor">#if GTEST_OS_MAC</span></div><div class="line"><a name="l01605"></a><span class="lineno"> 1605</span> <span class="preprocessor">#ifndef GTEST_OS_IOS</span></div><div class="line"><a name="l01606"></a><span class="lineno"> 1606</span> <span class="preprocessor">#include <crt_externs.h></span></div><div class="line"><a name="l01607"></a><span class="lineno"> 1607</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l01608"></a><span class="lineno"> 1608</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l01609"></a><span class="lineno"> 1609</span> </div><div class="line"><a name="l01610"></a><span class="lineno"> 1610</span> <span class="preprocessor">#if GTEST_HAS_ABSL</span></div><div class="line"><a name="l01611"></a><span class="lineno"> 1611</span> <span class="preprocessor">#include "absl/debugging/failure_signal_handler.h"</span></div><div class="line"><a name="l01612"></a><span class="lineno"> 1612</span> <span class="preprocessor">#include "absl/debugging/stacktrace.h"</span></div><div class="line"><a name="l01613"></a><span class="lineno"> 1613</span> <span class="preprocessor">#include "absl/debugging/symbolize.h"</span></div><div class="line"><a name="l01614"></a><span class="lineno"> 1614</span> <span class="preprocessor">#include "absl/strings/str_cat.h"</span></div><div class="line"><a name="l01615"></a><span class="lineno"> 1615</span> <span class="preprocessor">#endif // GTEST_HAS_ABSL</span></div><div class="line"><a name="l01616"></a><span class="lineno"> 1616</span> </div><div class="line"><a name="l01617"></a><span class="lineno"> 1617</span> <span class="keyword">namespace </span><a class="code" href="namespacetesting.html">testing</a> {</div><div class="line"><a name="l01618"></a><span class="lineno"> 1618</span> </div><div class="line"><a name="l01619"></a><span class="lineno"> 1619</span> <span class="keyword">using</span> internal::CountIf;</div><div class="line"><a name="l01620"></a><span class="lineno"> 1620</span> <span class="keyword">using</span> internal::ForEach;</div><div class="line"><a name="l01621"></a><span class="lineno"> 1621</span> <span class="keyword">using</span> internal::GetElementOr;</div><div class="line"><a name="l01622"></a><span class="lineno"> 1622</span> <span class="keyword">using</span> internal::Shuffle;</div><div class="line"><a name="l01623"></a><span class="lineno"> 1623</span> </div><div class="line"><a name="l01624"></a><span class="lineno"> 1624</span> <span class="comment">// Constants.</span></div><div class="line"><a name="l01625"></a><span class="lineno"> 1625</span> </div><div class="line"><a name="l01626"></a><span class="lineno"> 1626</span> <span class="comment">// A test whose test suite name or test name matches this filter is</span></div><div class="line"><a name="l01627"></a><span class="lineno"> 1627</span> <span class="comment">// disabled and not run.</span></div><div class="line"><a name="l01628"></a><span class="lineno"> 1628</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kDisableTestFilter[] = <span class="stringliteral">"DISABLED_*:*/DISABLED_*"</span>;</div><div class="line"><a name="l01629"></a><span class="lineno"> 1629</span> </div><div class="line"><a name="l01630"></a><span class="lineno"> 1630</span> <span class="comment">// A test suite whose name matches this filter is considered a death</span></div><div class="line"><a name="l01631"></a><span class="lineno"> 1631</span> <span class="comment">// test suite and will be run before test suites whose name doesn't</span></div><div class="line"><a name="l01632"></a><span class="lineno"> 1632</span> <span class="comment">// match this filter.</span></div><div class="line"><a name="l01633"></a><span class="lineno"> 1633</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kDeathTestSuiteFilter[] = <span class="stringliteral">"*DeathTest:*DeathTest/*"</span>;</div><div class="line"><a name="l01634"></a><span class="lineno"> 1634</span> </div><div class="line"><a name="l01635"></a><span class="lineno"> 1635</span> <span class="comment">// A test filter that matches everything.</span></div><div class="line"><a name="l01636"></a><span class="lineno"> 1636</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kUniversalFilter[] = <span class="stringliteral">"*"</span>;</div><div class="line"><a name="l01637"></a><span class="lineno"> 1637</span> </div><div class="line"><a name="l01638"></a><span class="lineno"> 1638</span> <span class="comment">// The default output format.</span></div><div class="line"><a name="l01639"></a><span class="lineno"> 1639</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kDefaultOutputFormat[] = <span class="stringliteral">"xml"</span>;</div><div class="line"><a name="l01640"></a><span class="lineno"> 1640</span> <span class="comment">// The default output file.</span></div><div class="line"><a name="l01641"></a><span class="lineno"> 1641</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kDefaultOutputFile[] = <span class="stringliteral">"test_detail"</span>;</div><div class="line"><a name="l01642"></a><span class="lineno"> 1642</span> </div><div class="line"><a name="l01643"></a><span class="lineno"> 1643</span> <span class="comment">// The environment variable name for the test shard index.</span></div><div class="line"><a name="l01644"></a><span class="lineno"> 1644</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kTestShardIndex[] = <span class="stringliteral">"GTEST_SHARD_INDEX"</span>;</div><div class="line"><a name="l01645"></a><span class="lineno"> 1645</span> <span class="comment">// The environment variable name for the total number of test shards.</span></div><div class="line"><a name="l01646"></a><span class="lineno"> 1646</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kTestTotalShards[] = <span class="stringliteral">"GTEST_TOTAL_SHARDS"</span>;</div><div class="line"><a name="l01647"></a><span class="lineno"> 1647</span> <span class="comment">// The environment variable name for the test shard status file.</span></div><div class="line"><a name="l01648"></a><span class="lineno"> 1648</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kTestShardStatusFile[] = <span class="stringliteral">"GTEST_SHARD_STATUS_FILE"</span>;</div><div class="line"><a name="l01649"></a><span class="lineno"> 1649</span> </div><div class="line"><a name="l01650"></a><span class="lineno"> 1650</span> <span class="keyword">namespace </span>internal {</div><div class="line"><a name="l01651"></a><span class="lineno"> 1651</span> </div><div class="line"><a name="l01652"></a><span class="lineno"> 1652</span> <span class="comment">// The text used in failure messages to indicate the start of the</span></div><div class="line"><a name="l01653"></a><span class="lineno"> 1653</span> <span class="comment">// stack trace.</span></div><div class="line"><a name="l01654"></a><span class="lineno"> 1654</span> <span class="keyword">const</span> <span class="keywordtype">char</span> <a class="code" href="namespacetesting_1_1internal.html#a999c7ef9ff01b6d2d76669372c444aa3">kStackTraceMarker</a>[] = <span class="stringliteral">"\nStack trace:\n"</span>;</div><div class="line"><a name="l01655"></a><span class="lineno"> 1655</span> </div><div class="line"><a name="l01656"></a><span class="lineno"> 1656</span> <span class="comment">// g_help_flag is true iff the --help flag or an equivalent form is</span></div><div class="line"><a name="l01657"></a><span class="lineno"> 1657</span> <span class="comment">// specified on the command line.</span></div><div class="line"><a name="l01658"></a><span class="lineno"> 1658</span> <span class="keywordtype">bool</span> g_help_flag = <span class="keyword">false</span>;</div><div class="line"><a name="l01659"></a><span class="lineno"> 1659</span> </div><div class="line"><a name="l01660"></a><span class="lineno"> 1660</span> <span class="comment">// Utilty function to Open File for Writing</span></div><div class="line"><a name="l01661"></a><span class="lineno"> 1661</span> <span class="keyword">static</span> FILE* OpenFileForWriting(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& output_file) {</div><div class="line"><a name="l01662"></a><span class="lineno"> 1662</span>  FILE* fileout = <span class="keyword">nullptr</span>;</div><div class="line"><a name="l01663"></a><span class="lineno"> 1663</span>  FilePath output_file_path(output_file);</div><div class="line"><a name="l01664"></a><span class="lineno"> 1664</span>  FilePath output_dir(output_file_path.RemoveFileName());</div><div class="line"><a name="l01665"></a><span class="lineno"> 1665</span> </div><div class="line"><a name="l01666"></a><span class="lineno"> 1666</span>  <span class="keywordflow">if</span> (output_dir.CreateDirectoriesRecursively()) {</div><div class="line"><a name="l01667"></a><span class="lineno"> 1667</span>  fileout = <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a4042201dcc4932641d484e7ddf94de7d">posix::FOpen</a>(output_file.c_str(), <span class="stringliteral">"w"</span>);</div><div class="line"><a name="l01668"></a><span class="lineno"> 1668</span>  }</div><div class="line"><a name="l01669"></a><span class="lineno"> 1669</span>  <span class="keywordflow">if</span> (fileout == <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l01670"></a><span class="lineno"> 1670</span>  <a class="code" href="gtest_8h.html#a8ef4cb4c465db8c15464aecc6d9510ef">GTEST_LOG_</a>(FATAL) << <span class="stringliteral">"Unable to open file \""</span> << output_file << <span class="stringliteral">"\""</span>;</div><div class="line"><a name="l01671"></a><span class="lineno"> 1671</span>  }</div><div class="line"><a name="l01672"></a><span class="lineno"> 1672</span>  <span class="keywordflow">return</span> fileout;</div><div class="line"><a name="l01673"></a><span class="lineno"> 1673</span> }</div><div class="line"><a name="l01674"></a><span class="lineno"> 1674</span> </div><div class="line"><a name="l01675"></a><span class="lineno"> 1675</span> } <span class="comment">// namespace internal</span></div><div class="line"><a name="l01676"></a><span class="lineno"> 1676</span> </div><div class="line"><a name="l01677"></a><span class="lineno"> 1677</span> <span class="comment">// Bazel passes in the argument to '--test_filter' via the TESTBRIDGE_TEST_ONLY</span></div><div class="line"><a name="l01678"></a><span class="lineno"> 1678</span> <span class="comment">// environment variable.</span></div><div class="line"><a name="l01679"></a><span class="lineno"> 1679</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* GetDefaultFilter() {</div><div class="line"><a name="l01680"></a><span class="lineno"> 1680</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> testbridge_test_only =</div><div class="line"><a name="l01681"></a><span class="lineno"> 1681</span>  <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a1d5e3da5a27eed25986859fa83cafe95">internal::posix::GetEnv</a>(<span class="stringliteral">"TESTBRIDGE_TEST_ONLY"</span>);</div><div class="line"><a name="l01682"></a><span class="lineno"> 1682</span>  <span class="keywordflow">if</span> (testbridge_test_only != <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l01683"></a><span class="lineno"> 1683</span>  <span class="keywordflow">return</span> testbridge_test_only;</div><div class="line"><a name="l01684"></a><span class="lineno"> 1684</span>  }</div><div class="line"><a name="l01685"></a><span class="lineno"> 1685</span>  <span class="keywordflow">return</span> kUniversalFilter;</div><div class="line"><a name="l01686"></a><span class="lineno"> 1686</span> }</div><div class="line"><a name="l01687"></a><span class="lineno"> 1687</span> </div><div class="line"><a name="l01688"></a><span class="lineno"> 1688</span> <a class="code" href="namespacetesting.html#a428e5944490e497df683cb8324ce4489">GTEST_DEFINE_bool_</a>(</div><div class="line"><a name="l01689"></a><span class="lineno"> 1689</span>  also_run_disabled_tests,</div><div class="line"><a name="l01690"></a><span class="lineno"> 1690</span>  <a class="code" href="namespacetesting_1_1internal.html#a1055088bb9b867e1b7b8f096f519d7c5">internal::BoolFromGTestEnv</a>(<span class="stringliteral">"also_run_disabled_tests"</span>, <span class="keyword">false</span>),</div><div class="line"><a name="l01691"></a><span class="lineno"> 1691</span>  <span class="stringliteral">"Run disabled tests too, in addition to the tests normally being run."</span>);</div><div class="line"><a name="l01692"></a><span class="lineno"> 1692</span> </div><div class="line"><a name="l01693"></a><span class="lineno"> 1693</span> <a class="code" href="namespacetesting.html#a428e5944490e497df683cb8324ce4489">GTEST_DEFINE_bool_</a>(</div><div class="line"><a name="l01694"></a><span class="lineno"> 1694</span>  break_on_failure,</div><div class="line"><a name="l01695"></a><span class="lineno"> 1695</span>  <a class="code" href="namespacetesting_1_1internal.html#a1055088bb9b867e1b7b8f096f519d7c5">internal::BoolFromGTestEnv</a>(<span class="stringliteral">"break_on_failure"</span>, <span class="keyword">false</span>),</div><div class="line"><a name="l01696"></a><span class="lineno"> 1696</span>  <span class="stringliteral">"True iff a failed assertion should be a debugger break-point."</span>);</div><div class="line"><a name="l01697"></a><span class="lineno"> 1697</span> </div><div class="line"><a name="l01698"></a><span class="lineno"> 1698</span> <a class="code" href="namespacetesting.html#a428e5944490e497df683cb8324ce4489">GTEST_DEFINE_bool_</a>(</div><div class="line"><a name="l01699"></a><span class="lineno"> 1699</span>  catch_exceptions,</div><div class="line"><a name="l01700"></a><span class="lineno"> 1700</span>  <a class="code" href="namespacetesting_1_1internal.html#a1055088bb9b867e1b7b8f096f519d7c5">internal::BoolFromGTestEnv</a>(<span class="stringliteral">"catch_exceptions"</span>, <span class="keyword">true</span>),</div><div class="line"><a name="l01701"></a><span class="lineno"> 1701</span>  <span class="stringliteral">"True iff "</span> <a class="code" href="gtest_8h.html#a13d98c217176bd8722c395b9225fc19d">GTEST_NAME_</a></div><div class="line"><a name="l01702"></a><span class="lineno"> 1702</span>  <span class="stringliteral">" should catch exceptions and treat them as test failures."</span>);</div><div class="line"><a name="l01703"></a><span class="lineno"> 1703</span> </div><div class="line"><a name="l01704"></a><span class="lineno"> 1704</span> <a class="code" href="namespacetesting.html#a8e954ed3f0f6ca2e90b043e419c74123">GTEST_DEFINE_string_</a>(</div><div class="line"><a name="l01705"></a><span class="lineno"> 1705</span>  color,</div><div class="line"><a name="l01706"></a><span class="lineno"> 1706</span>  <a class="code" href="namespacetesting_1_1internal.html#a0967cbf18fb1594f82512d8d822aba21">internal::StringFromGTestEnv</a>(<span class="stringliteral">"color"</span>, <span class="stringliteral">"auto"</span>),</div><div class="line"><a name="l01707"></a><span class="lineno"> 1707</span>  <span class="stringliteral">"Whether to use colors in the output. Valid values: yes, no, "</span></div><div class="line"><a name="l01708"></a><span class="lineno"> 1708</span>  <span class="stringliteral">"and auto. 'auto' means to use colors if the output is "</span></div><div class="line"><a name="l01709"></a><span class="lineno"> 1709</span>  <span class="stringliteral">"being sent to a terminal and the TERM environment variable "</span></div><div class="line"><a name="l01710"></a><span class="lineno"> 1710</span>  <span class="stringliteral">"is set to a terminal type that supports colors."</span>);</div><div class="line"><a name="l01711"></a><span class="lineno"> 1711</span> </div><div class="line"><a name="l01712"></a><span class="lineno"> 1712</span> <a class="code" href="namespacetesting.html#a8e954ed3f0f6ca2e90b043e419c74123">GTEST_DEFINE_string_</a>(</div><div class="line"><a name="l01713"></a><span class="lineno"> 1713</span>  <a class="code" href="namespaceutl_1_1meta.html#ac72acc616316c322e750d20a46553ba4">filter</a>,</div><div class="line"><a name="l01714"></a><span class="lineno"> 1714</span>  <a class="code" href="namespacetesting_1_1internal.html#a0967cbf18fb1594f82512d8d822aba21">internal::StringFromGTestEnv</a>(<span class="stringliteral">"filter"</span>, GetDefaultFilter()),</div><div class="line"><a name="l01715"></a><span class="lineno"> 1715</span>  <span class="stringliteral">"A colon-separated list of glob (not regex) patterns "</span></div><div class="line"><a name="l01716"></a><span class="lineno"> 1716</span>  <span class="stringliteral">"for filtering the tests to run, optionally followed by a "</span></div><div class="line"><a name="l01717"></a><span class="lineno"> 1717</span>  <span class="stringliteral">"'-' and a : separated list of negative patterns (tests to "</span></div><div class="line"><a name="l01718"></a><span class="lineno"> 1718</span>  <span class="stringliteral">"exclude). A test is run if it matches one of the positive "</span></div><div class="line"><a name="l01719"></a><span class="lineno"> 1719</span>  <span class="stringliteral">"patterns and does not match any of the negative patterns."</span>);</div><div class="line"><a name="l01720"></a><span class="lineno"> 1720</span> </div><div class="line"><a name="l01721"></a><span class="lineno"> 1721</span> <a class="code" href="namespacetesting.html#a428e5944490e497df683cb8324ce4489">GTEST_DEFINE_bool_</a>(</div><div class="line"><a name="l01722"></a><span class="lineno"> 1722</span>  install_failure_signal_handler,</div><div class="line"><a name="l01723"></a><span class="lineno"> 1723</span>  <a class="code" href="namespacetesting_1_1internal.html#a1055088bb9b867e1b7b8f096f519d7c5">internal::BoolFromGTestEnv</a>(<span class="stringliteral">"install_failure_signal_handler"</span>, <span class="keyword">false</span>),</div><div class="line"><a name="l01724"></a><span class="lineno"> 1724</span>  <span class="stringliteral">"If true and supported on the current platform, "</span> <a class="code" href="gtest_8h.html#a13d98c217176bd8722c395b9225fc19d">GTEST_NAME_</a> <span class="stringliteral">" should "</span></div><div class="line"><a name="l01725"></a><span class="lineno"> 1725</span>  <span class="stringliteral">"install a signal handler that dumps debugging information when fatal "</span></div><div class="line"><a name="l01726"></a><span class="lineno"> 1726</span>  <span class="stringliteral">"signals are raised."</span>);</div><div class="line"><a name="l01727"></a><span class="lineno"> 1727</span> </div><div class="line"><a name="l01728"></a><span class="lineno"> 1728</span> <a class="code" href="namespacetesting.html#a428e5944490e497df683cb8324ce4489">GTEST_DEFINE_bool_</a>(list_tests, <span class="keyword">false</span>,</div><div class="line"><a name="l01729"></a><span class="lineno"> 1729</span>  <span class="stringliteral">"List all tests without running them."</span>);</div><div class="line"><a name="l01730"></a><span class="lineno"> 1730</span> </div><div class="line"><a name="l01731"></a><span class="lineno"> 1731</span> <span class="comment">// The net priority order after flag processing is thus:</span></div><div class="line"><a name="l01732"></a><span class="lineno"> 1732</span> <span class="comment">// --gtest_output command line flag</span></div><div class="line"><a name="l01733"></a><span class="lineno"> 1733</span> <span class="comment">// GTEST_OUTPUT environment variable</span></div><div class="line"><a name="l01734"></a><span class="lineno"> 1734</span> <span class="comment">// XML_OUTPUT_FILE environment variable</span></div><div class="line"><a name="l01735"></a><span class="lineno"> 1735</span> <span class="comment">// ''</span></div><div class="line"><a name="l01736"></a><span class="lineno"> 1736</span> <a class="code" href="namespacetesting.html#a8e954ed3f0f6ca2e90b043e419c74123">GTEST_DEFINE_string_</a>(</div><div class="line"><a name="l01737"></a><span class="lineno"> 1737</span>  output,</div><div class="line"><a name="l01738"></a><span class="lineno"> 1738</span>  <a class="code" href="namespacetesting_1_1internal.html#a0967cbf18fb1594f82512d8d822aba21">internal::StringFromGTestEnv</a>(<span class="stringliteral">"output"</span>,</div><div class="line"><a name="l01739"></a><span class="lineno"> 1739</span>  <a class="code" href="namespacetesting_1_1internal.html#a0c793c6d84760d900299916c077a1af4">internal::OutputFlagAlsoCheckEnvVar</a>().c_str()),</div><div class="line"><a name="l01740"></a><span class="lineno"> 1740</span>  <span class="stringliteral">"A format (defaults to \"xml\" but can be specified to be \"json\"), "</span></div><div class="line"><a name="l01741"></a><span class="lineno"> 1741</span>  <span class="stringliteral">"optionally followed by a colon and an output file name or directory. "</span></div><div class="line"><a name="l01742"></a><span class="lineno"> 1742</span>  <span class="stringliteral">"A directory is indicated by a trailing pathname separator. "</span></div><div class="line"><a name="l01743"></a><span class="lineno"> 1743</span>  <span class="stringliteral">"Examples: \"xml:filename.xml\", \"xml::directoryname/\". "</span></div><div class="line"><a name="l01744"></a><span class="lineno"> 1744</span>  <span class="stringliteral">"If a directory is specified, output files will be created "</span></div><div class="line"><a name="l01745"></a><span class="lineno"> 1745</span>  <span class="stringliteral">"within that directory, with file-names based on the test "</span></div><div class="line"><a name="l01746"></a><span class="lineno"> 1746</span>  <span class="stringliteral">"executable's name and, if necessary, made unique by adding "</span></div><div class="line"><a name="l01747"></a><span class="lineno"> 1747</span>  <span class="stringliteral">"digits."</span>);</div><div class="line"><a name="l01748"></a><span class="lineno"> 1748</span> </div><div class="line"><a name="l01749"></a><span class="lineno"> 1749</span> <a class="code" href="namespacetesting.html#a428e5944490e497df683cb8324ce4489">GTEST_DEFINE_bool_</a>(</div><div class="line"><a name="l01750"></a><span class="lineno"> 1750</span>  print_time,</div><div class="line"><a name="l01751"></a><span class="lineno"> 1751</span>  <a class="code" href="namespacetesting_1_1internal.html#a1055088bb9b867e1b7b8f096f519d7c5">internal::BoolFromGTestEnv</a>(<span class="stringliteral">"print_time"</span>, <span class="keyword">true</span>),</div><div class="line"><a name="l01752"></a><span class="lineno"> 1752</span>  <span class="stringliteral">"True iff "</span> <a class="code" href="gtest_8h.html#a13d98c217176bd8722c395b9225fc19d">GTEST_NAME_</a></div><div class="line"><a name="l01753"></a><span class="lineno"> 1753</span>  <span class="stringliteral">" should display elapsed time in text output."</span>);</div><div class="line"><a name="l01754"></a><span class="lineno"> 1754</span> </div><div class="line"><a name="l01755"></a><span class="lineno"> 1755</span> <a class="code" href="namespacetesting.html#a428e5944490e497df683cb8324ce4489">GTEST_DEFINE_bool_</a>(</div><div class="line"><a name="l01756"></a><span class="lineno"> 1756</span>  print_utf8,</div><div class="line"><a name="l01757"></a><span class="lineno"> 1757</span>  <a class="code" href="namespacetesting_1_1internal.html#a1055088bb9b867e1b7b8f096f519d7c5">internal::BoolFromGTestEnv</a>(<span class="stringliteral">"print_utf8"</span>, <span class="keyword">true</span>),</div><div class="line"><a name="l01758"></a><span class="lineno"> 1758</span>  <span class="stringliteral">"True iff "</span> <a class="code" href="gtest_8h.html#a13d98c217176bd8722c395b9225fc19d">GTEST_NAME_</a></div><div class="line"><a name="l01759"></a><span class="lineno"> 1759</span>  <span class="stringliteral">" prints UTF8 characters as text."</span>);</div><div class="line"><a name="l01760"></a><span class="lineno"> 1760</span> </div><div class="line"><a name="l01761"></a><span class="lineno"> 1761</span> <a class="code" href="gtest_8h.html#a88ee2f19589ffff86ca742fd33611358">GTEST_DEFINE_int32_</a>(</div><div class="line"><a name="l01762"></a><span class="lineno"> 1762</span>  random_seed,</div><div class="line"><a name="l01763"></a><span class="lineno"> 1763</span>  <a class="code" href="namespacetesting_1_1internal.html#a2196f070b2d28bceb45c7ad3b565b9ba">internal::Int32FromGTestEnv</a>(<span class="stringliteral">"random_seed"</span>, 0),</div><div class="line"><a name="l01764"></a><span class="lineno"> 1764</span>  <span class="stringliteral">"Random number seed to use when shuffling test orders. Must be in range "</span></div><div class="line"><a name="l01765"></a><span class="lineno"> 1765</span>  <span class="stringliteral">"[1, 99999], or 0 to use a seed based on the current time."</span>);</div><div class="line"><a name="l01766"></a><span class="lineno"> 1766</span> </div><div class="line"><a name="l01767"></a><span class="lineno"> 1767</span> <a class="code" href="gtest_8h.html#a88ee2f19589ffff86ca742fd33611358">GTEST_DEFINE_int32_</a>(</div><div class="line"><a name="l01768"></a><span class="lineno"> 1768</span>  <a class="code" href="namespaceutl_1_1meta.html#aa013c45afb59b5c132a72be54ba145fb">repeat</a>,</div><div class="line"><a name="l01769"></a><span class="lineno"> 1769</span>  <a class="code" href="namespacetesting_1_1internal.html#a2196f070b2d28bceb45c7ad3b565b9ba">internal::Int32FromGTestEnv</a>(<span class="stringliteral">"repeat"</span>, 1),</div><div class="line"><a name="l01770"></a><span class="lineno"> 1770</span>  <span class="stringliteral">"How many times to repeat each test. Specify a negative number "</span></div><div class="line"><a name="l01771"></a><span class="lineno"> 1771</span>  <span class="stringliteral">"for repeating forever. Useful for shaking out flaky tests."</span>);</div><div class="line"><a name="l01772"></a><span class="lineno"> 1772</span> </div><div class="line"><a name="l01773"></a><span class="lineno"> 1773</span> <a class="code" href="namespacetesting.html#a428e5944490e497df683cb8324ce4489">GTEST_DEFINE_bool_</a>(</div><div class="line"><a name="l01774"></a><span class="lineno"> 1774</span>  show_internal_stack_frames, <span class="keyword">false</span>,</div><div class="line"><a name="l01775"></a><span class="lineno"> 1775</span>  <span class="stringliteral">"True iff "</span> <a class="code" href="gtest_8h.html#a13d98c217176bd8722c395b9225fc19d">GTEST_NAME_</a> <span class="stringliteral">" should include internal stack frames when "</span></div><div class="line"><a name="l01776"></a><span class="lineno"> 1776</span>  <span class="stringliteral">"printing test failure stack traces."</span>);</div><div class="line"><a name="l01777"></a><span class="lineno"> 1777</span> </div><div class="line"><a name="l01778"></a><span class="lineno"> 1778</span> <a class="code" href="namespacetesting.html#a428e5944490e497df683cb8324ce4489">GTEST_DEFINE_bool_</a>(</div><div class="line"><a name="l01779"></a><span class="lineno"> 1779</span>  shuffle,</div><div class="line"><a name="l01780"></a><span class="lineno"> 1780</span>  <a class="code" href="namespacetesting_1_1internal.html#a1055088bb9b867e1b7b8f096f519d7c5">internal::BoolFromGTestEnv</a>(<span class="stringliteral">"shuffle"</span>, <span class="keyword">false</span>),</div><div class="line"><a name="l01781"></a><span class="lineno"> 1781</span>  <span class="stringliteral">"True iff "</span> <a class="code" href="gtest_8h.html#a13d98c217176bd8722c395b9225fc19d">GTEST_NAME_</a></div><div class="line"><a name="l01782"></a><span class="lineno"> 1782</span>  <span class="stringliteral">" should randomize tests' order on every run."</span>);</div><div class="line"><a name="l01783"></a><span class="lineno"> 1783</span> </div><div class="line"><a name="l01784"></a><span class="lineno"> 1784</span> <a class="code" href="gtest_8h.html#a88ee2f19589ffff86ca742fd33611358">GTEST_DEFINE_int32_</a>(</div><div class="line"><a name="l01785"></a><span class="lineno"> 1785</span>  stack_trace_depth,</div><div class="line"><a name="l01786"></a><span class="lineno"> 1786</span>  <a class="code" href="namespacetesting_1_1internal.html#a2196f070b2d28bceb45c7ad3b565b9ba">internal::Int32FromGTestEnv</a>(<span class="stringliteral">"stack_trace_depth"</span>, kMaxStackTraceDepth),</div><div class="line"><a name="l01787"></a><span class="lineno"> 1787</span>  <span class="stringliteral">"The maximum number of stack frames to print when an "</span></div><div class="line"><a name="l01788"></a><span class="lineno"> 1788</span>  <span class="stringliteral">"assertion fails. The valid range is 0 through 100, inclusive."</span>);</div><div class="line"><a name="l01789"></a><span class="lineno"> 1789</span> </div><div class="line"><a name="l01790"></a><span class="lineno"> 1790</span> <a class="code" href="namespacetesting.html#a8e954ed3f0f6ca2e90b043e419c74123">GTEST_DEFINE_string_</a>(</div><div class="line"><a name="l01791"></a><span class="lineno"> 1791</span>  stream_result_to,</div><div class="line"><a name="l01792"></a><span class="lineno"> 1792</span>  <a class="code" href="namespacetesting_1_1internal.html#a0967cbf18fb1594f82512d8d822aba21">internal::StringFromGTestEnv</a>(<span class="stringliteral">"stream_result_to"</span>, <span class="stringliteral">""</span>),</div><div class="line"><a name="l01793"></a><span class="lineno"> 1793</span>  <span class="stringliteral">"This flag specifies the host name and the port number on which to stream "</span></div><div class="line"><a name="l01794"></a><span class="lineno"> 1794</span>  <span class="stringliteral">"test results. Example: \"localhost:555\". The flag is effective only on "</span></div><div class="line"><a name="l01795"></a><span class="lineno"> 1795</span>  <span class="stringliteral">"Linux."</span>);</div><div class="line"><a name="l01796"></a><span class="lineno"> 1796</span> </div><div class="line"><a name="l01797"></a><span class="lineno"> 1797</span> <a class="code" href="namespacetesting.html#a428e5944490e497df683cb8324ce4489">GTEST_DEFINE_bool_</a>(</div><div class="line"><a name="l01798"></a><span class="lineno"> 1798</span>  throw_on_failure,</div><div class="line"><a name="l01799"></a><span class="lineno"> 1799</span>  <a class="code" href="namespacetesting_1_1internal.html#a1055088bb9b867e1b7b8f096f519d7c5">internal::BoolFromGTestEnv</a>(<span class="stringliteral">"throw_on_failure"</span>, <span class="keyword">false</span>),</div><div class="line"><a name="l01800"></a><span class="lineno"> 1800</span>  <span class="stringliteral">"When this flag is specified, a failed assertion will throw an exception "</span></div><div class="line"><a name="l01801"></a><span class="lineno"> 1801</span>  <span class="stringliteral">"if exceptions are enabled or exit the program with a non-zero code "</span></div><div class="line"><a name="l01802"></a><span class="lineno"> 1802</span>  <span class="stringliteral">"otherwise. For use with an external test framework."</span>);</div><div class="line"><a name="l01803"></a><span class="lineno"> 1803</span> </div><div class="line"><a name="l01804"></a><span class="lineno"> 1804</span> <span class="preprocessor">#if GTEST_USE_OWN_FLAGFILE_FLAG_</span></div><div class="line"><a name="l01805"></a><span class="lineno"> 1805</span> <a class="code" href="namespacetesting.html#a8e954ed3f0f6ca2e90b043e419c74123">GTEST_DEFINE_string_</a>(</div><div class="line"><a name="l01806"></a><span class="lineno"> 1806</span>  flagfile,</div><div class="line"><a name="l01807"></a><span class="lineno"> 1807</span>  <a class="code" href="namespacetesting_1_1internal.html#a0967cbf18fb1594f82512d8d822aba21">internal::StringFromGTestEnv</a>(<span class="stringliteral">"flagfile"</span>, <span class="stringliteral">""</span>),</div><div class="line"><a name="l01808"></a><span class="lineno"> 1808</span>  <span class="stringliteral">"This flag specifies the flagfile to read command-line flags from."</span>);</div><div class="line"><a name="l01809"></a><span class="lineno"> 1809</span> <span class="preprocessor">#endif // GTEST_USE_OWN_FLAGFILE_FLAG_</span></div><div class="line"><a name="l01810"></a><span class="lineno"> 1810</span> </div><div class="line"><a name="l01811"></a><span class="lineno"> 1811</span> <span class="keyword">namespace </span>internal {</div><div class="line"><a name="l01812"></a><span class="lineno"> 1812</span> </div><div class="line"><a name="l01813"></a><span class="lineno"> 1813</span> <span class="comment">// Generates a random number from [0, range), using a Linear</span></div><div class="line"><a name="l01814"></a><span class="lineno"> 1814</span> <span class="comment">// Congruential Generator (LCG). Crashes if 'range' is 0 or greater</span></div><div class="line"><a name="l01815"></a><span class="lineno"> 1815</span> <span class="comment">// than kMaxRange.</span></div><div class="line"><a name="l01816"></a><span class="lineno"> 1816</span> <a class="code" href="namespacetesting_1_1internal.html#a40d4fffcd2bf56f18b1c380615aa85e3">UInt32</a> <a class="code" href="classtesting_1_1internal_1_1_random.html#a9315b7fb621cbcfdf92ed4b5e584c0db">Random::Generate</a>(<a class="code" href="namespacetesting_1_1internal.html#a40d4fffcd2bf56f18b1c380615aa85e3">UInt32</a> range) {</div><div class="line"><a name="l01817"></a><span class="lineno"> 1817</span>  <span class="comment">// These constants are the same as are used in glibc's rand(3).</span></div><div class="line"><a name="l01818"></a><span class="lineno"> 1818</span>  <span class="comment">// Use wider types than necessary to prevent unsigned overflow diagnostics.</span></div><div class="line"><a name="l01819"></a><span class="lineno"> 1819</span>  state_ = <span class="keyword">static_cast<</span><a class="code" href="namespacetesting_1_1internal.html#a40d4fffcd2bf56f18b1c380615aa85e3">UInt32</a><span class="keyword">></span>(1103515245ULL*state_ + 12345U) % <a class="code" href="classtesting_1_1internal_1_1_random.html#a36d72dd7063d0b5338f229e75382fdd2">kMaxRange</a>;</div><div class="line"><a name="l01820"></a><span class="lineno"> 1820</span> </div><div class="line"><a name="l01821"></a><span class="lineno"> 1821</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(range > 0)</div><div class="line"><a name="l01822"></a><span class="lineno"> 1822</span>  << <span class="stringliteral">"Cannot generate a number in the range [0, 0)."</span>;</div><div class="line"><a name="l01823"></a><span class="lineno"> 1823</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(range <= <a class="code" href="classtesting_1_1internal_1_1_random.html#a36d72dd7063d0b5338f229e75382fdd2">kMaxRange</a>)</div><div class="line"><a name="l01824"></a><span class="lineno"> 1824</span>  << <span class="stringliteral">"Generation of a number in [0, "</span> << range << <span class="stringliteral">") was requested, "</span></div><div class="line"><a name="l01825"></a><span class="lineno"> 1825</span>  << <span class="stringliteral">"but this can only generate numbers in [0, "</span> << <a class="code" href="classtesting_1_1internal_1_1_random.html#a36d72dd7063d0b5338f229e75382fdd2">kMaxRange</a> << <span class="stringliteral">")."</span>;</div><div class="line"><a name="l01826"></a><span class="lineno"> 1826</span> </div><div class="line"><a name="l01827"></a><span class="lineno"> 1827</span>  <span class="comment">// Converting via modulus introduces a bit of downward bias, but</span></div><div class="line"><a name="l01828"></a><span class="lineno"> 1828</span>  <span class="comment">// it's simple, and a linear congruential generator isn't too good</span></div><div class="line"><a name="l01829"></a><span class="lineno"> 1829</span>  <span class="comment">// to begin with.</span></div><div class="line"><a name="l01830"></a><span class="lineno"> 1830</span>  <span class="keywordflow">return</span> state_ % range;</div><div class="line"><a name="l01831"></a><span class="lineno"> 1831</span> }</div><div class="line"><a name="l01832"></a><span class="lineno"> 1832</span> </div><div class="line"><a name="l01833"></a><span class="lineno"> 1833</span> <span class="comment">// GTestIsInitialized() returns true iff the user has initialized</span></div><div class="line"><a name="l01834"></a><span class="lineno"> 1834</span> <span class="comment">// Google Test. Useful for catching the user mistake of not initializing</span></div><div class="line"><a name="l01835"></a><span class="lineno"> 1835</span> <span class="comment">// Google Test before calling RUN_ALL_TESTS().</span></div><div class="line"><a name="l01836"></a><span class="lineno"> 1836</span> <span class="keyword">static</span> <span class="keywordtype">bool</span> GTestIsInitialized() { <span class="keywordflow">return</span> <a class="code" href="namespacetesting_1_1internal.html#a8d8ed3acadedd9c0db28d35a188973ea">GetArgvs</a>().size() > 0; }</div><div class="line"><a name="l01837"></a><span class="lineno"> 1837</span> </div><div class="line"><a name="l01838"></a><span class="lineno"> 1838</span> <span class="comment">// Iterates over a vector of TestSuites, keeping a running sum of the</span></div><div class="line"><a name="l01839"></a><span class="lineno"> 1839</span> <span class="comment">// results of calling a given int-returning method on each.</span></div><div class="line"><a name="l01840"></a><span class="lineno"> 1840</span> <span class="comment">// Returns the sum.</span></div><div class="line"><a name="l01841"></a><span class="lineno"> 1841</span> <span class="keyword">static</span> <span class="keywordtype">int</span> SumOverTestSuiteList(<span class="keyword">const</span> std::vector<TestSuite*>& case_list,</div><div class="line"><a name="l01842"></a><span class="lineno"> 1842</span>  <span class="keywordtype">int</span> (TestSuite::*method)() <span class="keyword">const</span>) {</div><div class="line"><a name="l01843"></a><span class="lineno"> 1843</span>  <span class="keywordtype">int</span> sum = 0;</div><div class="line"><a name="l01844"></a><span class="lineno"> 1844</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i < case_list.size(); i++) {</div><div class="line"><a name="l01845"></a><span class="lineno"> 1845</span>  sum += (case_list[i]->*method)();</div><div class="line"><a name="l01846"></a><span class="lineno"> 1846</span>  }</div><div class="line"><a name="l01847"></a><span class="lineno"> 1847</span>  <span class="keywordflow">return</span> sum;</div><div class="line"><a name="l01848"></a><span class="lineno"> 1848</span> }</div><div class="line"><a name="l01849"></a><span class="lineno"> 1849</span> </div><div class="line"><a name="l01850"></a><span class="lineno"> 1850</span> <span class="comment">// Returns true iff the test suite passed.</span></div><div class="line"><a name="l01851"></a><span class="lineno"> 1851</span> <span class="keyword">static</span> <span class="keywordtype">bool</span> TestSuitePassed(<span class="keyword">const</span> TestSuite* test_suite) {</div><div class="line"><a name="l01852"></a><span class="lineno"> 1852</span>  <span class="keywordflow">return</span> test_suite->should_run() && test_suite->Passed();</div><div class="line"><a name="l01853"></a><span class="lineno"> 1853</span> }</div><div class="line"><a name="l01854"></a><span class="lineno"> 1854</span> </div><div class="line"><a name="l01855"></a><span class="lineno"> 1855</span> <span class="comment">// Returns true iff the test suite failed.</span></div><div class="line"><a name="l01856"></a><span class="lineno"> 1856</span> <span class="keyword">static</span> <span class="keywordtype">bool</span> TestSuiteFailed(<span class="keyword">const</span> TestSuite* test_suite) {</div><div class="line"><a name="l01857"></a><span class="lineno"> 1857</span>  <span class="keywordflow">return</span> test_suite->should_run() && test_suite->Failed();</div><div class="line"><a name="l01858"></a><span class="lineno"> 1858</span> }</div><div class="line"><a name="l01859"></a><span class="lineno"> 1859</span> </div><div class="line"><a name="l01860"></a><span class="lineno"> 1860</span> <span class="comment">// Returns true iff test_suite contains at least one test that should</span></div><div class="line"><a name="l01861"></a><span class="lineno"> 1861</span> <span class="comment">// run.</span></div><div class="line"><a name="l01862"></a><span class="lineno"> 1862</span> <span class="keyword">static</span> <span class="keywordtype">bool</span> ShouldRunTestSuite(<span class="keyword">const</span> TestSuite* test_suite) {</div><div class="line"><a name="l01863"></a><span class="lineno"> 1863</span>  <span class="keywordflow">return</span> test_suite->should_run();</div><div class="line"><a name="l01864"></a><span class="lineno"> 1864</span> }</div><div class="line"><a name="l01865"></a><span class="lineno"> 1865</span> </div><div class="line"><a name="l01866"></a><span class="lineno"> 1866</span> <span class="comment">// AssertHelper constructor.</span></div><div class="line"><a name="l01867"></a><span class="lineno"> 1867</span> <a class="code" href="classtesting_1_1internal_1_1_assert_helper.html#ac2c9334518fd4087189b4505567a3c90">AssertHelper::AssertHelper</a>(TestPartResult::Type type,</div><div class="line"><a name="l01868"></a><span class="lineno"> 1868</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* file,</div><div class="line"><a name="l01869"></a><span class="lineno"> 1869</span>  <span class="keywordtype">int</span> line,</div><div class="line"><a name="l01870"></a><span class="lineno"> 1870</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* message)</div><div class="line"><a name="l01871"></a><span class="lineno"> 1871</span>  : data_(new AssertHelperData(type, file, line, message)) {</div><div class="line"><a name="l01872"></a><span class="lineno"> 1872</span> }</div><div class="line"><a name="l01873"></a><span class="lineno"> 1873</span> </div><div class="line"><a name="l01874"></a><span class="lineno"> 1874</span> AssertHelper::~AssertHelper() {</div><div class="line"><a name="l01875"></a><span class="lineno"> 1875</span>  <span class="keyword">delete</span> data_;</div><div class="line"><a name="l01876"></a><span class="lineno"> 1876</span> }</div><div class="line"><a name="l01877"></a><span class="lineno"> 1877</span> </div><div class="line"><a name="l01878"></a><span class="lineno"> 1878</span> <span class="comment">// Message assignment, for assertion streaming support.</span></div><div class="line"><a name="l01879"></a><span class="lineno"> 1879</span> <span class="keywordtype">void</span> AssertHelper::operator=(<span class="keyword">const</span> Message& message)<span class="keyword"> const </span>{</div><div class="line"><a name="l01880"></a><span class="lineno"> 1880</span>  UnitTest::GetInstance()-></div><div class="line"><a name="l01881"></a><span class="lineno"> 1881</span>  AddTestPartResult(data_->type, data_->file, data_->line,</div><div class="line"><a name="l01882"></a><span class="lineno"> 1882</span>  <a class="code" href="namespacetesting_1_1internal.html#af69e146a989e8d48def39a0cc59461c9">AppendUserMessage</a>(data_->message, message),</div><div class="line"><a name="l01883"></a><span class="lineno"> 1883</span>  UnitTest::GetInstance()->impl()</div><div class="line"><a name="l01884"></a><span class="lineno"> 1884</span>  ->CurrentOsStackTraceExceptTop(1)</div><div class="line"><a name="l01885"></a><span class="lineno"> 1885</span>  <span class="comment">// Skips the stack frame for this function itself.</span></div><div class="line"><a name="l01886"></a><span class="lineno"> 1886</span>  ); <span class="comment">// NOLINT</span></div><div class="line"><a name="l01887"></a><span class="lineno"> 1887</span> }</div><div class="line"><a name="l01888"></a><span class="lineno"> 1888</span> </div><div class="line"><a name="l01889"></a><span class="lineno"> 1889</span> <span class="comment">// A copy of all command line arguments. Set by InitGoogleTest().</span></div><div class="line"><a name="l01890"></a><span class="lineno"> 1890</span> static ::std::vector<std::string> g_argvs;</div><div class="line"><a name="l01891"></a><span class="lineno"> 1891</span> </div><div class="line"><a name="l01892"></a><span class="lineno"> 1892</span> ::std::vector<std::string> <a class="code" href="namespacetesting_1_1internal.html#a8d8ed3acadedd9c0db28d35a188973ea">GetArgvs</a>() {</div><div class="line"><a name="l01893"></a><span class="lineno"> 1893</span> <span class="preprocessor">#if defined(GTEST_CUSTOM_GET_ARGVS_)</span></div><div class="line"><a name="l01894"></a><span class="lineno"> 1894</span>  <span class="comment">// GTEST_CUSTOM_GET_ARGVS_() may return a container of std::string or</span></div><div class="line"><a name="l01895"></a><span class="lineno"> 1895</span>  <span class="comment">// ::string. This code converts it to the appropriate type.</span></div><div class="line"><a name="l01896"></a><span class="lineno"> 1896</span>  <span class="keyword">const</span> <span class="keyword">auto</span>& custom = GTEST_CUSTOM_GET_ARGVS_();</div><div class="line"><a name="l01897"></a><span class="lineno"> 1897</span>  return ::std::vector<std::string>(custom.begin(), custom.end());</div><div class="line"><a name="l01898"></a><span class="lineno"> 1898</span> <span class="preprocessor">#else // defined(GTEST_CUSTOM_GET_ARGVS_)</span></div><div class="line"><a name="l01899"></a><span class="lineno"> 1899</span>  <span class="keywordflow">return</span> g_argvs;</div><div class="line"><a name="l01900"></a><span class="lineno"> 1900</span> <span class="preprocessor">#endif // defined(GTEST_CUSTOM_GET_ARGVS_)</span></div><div class="line"><a name="l01901"></a><span class="lineno"> 1901</span> }</div><div class="line"><a name="l01902"></a><span class="lineno"> 1902</span> </div><div class="line"><a name="l01903"></a><span class="lineno"> 1903</span> <span class="comment">// Returns the current application's name, removing directory path if that</span></div><div class="line"><a name="l01904"></a><span class="lineno"> 1904</span> <span class="comment">// is present.</span></div><div class="line"><a name="l01905"></a><span class="lineno"> 1905</span> FilePath GetCurrentExecutableName() {</div><div class="line"><a name="l01906"></a><span class="lineno"> 1906</span>  FilePath result;</div><div class="line"><a name="l01907"></a><span class="lineno"> 1907</span> </div><div class="line"><a name="l01908"></a><span class="lineno"> 1908</span> <span class="preprocessor">#if GTEST_OS_WINDOWS || GTEST_OS_OS2</span></div><div class="line"><a name="l01909"></a><span class="lineno"> 1909</span>  result.Set(FilePath(<a class="code" href="namespacetesting_1_1internal.html#a8d8ed3acadedd9c0db28d35a188973ea">GetArgvs</a>()[0]).RemoveExtension(<span class="stringliteral">"exe"</span>));</div><div class="line"><a name="l01910"></a><span class="lineno"> 1910</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l01911"></a><span class="lineno"> 1911</span>  result.Set(FilePath(<a class="code" href="namespacetesting_1_1internal.html#a8d8ed3acadedd9c0db28d35a188973ea">GetArgvs</a>()[0]));</div><div class="line"><a name="l01912"></a><span class="lineno"> 1912</span> <span class="preprocessor">#endif // GTEST_OS_WINDOWS</span></div><div class="line"><a name="l01913"></a><span class="lineno"> 1913</span> </div><div class="line"><a name="l01914"></a><span class="lineno"> 1914</span>  <span class="keywordflow">return</span> result.RemoveDirectoryName();</div><div class="line"><a name="l01915"></a><span class="lineno"> 1915</span> }</div><div class="line"><a name="l01916"></a><span class="lineno"> 1916</span> </div><div class="line"><a name="l01917"></a><span class="lineno"> 1917</span> <span class="comment">// Functions for processing the gtest_output flag.</span></div><div class="line"><a name="l01918"></a><span class="lineno"> 1918</span> </div><div class="line"><a name="l01919"></a><span class="lineno"> 1919</span> <span class="comment">// Returns the output format, or "" for normal printed output.</span></div><div class="line"><a name="l01920"></a><span class="lineno"> 1920</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> UnitTestOptions::GetOutputFormat() {</div><div class="line"><a name="l01921"></a><span class="lineno"> 1921</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> gtest_output_flag = <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(output).c_str();</div><div class="line"><a name="l01922"></a><span class="lineno"> 1922</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> colon = strchr(gtest_output_flag, <span class="charliteral">':'</span>);</div><div class="line"><a name="l01923"></a><span class="lineno"> 1923</span>  <span class="keywordflow">return</span> (colon == <span class="keyword">nullptr</span>)</div><div class="line"><a name="l01924"></a><span class="lineno"> 1924</span>  ? <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(gtest_output_flag)</div><div class="line"><a name="l01925"></a><span class="lineno"> 1925</span>  : std::<a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">string</a>(gtest_output_flag, colon - gtest_output_flag);</div><div class="line"><a name="l01926"></a><span class="lineno"> 1926</span> }</div><div class="line"><a name="l01927"></a><span class="lineno"> 1927</span> </div><div class="line"><a name="l01928"></a><span class="lineno"> 1928</span> <span class="comment">// Returns the name of the requested output file, or the default if none</span></div><div class="line"><a name="l01929"></a><span class="lineno"> 1929</span> <span class="comment">// was explicitly specified.</span></div><div class="line"><a name="l01930"></a><span class="lineno"> 1930</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> UnitTestOptions::GetAbsolutePathToOutputFile() {</div><div class="line"><a name="l01931"></a><span class="lineno"> 1931</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> gtest_output_flag = <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(output).c_str();</div><div class="line"><a name="l01932"></a><span class="lineno"> 1932</span> </div><div class="line"><a name="l01933"></a><span class="lineno"> 1933</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> format = GetOutputFormat();</div><div class="line"><a name="l01934"></a><span class="lineno"> 1934</span>  <span class="keywordflow">if</span> (format.empty())</div><div class="line"><a name="l01935"></a><span class="lineno"> 1935</span>  format = <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(kDefaultOutputFormat);</div><div class="line"><a name="l01936"></a><span class="lineno"> 1936</span> </div><div class="line"><a name="l01937"></a><span class="lineno"> 1937</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> colon = strchr(gtest_output_flag, <span class="charliteral">':'</span>);</div><div class="line"><a name="l01938"></a><span class="lineno"> 1938</span>  <span class="keywordflow">if</span> (colon == <span class="keyword">nullptr</span>)</div><div class="line"><a name="l01939"></a><span class="lineno"> 1939</span>  <span class="keywordflow">return</span> internal::FilePath::MakeFileName(</div><div class="line"><a name="l01940"></a><span class="lineno"> 1940</span>  internal::FilePath(</div><div class="line"><a name="l01941"></a><span class="lineno"> 1941</span>  UnitTest::GetInstance()->original_working_dir()),</div><div class="line"><a name="l01942"></a><span class="lineno"> 1942</span>  internal::FilePath(kDefaultOutputFile), 0,</div><div class="line"><a name="l01943"></a><span class="lineno"> 1943</span>  format.c_str()).<span class="keywordtype">string</span>();</div><div class="line"><a name="l01944"></a><span class="lineno"> 1944</span> </div><div class="line"><a name="l01945"></a><span class="lineno"> 1945</span>  internal::FilePath output_name(colon + 1);</div><div class="line"><a name="l01946"></a><span class="lineno"> 1946</span>  <span class="keywordflow">if</span> (!output_name.IsAbsolutePath())</div><div class="line"><a name="l01947"></a><span class="lineno"> 1947</span>  output_name = internal::FilePath::ConcatPaths(</div><div class="line"><a name="l01948"></a><span class="lineno"> 1948</span>  internal::FilePath(UnitTest::GetInstance()->original_working_dir()),</div><div class="line"><a name="l01949"></a><span class="lineno"> 1949</span>  internal::FilePath(colon + 1));</div><div class="line"><a name="l01950"></a><span class="lineno"> 1950</span> </div><div class="line"><a name="l01951"></a><span class="lineno"> 1951</span>  <span class="keywordflow">if</span> (!output_name.IsDirectory())</div><div class="line"><a name="l01952"></a><span class="lineno"> 1952</span>  <span class="keywordflow">return</span> output_name.string();</div><div class="line"><a name="l01953"></a><span class="lineno"> 1953</span> </div><div class="line"><a name="l01954"></a><span class="lineno"> 1954</span>  internal::FilePath result(internal::FilePath::GenerateUniqueFileName(</div><div class="line"><a name="l01955"></a><span class="lineno"> 1955</span>  output_name, internal::GetCurrentExecutableName(),</div><div class="line"><a name="l01956"></a><span class="lineno"> 1956</span>  GetOutputFormat().c_str()));</div><div class="line"><a name="l01957"></a><span class="lineno"> 1957</span>  <span class="keywordflow">return</span> result.string();</div><div class="line"><a name="l01958"></a><span class="lineno"> 1958</span> }</div><div class="line"><a name="l01959"></a><span class="lineno"> 1959</span> </div><div class="line"><a name="l01960"></a><span class="lineno"> 1960</span> <span class="comment">// Returns true iff the wildcard pattern matches the string. The</span></div><div class="line"><a name="l01961"></a><span class="lineno"> 1961</span> <span class="comment">// first ':' or '\0' character in pattern marks the end of it.</span></div><div class="line"><a name="l01962"></a><span class="lineno"> 1962</span> <span class="comment">//</span></div><div class="line"><a name="l01963"></a><span class="lineno"> 1963</span> <span class="comment">// This recursive algorithm isn't very efficient, but is clear and</span></div><div class="line"><a name="l01964"></a><span class="lineno"> 1964</span> <span class="comment">// works well enough for matching test names, which are short.</span></div><div class="line"><a name="l01965"></a><span class="lineno"> 1965</span> <span class="keywordtype">bool</span> UnitTestOptions::PatternMatchesString(<span class="keyword">const</span> <span class="keywordtype">char</span> *pattern,</div><div class="line"><a name="l01966"></a><span class="lineno"> 1966</span>  <span class="keyword">const</span> <span class="keywordtype">char</span> *str) {</div><div class="line"><a name="l01967"></a><span class="lineno"> 1967</span>  <span class="keywordflow">switch</span> (*pattern) {</div><div class="line"><a name="l01968"></a><span class="lineno"> 1968</span>  <span class="keywordflow">case</span> <span class="charliteral">'\0'</span>:</div><div class="line"><a name="l01969"></a><span class="lineno"> 1969</span>  <span class="keywordflow">case</span> <span class="charliteral">':'</span>: <span class="comment">// Either ':' or '\0' marks the end of the pattern.</span></div><div class="line"><a name="l01970"></a><span class="lineno"> 1970</span>  <span class="keywordflow">return</span> *str == <span class="charliteral">'\0'</span>;</div><div class="line"><a name="l01971"></a><span class="lineno"> 1971</span>  <span class="keywordflow">case</span> <span class="charliteral">'?'</span>: <span class="comment">// Matches any single character.</span></div><div class="line"><a name="l01972"></a><span class="lineno"> 1972</span>  <span class="keywordflow">return</span> *str != <span class="charliteral">'\0'</span> && PatternMatchesString(pattern + 1, str + 1);</div><div class="line"><a name="l01973"></a><span class="lineno"> 1973</span>  <span class="keywordflow">case</span> <span class="charliteral">'*'</span>: <span class="comment">// Matches any string (possibly empty) of characters.</span></div><div class="line"><a name="l01974"></a><span class="lineno"> 1974</span>  <span class="keywordflow">return</span> (*str != <span class="charliteral">'\0'</span> && PatternMatchesString(pattern, str + 1)) ||</div><div class="line"><a name="l01975"></a><span class="lineno"> 1975</span>  PatternMatchesString(pattern + 1, str);</div><div class="line"><a name="l01976"></a><span class="lineno"> 1976</span>  <span class="keywordflow">default</span>: <span class="comment">// Non-special character. Matches itself.</span></div><div class="line"><a name="l01977"></a><span class="lineno"> 1977</span>  <span class="keywordflow">return</span> *pattern == *str &&</div><div class="line"><a name="l01978"></a><span class="lineno"> 1978</span>  PatternMatchesString(pattern + 1, str + 1);</div><div class="line"><a name="l01979"></a><span class="lineno"> 1979</span>  }</div><div class="line"><a name="l01980"></a><span class="lineno"> 1980</span> }</div><div class="line"><a name="l01981"></a><span class="lineno"> 1981</span> </div><div class="line"><a name="l01982"></a><span class="lineno"> 1982</span> <span class="keywordtype">bool</span> UnitTestOptions::MatchesFilter(</div><div class="line"><a name="l01983"></a><span class="lineno"> 1983</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& name, <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="namespaceutl_1_1meta.html#ac72acc616316c322e750d20a46553ba4">filter</a>) {</div><div class="line"><a name="l01984"></a><span class="lineno"> 1984</span>  <span class="keyword">const</span> <span class="keywordtype">char</span> *cur_pattern = <a class="code" href="namespaceutl_1_1meta.html#ac72acc616316c322e750d20a46553ba4">filter</a>;</div><div class="line"><a name="l01985"></a><span class="lineno"> 1985</span>  <span class="keywordflow">for</span> (;;) {</div><div class="line"><a name="l01986"></a><span class="lineno"> 1986</span>  <span class="keywordflow">if</span> (PatternMatchesString(cur_pattern, name.c_str())) {</div><div class="line"><a name="l01987"></a><span class="lineno"> 1987</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l01988"></a><span class="lineno"> 1988</span>  }</div><div class="line"><a name="l01989"></a><span class="lineno"> 1989</span> </div><div class="line"><a name="l01990"></a><span class="lineno"> 1990</span>  <span class="comment">// Finds the next pattern in the filter.</span></div><div class="line"><a name="l01991"></a><span class="lineno"> 1991</span>  cur_pattern = strchr(cur_pattern, <span class="charliteral">':'</span>);</div><div class="line"><a name="l01992"></a><span class="lineno"> 1992</span> </div><div class="line"><a name="l01993"></a><span class="lineno"> 1993</span>  <span class="comment">// Returns if no more pattern can be found.</span></div><div class="line"><a name="l01994"></a><span class="lineno"> 1994</span>  <span class="keywordflow">if</span> (cur_pattern == <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l01995"></a><span class="lineno"> 1995</span>  <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l01996"></a><span class="lineno"> 1996</span>  }</div><div class="line"><a name="l01997"></a><span class="lineno"> 1997</span> </div><div class="line"><a name="l01998"></a><span class="lineno"> 1998</span>  <span class="comment">// Skips the pattern separater (the ':' character).</span></div><div class="line"><a name="l01999"></a><span class="lineno"> 1999</span>  cur_pattern++;</div><div class="line"><a name="l02000"></a><span class="lineno"> 2000</span>  }</div><div class="line"><a name="l02001"></a><span class="lineno"> 2001</span> }</div><div class="line"><a name="l02002"></a><span class="lineno"> 2002</span> </div><div class="line"><a name="l02003"></a><span class="lineno"> 2003</span> <span class="comment">// Returns true iff the user-specified filter matches the test suite</span></div><div class="line"><a name="l02004"></a><span class="lineno"> 2004</span> <span class="comment">// name and the test name.</span></div><div class="line"><a name="l02005"></a><span class="lineno"> 2005</span> <span class="keywordtype">bool</span> UnitTestOptions::FilterMatchesTest(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& test_suite_name,</div><div class="line"><a name="l02006"></a><span class="lineno"> 2006</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& test_name) {</div><div class="line"><a name="l02007"></a><span class="lineno"> 2007</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& full_name = test_suite_name + <span class="stringliteral">"."</span> + test_name.c_str();</div><div class="line"><a name="l02008"></a><span class="lineno"> 2008</span> </div><div class="line"><a name="l02009"></a><span class="lineno"> 2009</span>  <span class="comment">// Split --gtest_filter at '-', if there is one, to separate into</span></div><div class="line"><a name="l02010"></a><span class="lineno"> 2010</span>  <span class="comment">// positive filter and negative filter portions</span></div><div class="line"><a name="l02011"></a><span class="lineno"> 2011</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> p = <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(<a class="code" href="namespaceutl_1_1meta.html#ac72acc616316c322e750d20a46553ba4">filter</a>).c_str();</div><div class="line"><a name="l02012"></a><span class="lineno"> 2012</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> dash = strchr(p, <span class="charliteral">'-'</span>);</div><div class="line"><a name="l02013"></a><span class="lineno"> 2013</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> positive;</div><div class="line"><a name="l02014"></a><span class="lineno"> 2014</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> negative;</div><div class="line"><a name="l02015"></a><span class="lineno"> 2015</span>  <span class="keywordflow">if</span> (dash == <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l02016"></a><span class="lineno"> 2016</span>  positive = <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(<a class="code" href="namespaceutl_1_1meta.html#ac72acc616316c322e750d20a46553ba4">filter</a>).c_str(); <span class="comment">// Whole string is a positive filter</span></div><div class="line"><a name="l02017"></a><span class="lineno"> 2017</span>  negative = <span class="stringliteral">""</span>;</div><div class="line"><a name="l02018"></a><span class="lineno"> 2018</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l02019"></a><span class="lineno"> 2019</span>  positive = <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(p, dash); <span class="comment">// Everything up to the dash</span></div><div class="line"><a name="l02020"></a><span class="lineno"> 2020</span>  negative = <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(dash + 1); <span class="comment">// Everything after the dash</span></div><div class="line"><a name="l02021"></a><span class="lineno"> 2021</span>  <span class="keywordflow">if</span> (positive.empty()) {</div><div class="line"><a name="l02022"></a><span class="lineno"> 2022</span>  <span class="comment">// Treat '-test1' as the same as '*-test1'</span></div><div class="line"><a name="l02023"></a><span class="lineno"> 2023</span>  positive = kUniversalFilter;</div><div class="line"><a name="l02024"></a><span class="lineno"> 2024</span>  }</div><div class="line"><a name="l02025"></a><span class="lineno"> 2025</span>  }</div><div class="line"><a name="l02026"></a><span class="lineno"> 2026</span> </div><div class="line"><a name="l02027"></a><span class="lineno"> 2027</span>  <span class="comment">// A filter is a colon-separated list of patterns. It matches a</span></div><div class="line"><a name="l02028"></a><span class="lineno"> 2028</span>  <span class="comment">// test if any pattern in it matches the test.</span></div><div class="line"><a name="l02029"></a><span class="lineno"> 2029</span>  <span class="keywordflow">return</span> (MatchesFilter(full_name, positive.c_str()) &&</div><div class="line"><a name="l02030"></a><span class="lineno"> 2030</span>  !MatchesFilter(full_name, negative.c_str()));</div><div class="line"><a name="l02031"></a><span class="lineno"> 2031</span> }</div><div class="line"><a name="l02032"></a><span class="lineno"> 2032</span> </div><div class="line"><a name="l02033"></a><span class="lineno"> 2033</span> <span class="preprocessor">#if GTEST_HAS_SEH</span></div><div class="line"><a name="l02034"></a><span class="lineno"> 2034</span> <span class="comment">// Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the</span></div><div class="line"><a name="l02035"></a><span class="lineno"> 2035</span> <span class="comment">// given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise.</span></div><div class="line"><a name="l02036"></a><span class="lineno"> 2036</span> <span class="comment">// This function is useful as an __except condition.</span></div><div class="line"><a name="l02037"></a><span class="lineno"> 2037</span> <span class="keywordtype">int</span> UnitTestOptions::GTestShouldProcessSEH(DWORD exception_code) {</div><div class="line"><a name="l02038"></a><span class="lineno"> 2038</span>  <span class="comment">// Google Test should handle a SEH exception if:</span></div><div class="line"><a name="l02039"></a><span class="lineno"> 2039</span>  <span class="comment">// 1. the user wants it to, AND</span></div><div class="line"><a name="l02040"></a><span class="lineno"> 2040</span>  <span class="comment">// 2. this is not a breakpoint exception, AND</span></div><div class="line"><a name="l02041"></a><span class="lineno"> 2041</span>  <span class="comment">// 3. this is not a C++ exception (VC++ implements them via SEH,</span></div><div class="line"><a name="l02042"></a><span class="lineno"> 2042</span>  <span class="comment">// apparently).</span></div><div class="line"><a name="l02043"></a><span class="lineno"> 2043</span>  <span class="comment">//</span></div><div class="line"><a name="l02044"></a><span class="lineno"> 2044</span>  <span class="comment">// SEH exception code for C++ exceptions.</span></div><div class="line"><a name="l02045"></a><span class="lineno"> 2045</span>  <span class="comment">// (see http://support.microsoft.com/kb/185294 for more information).</span></div><div class="line"><a name="l02046"></a><span class="lineno"> 2046</span>  <span class="keyword">const</span> DWORD kCxxExceptionCode = 0xe06d7363;</div><div class="line"><a name="l02047"></a><span class="lineno"> 2047</span> </div><div class="line"><a name="l02048"></a><span class="lineno"> 2048</span>  <span class="keywordtype">bool</span> should_handle = <span class="keyword">true</span>;</div><div class="line"><a name="l02049"></a><span class="lineno"> 2049</span> </div><div class="line"><a name="l02050"></a><span class="lineno"> 2050</span>  <span class="keywordflow">if</span> (!<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(catch_exceptions))</div><div class="line"><a name="l02051"></a><span class="lineno"> 2051</span>  should_handle = <span class="keyword">false</span>;</div><div class="line"><a name="l02052"></a><span class="lineno"> 2052</span>  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (exception_code == EXCEPTION_BREAKPOINT)</div><div class="line"><a name="l02053"></a><span class="lineno"> 2053</span>  should_handle = <span class="keyword">false</span>;</div><div class="line"><a name="l02054"></a><span class="lineno"> 2054</span>  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (exception_code == kCxxExceptionCode)</div><div class="line"><a name="l02055"></a><span class="lineno"> 2055</span>  should_handle = <span class="keyword">false</span>;</div><div class="line"><a name="l02056"></a><span class="lineno"> 2056</span> </div><div class="line"><a name="l02057"></a><span class="lineno"> 2057</span>  <span class="keywordflow">return</span> should_handle ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH;</div><div class="line"><a name="l02058"></a><span class="lineno"> 2058</span> }</div><div class="line"><a name="l02059"></a><span class="lineno"> 2059</span> <span class="preprocessor">#endif // GTEST_HAS_SEH</span></div><div class="line"><a name="l02060"></a><span class="lineno"> 2060</span> </div><div class="line"><a name="l02061"></a><span class="lineno"> 2061</span> } <span class="comment">// namespace internal</span></div><div class="line"><a name="l02062"></a><span class="lineno"> 2062</span> </div><div class="line"><a name="l02063"></a><span class="lineno"> 2063</span> <span class="comment">// The c'tor sets this object as the test part result reporter used by</span></div><div class="line"><a name="l02064"></a><span class="lineno"> 2064</span> <span class="comment">// Google Test. The 'result' parameter specifies where to report the</span></div><div class="line"><a name="l02065"></a><span class="lineno"> 2065</span> <span class="comment">// results. Intercepts only failures from the current thread.</span></div><div class="line"><a name="l02066"></a><span class="lineno"> 2066</span> ScopedFakeTestPartResultReporter::ScopedFakeTestPartResultReporter(</div><div class="line"><a name="l02067"></a><span class="lineno"> 2067</span>  TestPartResultArray* result)</div><div class="line"><a name="l02068"></a><span class="lineno"> 2068</span>  : intercept_mode_(INTERCEPT_ONLY_CURRENT_THREAD),</div><div class="line"><a name="l02069"></a><span class="lineno"> 2069</span>  result_(result) {</div><div class="line"><a name="l02070"></a><span class="lineno"> 2070</span>  Init();</div><div class="line"><a name="l02071"></a><span class="lineno"> 2071</span> }</div><div class="line"><a name="l02072"></a><span class="lineno"> 2072</span> </div><div class="line"><a name="l02073"></a><span class="lineno"> 2073</span> <span class="comment">// The c'tor sets this object as the test part result reporter used by</span></div><div class="line"><a name="l02074"></a><span class="lineno"> 2074</span> <span class="comment">// Google Test. The 'result' parameter specifies where to report the</span></div><div class="line"><a name="l02075"></a><span class="lineno"> 2075</span> <span class="comment">// results.</span></div><div class="line"><a name="l02076"></a><span class="lineno"> 2076</span> ScopedFakeTestPartResultReporter::ScopedFakeTestPartResultReporter(</div><div class="line"><a name="l02077"></a><span class="lineno"> 2077</span>  InterceptMode intercept_mode, TestPartResultArray* result)</div><div class="line"><a name="l02078"></a><span class="lineno"> 2078</span>  : intercept_mode_(intercept_mode),</div><div class="line"><a name="l02079"></a><span class="lineno"> 2079</span>  result_(result) {</div><div class="line"><a name="l02080"></a><span class="lineno"> 2080</span>  Init();</div><div class="line"><a name="l02081"></a><span class="lineno"> 2081</span> }</div><div class="line"><a name="l02082"></a><span class="lineno"> 2082</span> </div><div class="line"><a name="l02083"></a><span class="lineno"> 2083</span> <span class="keywordtype">void</span> ScopedFakeTestPartResultReporter::Init() {</div><div class="line"><a name="l02084"></a><span class="lineno"> 2084</span>  internal::UnitTestImpl* <span class="keyword">const</span> impl = internal::GetUnitTestImpl();</div><div class="line"><a name="l02085"></a><span class="lineno"> 2085</span>  <span class="keywordflow">if</span> (intercept_mode_ == INTERCEPT_ALL_THREADS) {</div><div class="line"><a name="l02086"></a><span class="lineno"> 2086</span>  old_reporter_ = impl->GetGlobalTestPartResultReporter();</div><div class="line"><a name="l02087"></a><span class="lineno"> 2087</span>  impl->SetGlobalTestPartResultReporter(<span class="keyword">this</span>);</div><div class="line"><a name="l02088"></a><span class="lineno"> 2088</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l02089"></a><span class="lineno"> 2089</span>  old_reporter_ = impl->GetTestPartResultReporterForCurrentThread();</div><div class="line"><a name="l02090"></a><span class="lineno"> 2090</span>  impl->SetTestPartResultReporterForCurrentThread(<span class="keyword">this</span>);</div><div class="line"><a name="l02091"></a><span class="lineno"> 2091</span>  }</div><div class="line"><a name="l02092"></a><span class="lineno"> 2092</span> }</div><div class="line"><a name="l02093"></a><span class="lineno"> 2093</span> </div><div class="line"><a name="l02094"></a><span class="lineno"> 2094</span> <span class="comment">// The d'tor restores the test part result reporter used by Google Test</span></div><div class="line"><a name="l02095"></a><span class="lineno"> 2095</span> <span class="comment">// before.</span></div><div class="line"><a name="l02096"></a><span class="lineno"> 2096</span> ScopedFakeTestPartResultReporter::~ScopedFakeTestPartResultReporter() {</div><div class="line"><a name="l02097"></a><span class="lineno"> 2097</span>  internal::UnitTestImpl* <span class="keyword">const</span> impl = internal::GetUnitTestImpl();</div><div class="line"><a name="l02098"></a><span class="lineno"> 2098</span>  <span class="keywordflow">if</span> (intercept_mode_ == INTERCEPT_ALL_THREADS) {</div><div class="line"><a name="l02099"></a><span class="lineno"> 2099</span>  impl->SetGlobalTestPartResultReporter(old_reporter_);</div><div class="line"><a name="l02100"></a><span class="lineno"> 2100</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l02101"></a><span class="lineno"> 2101</span>  impl->SetTestPartResultReporterForCurrentThread(old_reporter_);</div><div class="line"><a name="l02102"></a><span class="lineno"> 2102</span>  }</div><div class="line"><a name="l02103"></a><span class="lineno"> 2103</span> }</div><div class="line"><a name="l02104"></a><span class="lineno"> 2104</span> </div><div class="line"><a name="l02105"></a><span class="lineno"> 2105</span> <span class="comment">// Increments the test part result count and remembers the result.</span></div><div class="line"><a name="l02106"></a><span class="lineno"> 2106</span> <span class="comment">// This method is from the TestPartResultReporterInterface interface.</span></div><div class="line"><a name="l02107"></a><span class="lineno"> 2107</span> <span class="keywordtype">void</span> ScopedFakeTestPartResultReporter::ReportTestPartResult(</div><div class="line"><a name="l02108"></a><span class="lineno"> 2108</span>  <span class="keyword">const</span> TestPartResult& result) {</div><div class="line"><a name="l02109"></a><span class="lineno"> 2109</span>  result_->Append(result);</div><div class="line"><a name="l02110"></a><span class="lineno"> 2110</span> }</div><div class="line"><a name="l02111"></a><span class="lineno"> 2111</span> </div><div class="line"><a name="l02112"></a><span class="lineno"> 2112</span> <span class="keyword">namespace </span>internal {</div><div class="line"><a name="l02113"></a><span class="lineno"> 2113</span> </div><div class="line"><a name="l02114"></a><span class="lineno"> 2114</span> <span class="comment">// Returns the type ID of ::testing::Test. We should always call this</span></div><div class="line"><a name="l02115"></a><span class="lineno"> 2115</span> <span class="comment">// instead of GetTypeId< ::testing::Test>() to get the type ID of</span></div><div class="line"><a name="l02116"></a><span class="lineno"> 2116</span> <span class="comment">// testing::Test. This is to work around a suspected linker bug when</span></div><div class="line"><a name="l02117"></a><span class="lineno"> 2117</span> <span class="comment">// using Google Test as a framework on Mac OS X. The bug causes</span></div><div class="line"><a name="l02118"></a><span class="lineno"> 2118</span> <span class="comment">// GetTypeId< ::testing::Test>() to return different values depending</span></div><div class="line"><a name="l02119"></a><span class="lineno"> 2119</span> <span class="comment">// on whether the call is from the Google Test framework itself or</span></div><div class="line"><a name="l02120"></a><span class="lineno"> 2120</span> <span class="comment">// from user test code. GetTestTypeId() is guaranteed to always</span></div><div class="line"><a name="l02121"></a><span class="lineno"> 2121</span> <span class="comment">// return the same value, as it always calls GetTypeId<>() from the</span></div><div class="line"><a name="l02122"></a><span class="lineno"> 2122</span> <span class="comment">// gtest.cc, which is within the Google Test framework.</span></div><div class="line"><a name="l02123"></a><span class="lineno"> 2123</span> <a class="code" href="namespacetesting_1_1internal.html#ab1114197d3c657d8b7f8e0c5caa12d00">TypeId</a> <a class="code" href="namespacetesting_1_1internal.html#a1e85cf16bb95b60f879d48ba1fbfc1c9">GetTestTypeId</a>() {</div><div class="line"><a name="l02124"></a><span class="lineno"> 2124</span>  <span class="keywordflow">return</span> GetTypeId<Test>();</div><div class="line"><a name="l02125"></a><span class="lineno"> 2125</span> }</div><div class="line"><a name="l02126"></a><span class="lineno"> 2126</span> </div><div class="line"><a name="l02127"></a><span class="lineno"> 2127</span> <span class="comment">// The value of GetTestTypeId() as seen from within the Google Test</span></div><div class="line"><a name="l02128"></a><span class="lineno"> 2128</span> <span class="comment">// library. This is solely for testing GetTestTypeId().</span></div><div class="line"><a name="l02129"></a><span class="lineno"> 2129</span> <span class="keyword">extern</span> <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#ab1114197d3c657d8b7f8e0c5caa12d00">TypeId</a> kTestTypeIdInGoogleTest = <a class="code" href="namespacetesting_1_1internal.html#a1e85cf16bb95b60f879d48ba1fbfc1c9">GetTestTypeId</a>();</div><div class="line"><a name="l02130"></a><span class="lineno"> 2130</span> </div><div class="line"><a name="l02131"></a><span class="lineno"> 2131</span> <span class="comment">// This predicate-formatter checks that 'results' contains a test part</span></div><div class="line"><a name="l02132"></a><span class="lineno"> 2132</span> <span class="comment">// failure of the given type and that the failure message contains the</span></div><div class="line"><a name="l02133"></a><span class="lineno"> 2133</span> <span class="comment">// given substring.</span></div><div class="line"><a name="l02134"></a><span class="lineno"> 2134</span> <span class="keyword">static</span> AssertionResult HasOneFailure(<span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="comment">/* results_expr */</span>,</div><div class="line"><a name="l02135"></a><span class="lineno"> 2135</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="comment">/* type_expr */</span>,</div><div class="line"><a name="l02136"></a><span class="lineno"> 2136</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="comment">/* substr_expr */</span>,</div><div class="line"><a name="l02137"></a><span class="lineno"> 2137</span>  <span class="keyword">const</span> TestPartResultArray& results,</div><div class="line"><a name="l02138"></a><span class="lineno"> 2138</span>  TestPartResult::Type type,</div><div class="line"><a name="l02139"></a><span class="lineno"> 2139</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& substr) {</div><div class="line"><a name="l02140"></a><span class="lineno"> 2140</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> expected(type == TestPartResult::kFatalFailure ?</div><div class="line"><a name="l02141"></a><span class="lineno"> 2141</span>  <span class="stringliteral">"1 fatal failure"</span> :</div><div class="line"><a name="l02142"></a><span class="lineno"> 2142</span>  <span class="stringliteral">"1 non-fatal failure"</span>);</div><div class="line"><a name="l02143"></a><span class="lineno"> 2143</span>  Message msg;</div><div class="line"><a name="l02144"></a><span class="lineno"> 2144</span>  <span class="keywordflow">if</span> (results.size() != 1) {</div><div class="line"><a name="l02145"></a><span class="lineno"> 2145</span>  msg << <span class="stringliteral">"Expected: "</span> << expected << <span class="stringliteral">"\n"</span></div><div class="line"><a name="l02146"></a><span class="lineno"> 2146</span>  << <span class="stringliteral">" Actual: "</span> << results.size() << <span class="stringliteral">" failures"</span>;</div><div class="line"><a name="l02147"></a><span class="lineno"> 2147</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < results.size(); i++) {</div><div class="line"><a name="l02148"></a><span class="lineno"> 2148</span>  msg << <span class="stringliteral">"\n"</span> << results.GetTestPartResult(i);</div><div class="line"><a name="l02149"></a><span class="lineno"> 2149</span>  }</div><div class="line"><a name="l02150"></a><span class="lineno"> 2150</span>  <span class="keywordflow">return</span> AssertionFailure() << msg;</div><div class="line"><a name="l02151"></a><span class="lineno"> 2151</span>  }</div><div class="line"><a name="l02152"></a><span class="lineno"> 2152</span> </div><div class="line"><a name="l02153"></a><span class="lineno"> 2153</span>  <span class="keyword">const</span> TestPartResult& r = results.GetTestPartResult(0);</div><div class="line"><a name="l02154"></a><span class="lineno"> 2154</span>  <span class="keywordflow">if</span> (r.type() != type) {</div><div class="line"><a name="l02155"></a><span class="lineno"> 2155</span>  <span class="keywordflow">return</span> AssertionFailure() << <span class="stringliteral">"Expected: "</span> << expected << <span class="stringliteral">"\n"</span></div><div class="line"><a name="l02156"></a><span class="lineno"> 2156</span>  << <span class="stringliteral">" Actual:\n"</span></div><div class="line"><a name="l02157"></a><span class="lineno"> 2157</span>  << r;</div><div class="line"><a name="l02158"></a><span class="lineno"> 2158</span>  }</div><div class="line"><a name="l02159"></a><span class="lineno"> 2159</span> </div><div class="line"><a name="l02160"></a><span class="lineno"> 2160</span>  <span class="keywordflow">if</span> (strstr(r.message(), substr.c_str()) == <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l02161"></a><span class="lineno"> 2161</span>  <span class="keywordflow">return</span> AssertionFailure() << <span class="stringliteral">"Expected: "</span> << expected << <span class="stringliteral">" containing \""</span></div><div class="line"><a name="l02162"></a><span class="lineno"> 2162</span>  << substr << <span class="stringliteral">"\"\n"</span></div><div class="line"><a name="l02163"></a><span class="lineno"> 2163</span>  << <span class="stringliteral">" Actual:\n"</span></div><div class="line"><a name="l02164"></a><span class="lineno"> 2164</span>  << r;</div><div class="line"><a name="l02165"></a><span class="lineno"> 2165</span>  }</div><div class="line"><a name="l02166"></a><span class="lineno"> 2166</span> </div><div class="line"><a name="l02167"></a><span class="lineno"> 2167</span>  <span class="keywordflow">return</span> AssertionSuccess();</div><div class="line"><a name="l02168"></a><span class="lineno"> 2168</span> }</div><div class="line"><a name="l02169"></a><span class="lineno"> 2169</span> </div><div class="line"><a name="l02170"></a><span class="lineno"> 2170</span> <span class="comment">// The constructor of SingleFailureChecker remembers where to look up</span></div><div class="line"><a name="l02171"></a><span class="lineno"> 2171</span> <span class="comment">// test part results, what type of failure we expect, and what</span></div><div class="line"><a name="l02172"></a><span class="lineno"> 2172</span> <span class="comment">// substring the failure message should contain.</span></div><div class="line"><a name="l02173"></a><span class="lineno"> 2173</span> SingleFailureChecker::SingleFailureChecker(<span class="keyword">const</span> TestPartResultArray* results,</div><div class="line"><a name="l02174"></a><span class="lineno"> 2174</span>  TestPartResult::Type type,</div><div class="line"><a name="l02175"></a><span class="lineno"> 2175</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& substr)</div><div class="line"><a name="l02176"></a><span class="lineno"> 2176</span>  : results_(results), type_(type), substr_(substr) {}</div><div class="line"><a name="l02177"></a><span class="lineno"> 2177</span> </div><div class="line"><a name="l02178"></a><span class="lineno"> 2178</span> <span class="comment">// The destructor of SingleFailureChecker verifies that the given</span></div><div class="line"><a name="l02179"></a><span class="lineno"> 2179</span> <span class="comment">// TestPartResultArray contains exactly one failure that has the given</span></div><div class="line"><a name="l02180"></a><span class="lineno"> 2180</span> <span class="comment">// type and contains the given substring. If that's not the case, a</span></div><div class="line"><a name="l02181"></a><span class="lineno"> 2181</span> <span class="comment">// non-fatal failure will be generated.</span></div><div class="line"><a name="l02182"></a><span class="lineno"> 2182</span> SingleFailureChecker::~SingleFailureChecker() {</div><div class="line"><a name="l02183"></a><span class="lineno"> 2183</span>  <a class="code" href="gtest_8h.html#a7285708fa5d37d6d8ed5b5e59da08bae">EXPECT_PRED_FORMAT3</a>(HasOneFailure, *results_, type_, substr_);</div><div class="line"><a name="l02184"></a><span class="lineno"> 2184</span> }</div><div class="line"><a name="l02185"></a><span class="lineno"> 2185</span> </div><div class="line"><a name="l02186"></a><span class="lineno"> 2186</span> DefaultGlobalTestPartResultReporter::DefaultGlobalTestPartResultReporter(</div><div class="line"><a name="l02187"></a><span class="lineno"> 2187</span>  UnitTestImpl* unit_test) : unit_test_(unit_test) {}</div><div class="line"><a name="l02188"></a><span class="lineno"> 2188</span> </div><div class="line"><a name="l02189"></a><span class="lineno"> 2189</span> <span class="keywordtype">void</span> DefaultGlobalTestPartResultReporter::ReportTestPartResult(</div><div class="line"><a name="l02190"></a><span class="lineno"> 2190</span>  <span class="keyword">const</span> TestPartResult& result) {</div><div class="line"><a name="l02191"></a><span class="lineno"> 2191</span>  unit_test_->current_test_result()->AddTestPartResult(result);</div><div class="line"><a name="l02192"></a><span class="lineno"> 2192</span>  unit_test_->listeners()->repeater()->OnTestPartResult(result);</div><div class="line"><a name="l02193"></a><span class="lineno"> 2193</span> }</div><div class="line"><a name="l02194"></a><span class="lineno"> 2194</span> </div><div class="line"><a name="l02195"></a><span class="lineno"> 2195</span> DefaultPerThreadTestPartResultReporter::DefaultPerThreadTestPartResultReporter(</div><div class="line"><a name="l02196"></a><span class="lineno"> 2196</span>  UnitTestImpl* unit_test) : unit_test_(unit_test) {}</div><div class="line"><a name="l02197"></a><span class="lineno"> 2197</span> </div><div class="line"><a name="l02198"></a><span class="lineno"> 2198</span> <span class="keywordtype">void</span> DefaultPerThreadTestPartResultReporter::ReportTestPartResult(</div><div class="line"><a name="l02199"></a><span class="lineno"> 2199</span>  <span class="keyword">const</span> TestPartResult& result) {</div><div class="line"><a name="l02200"></a><span class="lineno"> 2200</span>  unit_test_->GetGlobalTestPartResultReporter()->ReportTestPartResult(result);</div><div class="line"><a name="l02201"></a><span class="lineno"> 2201</span> }</div><div class="line"><a name="l02202"></a><span class="lineno"> 2202</span> </div><div class="line"><a name="l02203"></a><span class="lineno"> 2203</span> <span class="comment">// Returns the global test part result reporter.</span></div><div class="line"><a name="l02204"></a><span class="lineno"> 2204</span> TestPartResultReporterInterface*</div><div class="line"><a name="l02205"></a><span class="lineno"> 2205</span> UnitTestImpl::GetGlobalTestPartResultReporter() {</div><div class="line"><a name="l02206"></a><span class="lineno"> 2206</span>  <a class="code" href="namespacetesting_1_1internal.html#a08b187c6cc4e28400aadf9a32fccc8de">internal::MutexLock</a> lock(&global_test_part_result_reporter_mutex_);</div><div class="line"><a name="l02207"></a><span class="lineno"> 2207</span>  <span class="keywordflow">return</span> global_test_part_result_repoter_;</div><div class="line"><a name="l02208"></a><span class="lineno"> 2208</span> }</div><div class="line"><a name="l02209"></a><span class="lineno"> 2209</span> </div><div class="line"><a name="l02210"></a><span class="lineno"> 2210</span> <span class="comment">// Sets the global test part result reporter.</span></div><div class="line"><a name="l02211"></a><span class="lineno"> 2211</span> <span class="keywordtype">void</span> UnitTestImpl::SetGlobalTestPartResultReporter(</div><div class="line"><a name="l02212"></a><span class="lineno"> 2212</span>  TestPartResultReporterInterface* reporter) {</div><div class="line"><a name="l02213"></a><span class="lineno"> 2213</span>  <a class="code" href="namespacetesting_1_1internal.html#a08b187c6cc4e28400aadf9a32fccc8de">internal::MutexLock</a> lock(&global_test_part_result_reporter_mutex_);</div><div class="line"><a name="l02214"></a><span class="lineno"> 2214</span>  global_test_part_result_repoter_ = reporter;</div><div class="line"><a name="l02215"></a><span class="lineno"> 2215</span> }</div><div class="line"><a name="l02216"></a><span class="lineno"> 2216</span> </div><div class="line"><a name="l02217"></a><span class="lineno"> 2217</span> <span class="comment">// Returns the test part result reporter for the current thread.</span></div><div class="line"><a name="l02218"></a><span class="lineno"> 2218</span> TestPartResultReporterInterface*</div><div class="line"><a name="l02219"></a><span class="lineno"> 2219</span> UnitTestImpl::GetTestPartResultReporterForCurrentThread() {</div><div class="line"><a name="l02220"></a><span class="lineno"> 2220</span>  <span class="keywordflow">return</span> per_thread_test_part_result_reporter_.get();</div><div class="line"><a name="l02221"></a><span class="lineno"> 2221</span> }</div><div class="line"><a name="l02222"></a><span class="lineno"> 2222</span> </div><div class="line"><a name="l02223"></a><span class="lineno"> 2223</span> <span class="comment">// Sets the test part result reporter for the current thread.</span></div><div class="line"><a name="l02224"></a><span class="lineno"> 2224</span> <span class="keywordtype">void</span> UnitTestImpl::SetTestPartResultReporterForCurrentThread(</div><div class="line"><a name="l02225"></a><span class="lineno"> 2225</span>  TestPartResultReporterInterface* reporter) {</div><div class="line"><a name="l02226"></a><span class="lineno"> 2226</span>  per_thread_test_part_result_reporter_.set(reporter);</div><div class="line"><a name="l02227"></a><span class="lineno"> 2227</span> }</div><div class="line"><a name="l02228"></a><span class="lineno"> 2228</span> </div><div class="line"><a name="l02229"></a><span class="lineno"> 2229</span> <span class="comment">// Gets the number of successful test suites.</span></div><div class="line"><a name="l02230"></a><span class="lineno"> 2230</span> <span class="keywordtype">int</span> UnitTestImpl::successful_test_suite_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l02231"></a><span class="lineno"> 2231</span>  <span class="keywordflow">return</span> CountIf(test_suites_, TestSuitePassed);</div><div class="line"><a name="l02232"></a><span class="lineno"> 2232</span> }</div><div class="line"><a name="l02233"></a><span class="lineno"> 2233</span> </div><div class="line"><a name="l02234"></a><span class="lineno"> 2234</span> <span class="comment">// Gets the number of failed test suites.</span></div><div class="line"><a name="l02235"></a><span class="lineno"> 2235</span> <span class="keywordtype">int</span> UnitTestImpl::failed_test_suite_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l02236"></a><span class="lineno"> 2236</span>  <span class="keywordflow">return</span> CountIf(test_suites_, TestSuiteFailed);</div><div class="line"><a name="l02237"></a><span class="lineno"> 2237</span> }</div><div class="line"><a name="l02238"></a><span class="lineno"> 2238</span> </div><div class="line"><a name="l02239"></a><span class="lineno"> 2239</span> <span class="comment">// Gets the number of all test suites.</span></div><div class="line"><a name="l02240"></a><span class="lineno"> 2240</span> <span class="keywordtype">int</span> UnitTestImpl::total_test_suite_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l02241"></a><span class="lineno"> 2241</span>  <span class="keywordflow">return</span> <span class="keyword">static_cast<</span><span class="keywordtype">int</span><span class="keyword">></span>(test_suites_.size());</div><div class="line"><a name="l02242"></a><span class="lineno"> 2242</span> }</div><div class="line"><a name="l02243"></a><span class="lineno"> 2243</span> </div><div class="line"><a name="l02244"></a><span class="lineno"> 2244</span> <span class="comment">// Gets the number of all test suites that contain at least one test</span></div><div class="line"><a name="l02245"></a><span class="lineno"> 2245</span> <span class="comment">// that should run.</span></div><div class="line"><a name="l02246"></a><span class="lineno"> 2246</span> <span class="keywordtype">int</span> UnitTestImpl::test_suite_to_run_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l02247"></a><span class="lineno"> 2247</span>  <span class="keywordflow">return</span> CountIf(test_suites_, ShouldRunTestSuite);</div><div class="line"><a name="l02248"></a><span class="lineno"> 2248</span> }</div><div class="line"><a name="l02249"></a><span class="lineno"> 2249</span> </div><div class="line"><a name="l02250"></a><span class="lineno"> 2250</span> <span class="comment">// Gets the number of successful tests.</span></div><div class="line"><a name="l02251"></a><span class="lineno"> 2251</span> <span class="keywordtype">int</span> UnitTestImpl::successful_test_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l02252"></a><span class="lineno"> 2252</span>  <span class="keywordflow">return</span> SumOverTestSuiteList(test_suites_, &TestSuite::successful_test_count);</div><div class="line"><a name="l02253"></a><span class="lineno"> 2253</span> }</div><div class="line"><a name="l02254"></a><span class="lineno"> 2254</span> </div><div class="line"><a name="l02255"></a><span class="lineno"> 2255</span> <span class="comment">// Gets the number of skipped tests.</span></div><div class="line"><a name="l02256"></a><span class="lineno"> 2256</span> <span class="keywordtype">int</span> UnitTestImpl::skipped_test_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l02257"></a><span class="lineno"> 2257</span>  <span class="keywordflow">return</span> SumOverTestSuiteList(test_suites_, &TestSuite::skipped_test_count);</div><div class="line"><a name="l02258"></a><span class="lineno"> 2258</span> }</div><div class="line"><a name="l02259"></a><span class="lineno"> 2259</span> </div><div class="line"><a name="l02260"></a><span class="lineno"> 2260</span> <span class="comment">// Gets the number of failed tests.</span></div><div class="line"><a name="l02261"></a><span class="lineno"> 2261</span> <span class="keywordtype">int</span> UnitTestImpl::failed_test_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l02262"></a><span class="lineno"> 2262</span>  <span class="keywordflow">return</span> SumOverTestSuiteList(test_suites_, &TestSuite::failed_test_count);</div><div class="line"><a name="l02263"></a><span class="lineno"> 2263</span> }</div><div class="line"><a name="l02264"></a><span class="lineno"> 2264</span> </div><div class="line"><a name="l02265"></a><span class="lineno"> 2265</span> <span class="comment">// Gets the number of disabled tests that will be reported in the XML report.</span></div><div class="line"><a name="l02266"></a><span class="lineno"> 2266</span> <span class="keywordtype">int</span> UnitTestImpl::reportable_disabled_test_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l02267"></a><span class="lineno"> 2267</span>  <span class="keywordflow">return</span> SumOverTestSuiteList(test_suites_,</div><div class="line"><a name="l02268"></a><span class="lineno"> 2268</span>  &TestSuite::reportable_disabled_test_count);</div><div class="line"><a name="l02269"></a><span class="lineno"> 2269</span> }</div><div class="line"><a name="l02270"></a><span class="lineno"> 2270</span> </div><div class="line"><a name="l02271"></a><span class="lineno"> 2271</span> <span class="comment">// Gets the number of disabled tests.</span></div><div class="line"><a name="l02272"></a><span class="lineno"> 2272</span> <span class="keywordtype">int</span> UnitTestImpl::disabled_test_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l02273"></a><span class="lineno"> 2273</span>  <span class="keywordflow">return</span> SumOverTestSuiteList(test_suites_, &TestSuite::disabled_test_count);</div><div class="line"><a name="l02274"></a><span class="lineno"> 2274</span> }</div><div class="line"><a name="l02275"></a><span class="lineno"> 2275</span> </div><div class="line"><a name="l02276"></a><span class="lineno"> 2276</span> <span class="comment">// Gets the number of tests to be printed in the XML report.</span></div><div class="line"><a name="l02277"></a><span class="lineno"> 2277</span> <span class="keywordtype">int</span> UnitTestImpl::reportable_test_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l02278"></a><span class="lineno"> 2278</span>  <span class="keywordflow">return</span> SumOverTestSuiteList(test_suites_, &TestSuite::reportable_test_count);</div><div class="line"><a name="l02279"></a><span class="lineno"> 2279</span> }</div><div class="line"><a name="l02280"></a><span class="lineno"> 2280</span> </div><div class="line"><a name="l02281"></a><span class="lineno"> 2281</span> <span class="comment">// Gets the number of all tests.</span></div><div class="line"><a name="l02282"></a><span class="lineno"> 2282</span> <span class="keywordtype">int</span> UnitTestImpl::total_test_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l02283"></a><span class="lineno"> 2283</span>  <span class="keywordflow">return</span> SumOverTestSuiteList(test_suites_, &TestSuite::total_test_count);</div><div class="line"><a name="l02284"></a><span class="lineno"> 2284</span> }</div><div class="line"><a name="l02285"></a><span class="lineno"> 2285</span> </div><div class="line"><a name="l02286"></a><span class="lineno"> 2286</span> <span class="comment">// Gets the number of tests that should run.</span></div><div class="line"><a name="l02287"></a><span class="lineno"> 2287</span> <span class="keywordtype">int</span> UnitTestImpl::test_to_run_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l02288"></a><span class="lineno"> 2288</span>  <span class="keywordflow">return</span> SumOverTestSuiteList(test_suites_, &TestSuite::test_to_run_count);</div><div class="line"><a name="l02289"></a><span class="lineno"> 2289</span> }</div><div class="line"><a name="l02290"></a><span class="lineno"> 2290</span> </div><div class="line"><a name="l02291"></a><span class="lineno"> 2291</span> <span class="comment">// Returns the current OS stack trace as an std::string.</span></div><div class="line"><a name="l02292"></a><span class="lineno"> 2292</span> <span class="comment">//</span></div><div class="line"><a name="l02293"></a><span class="lineno"> 2293</span> <span class="comment">// The maximum number of stack frames to be included is specified by</span></div><div class="line"><a name="l02294"></a><span class="lineno"> 2294</span> <span class="comment">// the gtest_stack_trace_depth flag. The skip_count parameter</span></div><div class="line"><a name="l02295"></a><span class="lineno"> 2295</span> <span class="comment">// specifies the number of top frames to be skipped, which doesn't</span></div><div class="line"><a name="l02296"></a><span class="lineno"> 2296</span> <span class="comment">// count against the number of frames to be included.</span></div><div class="line"><a name="l02297"></a><span class="lineno"> 2297</span> <span class="comment">//</span></div><div class="line"><a name="l02298"></a><span class="lineno"> 2298</span> <span class="comment">// For example, if Foo() calls Bar(), which in turn calls</span></div><div class="line"><a name="l02299"></a><span class="lineno"> 2299</span> <span class="comment">// CurrentOsStackTraceExceptTop(1), Foo() will be included in the</span></div><div class="line"><a name="l02300"></a><span class="lineno"> 2300</span> <span class="comment">// trace but Bar() and CurrentOsStackTraceExceptTop() won't.</span></div><div class="line"><a name="l02301"></a><span class="lineno"> 2301</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> UnitTestImpl::CurrentOsStackTraceExceptTop(<span class="keywordtype">int</span> skip_count) {</div><div class="line"><a name="l02302"></a><span class="lineno"> 2302</span>  <span class="keywordflow">return</span> os_stack_trace_getter()->CurrentStackTrace(</div><div class="line"><a name="l02303"></a><span class="lineno"> 2303</span>  static_cast<int>(<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(stack_trace_depth)),</div><div class="line"><a name="l02304"></a><span class="lineno"> 2304</span>  skip_count + 1</div><div class="line"><a name="l02305"></a><span class="lineno"> 2305</span>  <span class="comment">// Skips the user-specified number of frames plus this function</span></div><div class="line"><a name="l02306"></a><span class="lineno"> 2306</span>  <span class="comment">// itself.</span></div><div class="line"><a name="l02307"></a><span class="lineno"> 2307</span>  ); <span class="comment">// NOLINT</span></div><div class="line"><a name="l02308"></a><span class="lineno"> 2308</span> }</div><div class="line"><a name="l02309"></a><span class="lineno"> 2309</span> </div><div class="line"><a name="l02310"></a><span class="lineno"> 2310</span> <span class="comment">// Returns the current time in milliseconds.</span></div><div class="line"><a name="l02311"></a><span class="lineno"> 2311</span> <a class="code" href="namespacetesting_1_1internal.html#a66a845df404b38fe85c5e14a069f255a">TimeInMillis</a> GetTimeInMillis() {</div><div class="line"><a name="l02312"></a><span class="lineno"> 2312</span> <span class="preprocessor">#if GTEST_OS_WINDOWS_MOBILE || defined(__BORLANDC__)</span></div><div class="line"><a name="l02313"></a><span class="lineno"> 2313</span>  <span class="comment">// Difference between 1970-01-01 and 1601-01-01 in milliseconds.</span></div><div class="line"><a name="l02314"></a><span class="lineno"> 2314</span>  <span class="comment">// http://analogous.blogspot.com/2005/04/epoch.html</span></div><div class="line"><a name="l02315"></a><span class="lineno"> 2315</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a66a845df404b38fe85c5e14a069f255a">TimeInMillis</a> kJavaEpochToWinFileTimeDelta =</div><div class="line"><a name="l02316"></a><span class="lineno"> 2316</span>  <span class="keyword">static_cast<</span><a class="code" href="namespacetesting_1_1internal.html#a66a845df404b38fe85c5e14a069f255a">TimeInMillis</a><span class="keyword">></span>(116444736UL) * 100000UL;</div><div class="line"><a name="l02317"></a><span class="lineno"> 2317</span>  <span class="keyword">const</span> DWORD kTenthMicrosInMilliSecond = 10000;</div><div class="line"><a name="l02318"></a><span class="lineno"> 2318</span> </div><div class="line"><a name="l02319"></a><span class="lineno"> 2319</span>  SYSTEMTIME now_systime;</div><div class="line"><a name="l02320"></a><span class="lineno"> 2320</span>  FILETIME now_filetime;</div><div class="line"><a name="l02321"></a><span class="lineno"> 2321</span>  ULARGE_INTEGER now_int64;</div><div class="line"><a name="l02322"></a><span class="lineno"> 2322</span>  GetSystemTime(&now_systime);</div><div class="line"><a name="l02323"></a><span class="lineno"> 2323</span>  <span class="keywordflow">if</span> (SystemTimeToFileTime(&now_systime, &now_filetime)) {</div><div class="line"><a name="l02324"></a><span class="lineno"> 2324</span>  now_int64.LowPart = now_filetime.dwLowDateTime;</div><div class="line"><a name="l02325"></a><span class="lineno"> 2325</span>  now_int64.HighPart = now_filetime.dwHighDateTime;</div><div class="line"><a name="l02326"></a><span class="lineno"> 2326</span>  now_int64.QuadPart = (now_int64.QuadPart / kTenthMicrosInMilliSecond) -</div><div class="line"><a name="l02327"></a><span class="lineno"> 2327</span>  kJavaEpochToWinFileTimeDelta;</div><div class="line"><a name="l02328"></a><span class="lineno"> 2328</span>  <span class="keywordflow">return</span> now_int64.QuadPart;</div><div class="line"><a name="l02329"></a><span class="lineno"> 2329</span>  }</div><div class="line"><a name="l02330"></a><span class="lineno"> 2330</span>  <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l02331"></a><span class="lineno"> 2331</span> <span class="preprocessor">#elif GTEST_OS_WINDOWS && !GTEST_HAS_GETTIMEOFDAY_</span></div><div class="line"><a name="l02332"></a><span class="lineno"> 2332</span>  __timeb64 now;</div><div class="line"><a name="l02333"></a><span class="lineno"> 2333</span> </div><div class="line"><a name="l02334"></a><span class="lineno"> 2334</span>  <span class="comment">// MSVC 8 deprecates _ftime64(), so we want to suppress warning 4996</span></div><div class="line"><a name="l02335"></a><span class="lineno"> 2335</span>  <span class="comment">// (deprecated function) there.</span></div><div class="line"><a name="l02336"></a><span class="lineno"> 2336</span>  <a class="code" href="gtest_8h.html#a5b130138db254deaf29dbe3dffa1a2a8">GTEST_DISABLE_MSC_DEPRECATED_PUSH_</a>()</div><div class="line"><a name="l02337"></a><span class="lineno"> 2337</span>  _ftime64(&now);</div><div class="line"><a name="l02338"></a><span class="lineno"> 2338</span>  <a class="code" href="gtest_8h.html#aa0dc86dc9837f1610e91da65458f53b3">GTEST_DISABLE_MSC_DEPRECATED_POP_</a>()</div><div class="line"><a name="l02339"></a><span class="lineno"> 2339</span> </div><div class="line"><a name="l02340"></a><span class="lineno"> 2340</span>  return static_cast<<a class="code" href="namespacetesting_1_1internal.html#a66a845df404b38fe85c5e14a069f255a">TimeInMillis</a>>(now.time) * 1000 + now.millitm;</div><div class="line"><a name="l02341"></a><span class="lineno"> 2341</span> <span class="preprocessor">#elif GTEST_HAS_GETTIMEOFDAY_</span></div><div class="line"><a name="l02342"></a><span class="lineno"> 2342</span>  <span class="keyword">struct </span>timeval now;</div><div class="line"><a name="l02343"></a><span class="lineno"> 2343</span>  gettimeofday(&now, <span class="keyword">nullptr</span>);</div><div class="line"><a name="l02344"></a><span class="lineno"> 2344</span>  <span class="keywordflow">return</span> <span class="keyword">static_cast<</span><a class="code" href="namespacetesting_1_1internal.html#a66a845df404b38fe85c5e14a069f255a">TimeInMillis</a><span class="keyword">></span>(now.tv_sec) * 1000 + now.tv_usec / 1000;</div><div class="line"><a name="l02345"></a><span class="lineno"> 2345</span> #<span class="keywordflow">else</span></div><div class="line"><a name="l02346"></a><span class="lineno"> 2346</span> # error <span class="stringliteral">"Don't know how to get the current time on your system."</span></div><div class="line"><a name="l02347"></a><span class="lineno"> 2347</span> #endif</div><div class="line"><a name="l02348"></a><span class="lineno"> 2348</span> }</div><div class="line"><a name="l02349"></a><span class="lineno"> 2349</span> </div><div class="line"><a name="l02350"></a><span class="lineno"> 2350</span> <span class="comment">// Utilities</span></div><div class="line"><a name="l02351"></a><span class="lineno"> 2351</span> </div><div class="line"><a name="l02352"></a><span class="lineno"> 2352</span> <span class="comment">// class String.</span></div><div class="line"><a name="l02353"></a><span class="lineno"> 2353</span> </div><div class="line"><a name="l02354"></a><span class="lineno"> 2354</span> <span class="preprocessor">#if GTEST_OS_WINDOWS_MOBILE</span></div><div class="line"><a name="l02355"></a><span class="lineno"> 2355</span> <span class="comment">// Creates a UTF-16 wide string from the given ANSI string, allocating</span></div><div class="line"><a name="l02356"></a><span class="lineno"> 2356</span> <span class="comment">// memory using new. The caller is responsible for deleting the return</span></div><div class="line"><a name="l02357"></a><span class="lineno"> 2357</span> <span class="comment">// value using delete[]. Returns the wide string, or NULL if the</span></div><div class="line"><a name="l02358"></a><span class="lineno"> 2358</span> <span class="comment">// input is NULL.</span></div><div class="line"><a name="l02359"></a><span class="lineno"> 2359</span> LPCWSTR String::AnsiToUtf16(<span class="keyword">const</span> <span class="keywordtype">char</span>* ansi) {</div><div class="line"><a name="l02360"></a><span class="lineno"> 2360</span>  <span class="keywordflow">if</span> (!ansi) <span class="keywordflow">return</span> <span class="keyword">nullptr</span>;</div><div class="line"><a name="l02361"></a><span class="lineno"> 2361</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> length = strlen(ansi);</div><div class="line"><a name="l02362"></a><span class="lineno"> 2362</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> unicode_length =</div><div class="line"><a name="l02363"></a><span class="lineno"> 2363</span>  MultiByteToWideChar(CP_ACP, 0, ansi, length, <span class="keyword">nullptr</span>, 0);</div><div class="line"><a name="l02364"></a><span class="lineno"> 2364</span>  WCHAR* unicode = <span class="keyword">new</span> WCHAR[unicode_length + 1];</div><div class="line"><a name="l02365"></a><span class="lineno"> 2365</span>  MultiByteToWideChar(CP_ACP, 0, ansi, length,</div><div class="line"><a name="l02366"></a><span class="lineno"> 2366</span>  unicode, unicode_length);</div><div class="line"><a name="l02367"></a><span class="lineno"> 2367</span>  unicode[unicode_length] = 0;</div><div class="line"><a name="l02368"></a><span class="lineno"> 2368</span>  <span class="keywordflow">return</span> unicode;</div><div class="line"><a name="l02369"></a><span class="lineno"> 2369</span> }</div><div class="line"><a name="l02370"></a><span class="lineno"> 2370</span> </div><div class="line"><a name="l02371"></a><span class="lineno"> 2371</span> <span class="comment">// Creates an ANSI string from the given wide string, allocating</span></div><div class="line"><a name="l02372"></a><span class="lineno"> 2372</span> <span class="comment">// memory using new. The caller is responsible for deleting the return</span></div><div class="line"><a name="l02373"></a><span class="lineno"> 2373</span> <span class="comment">// value using delete[]. Returns the ANSI string, or NULL if the</span></div><div class="line"><a name="l02374"></a><span class="lineno"> 2374</span> <span class="comment">// input is NULL.</span></div><div class="line"><a name="l02375"></a><span class="lineno"> 2375</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* String::Utf16ToAnsi(LPCWSTR utf16_str) {</div><div class="line"><a name="l02376"></a><span class="lineno"> 2376</span>  <span class="keywordflow">if</span> (!utf16_str) <span class="keywordflow">return</span> <span class="keyword">nullptr</span>;</div><div class="line"><a name="l02377"></a><span class="lineno"> 2377</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> ansi_length = WideCharToMultiByte(CP_ACP, 0, utf16_str, -1, <span class="keyword">nullptr</span>,</div><div class="line"><a name="l02378"></a><span class="lineno"> 2378</span>  0, <span class="keyword">nullptr</span>, <span class="keyword">nullptr</span>);</div><div class="line"><a name="l02379"></a><span class="lineno"> 2379</span>  <span class="keywordtype">char</span>* ansi = <span class="keyword">new</span> <span class="keywordtype">char</span>[ansi_length + 1];</div><div class="line"><a name="l02380"></a><span class="lineno"> 2380</span>  WideCharToMultiByte(CP_ACP, 0, utf16_str, -1, ansi, ansi_length, <span class="keyword">nullptr</span>,</div><div class="line"><a name="l02381"></a><span class="lineno"> 2381</span>  <span class="keyword">nullptr</span>);</div><div class="line"><a name="l02382"></a><span class="lineno"> 2382</span>  ansi[ansi_length] = 0;</div><div class="line"><a name="l02383"></a><span class="lineno"> 2383</span>  <span class="keywordflow">return</span> ansi;</div><div class="line"><a name="l02384"></a><span class="lineno"> 2384</span> }</div><div class="line"><a name="l02385"></a><span class="lineno"> 2385</span> </div><div class="line"><a name="l02386"></a><span class="lineno"> 2386</span> <span class="preprocessor">#endif // GTEST_OS_WINDOWS_MOBILE</span></div><div class="line"><a name="l02387"></a><span class="lineno"> 2387</span> </div><div class="line"><a name="l02388"></a><span class="lineno"> 2388</span> <span class="comment">// Compares two C strings. Returns true iff they have the same content.</span></div><div class="line"><a name="l02389"></a><span class="lineno"> 2389</span> <span class="comment">//</span></div><div class="line"><a name="l02390"></a><span class="lineno"> 2390</span> <span class="comment">// Unlike strcmp(), this function can handle NULL argument(s). A NULL</span></div><div class="line"><a name="l02391"></a><span class="lineno"> 2391</span> <span class="comment">// C string is considered different to any non-NULL C string,</span></div><div class="line"><a name="l02392"></a><span class="lineno"> 2392</span> <span class="comment">// including the empty string.</span></div><div class="line"><a name="l02393"></a><span class="lineno"> 2393</span> <span class="keywordtype">bool</span> String::CStringEquals(<span class="keyword">const</span> <span class="keywordtype">char</span> * lhs, <span class="keyword">const</span> <span class="keywordtype">char</span> * rhs) {</div><div class="line"><a name="l02394"></a><span class="lineno"> 2394</span>  <span class="keywordflow">if</span> (lhs == <span class="keyword">nullptr</span>) <span class="keywordflow">return</span> rhs == <span class="keyword">nullptr</span>;</div><div class="line"><a name="l02395"></a><span class="lineno"> 2395</span> </div><div class="line"><a name="l02396"></a><span class="lineno"> 2396</span>  <span class="keywordflow">if</span> (rhs == <span class="keyword">nullptr</span>) <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l02397"></a><span class="lineno"> 2397</span> </div><div class="line"><a name="l02398"></a><span class="lineno"> 2398</span>  <span class="keywordflow">return</span> strcmp(lhs, rhs) == 0;</div><div class="line"><a name="l02399"></a><span class="lineno"> 2399</span> }</div><div class="line"><a name="l02400"></a><span class="lineno"> 2400</span> </div><div class="line"><a name="l02401"></a><span class="lineno"> 2401</span> <span class="preprocessor">#if GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING</span></div><div class="line"><a name="l02402"></a><span class="lineno"> 2402</span> </div><div class="line"><a name="l02403"></a><span class="lineno"> 2403</span> <span class="comment">// Converts an array of wide chars to a narrow string using the UTF-8</span></div><div class="line"><a name="l02404"></a><span class="lineno"> 2404</span> <span class="comment">// encoding, and streams the result to the given Message object.</span></div><div class="line"><a name="l02405"></a><span class="lineno"> 2405</span> <span class="keyword">static</span> <span class="keywordtype">void</span> StreamWideCharsToMessage(<span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* wstr, <span class="keywordtype">size_t</span> length,</div><div class="line"><a name="l02406"></a><span class="lineno"> 2406</span>  Message* msg) {</div><div class="line"><a name="l02407"></a><span class="lineno"> 2407</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i != length; ) { <span class="comment">// NOLINT</span></div><div class="line"><a name="l02408"></a><span class="lineno"> 2408</span>  <span class="keywordflow">if</span> (wstr[i] != L<span class="charliteral">'\0'</span>) {</div><div class="line"><a name="l02409"></a><span class="lineno"> 2409</span>  *msg << WideStringToUtf8(wstr + i, static_cast<int>(length - i));</div><div class="line"><a name="l02410"></a><span class="lineno"> 2410</span>  <span class="keywordflow">while</span> (i != length && wstr[i] != L<span class="charliteral">'\0'</span>)</div><div class="line"><a name="l02411"></a><span class="lineno"> 2411</span>  i++;</div><div class="line"><a name="l02412"></a><span class="lineno"> 2412</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l02413"></a><span class="lineno"> 2413</span>  *msg << <span class="charliteral">'\0'</span>;</div><div class="line"><a name="l02414"></a><span class="lineno"> 2414</span>  i++;</div><div class="line"><a name="l02415"></a><span class="lineno"> 2415</span>  }</div><div class="line"><a name="l02416"></a><span class="lineno"> 2416</span>  }</div><div class="line"><a name="l02417"></a><span class="lineno"> 2417</span> }</div><div class="line"><a name="l02418"></a><span class="lineno"> 2418</span> </div><div class="line"><a name="l02419"></a><span class="lineno"> 2419</span> <span class="preprocessor">#endif // GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING</span></div><div class="line"><a name="l02420"></a><span class="lineno"> 2420</span> </div><div class="line"><a name="l02421"></a><span class="lineno"> 2421</span> <span class="keywordtype">void</span> SplitString(<a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">const ::std::string</a>& str, <span class="keywordtype">char</span> delimiter,</div><div class="line"><a name="l02422"></a><span class="lineno"> 2422</span>  ::std::vector< ::std::string>* dest) {</div><div class="line"><a name="l02423"></a><span class="lineno"> 2423</span>  ::std::vector< ::std::string> parsed;</div><div class="line"><a name="l02424"></a><span class="lineno"> 2424</span>  ::std::string::size_type pos = 0;</div><div class="line"><a name="l02425"></a><span class="lineno"> 2425</span>  <span class="keywordflow">while</span> (::<a class="code" href="namespacetesting_1_1internal.html#a4d46f09c3bfe68700b7f728d2cc3782f">testing::internal::AlwaysTrue</a>()) {</div><div class="line"><a name="l02426"></a><span class="lineno"> 2426</span>  const ::std::string::size_type colon = str.find(delimiter, pos);</div><div class="line"><a name="l02427"></a><span class="lineno"> 2427</span>  <span class="keywordflow">if</span> (colon == ::std::string::npos) {</div><div class="line"><a name="l02428"></a><span class="lineno"> 2428</span>  parsed.push_back(str.substr(pos));</div><div class="line"><a name="l02429"></a><span class="lineno"> 2429</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l02430"></a><span class="lineno"> 2430</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l02431"></a><span class="lineno"> 2431</span>  parsed.push_back(str.substr(pos, colon - pos));</div><div class="line"><a name="l02432"></a><span class="lineno"> 2432</span>  pos = colon + 1;</div><div class="line"><a name="l02433"></a><span class="lineno"> 2433</span>  }</div><div class="line"><a name="l02434"></a><span class="lineno"> 2434</span>  }</div><div class="line"><a name="l02435"></a><span class="lineno"> 2435</span>  dest->swap(parsed);</div><div class="line"><a name="l02436"></a><span class="lineno"> 2436</span> }</div><div class="line"><a name="l02437"></a><span class="lineno"> 2437</span> </div><div class="line"><a name="l02438"></a><span class="lineno"> 2438</span> } <span class="comment">// namespace internal</span></div><div class="line"><a name="l02439"></a><span class="lineno"> 2439</span> </div><div class="line"><a name="l02440"></a><span class="lineno"> 2440</span> <span class="comment">// Constructs an empty Message.</span></div><div class="line"><a name="l02441"></a><span class="lineno"> 2441</span> <span class="comment">// We allocate the stringstream separately because otherwise each use of</span></div><div class="line"><a name="l02442"></a><span class="lineno"> 2442</span> <span class="comment">// ASSERT/EXPECT in a procedure adds over 200 bytes to the procedure's</span></div><div class="line"><a name="l02443"></a><span class="lineno"> 2443</span> <span class="comment">// stack frame leading to huge stack frames in some cases; gcc does not reuse</span></div><div class="line"><a name="l02444"></a><span class="lineno"> 2444</span> <span class="comment">// the stack space.</span></div><div class="line"><a name="l02445"></a><span class="lineno"> 2445</span> Message::Message() : ss_(new ::std::stringstream) {</div><div class="line"><a name="l02446"></a><span class="lineno"> 2446</span>  <span class="comment">// By default, we want there to be enough precision when printing</span></div><div class="line"><a name="l02447"></a><span class="lineno"> 2447</span>  <span class="comment">// a double to a Message.</span></div><div class="line"><a name="l02448"></a><span class="lineno"> 2448</span>  *ss_ << std::setprecision(std::numeric_limits<double>::digits10 + 2);</div><div class="line"><a name="l02449"></a><span class="lineno"> 2449</span> }</div><div class="line"><a name="l02450"></a><span class="lineno"> 2450</span> </div><div class="line"><a name="l02451"></a><span class="lineno"> 2451</span> <span class="comment">// These two overloads allow streaming a wide C string to a Message</span></div><div class="line"><a name="l02452"></a><span class="lineno"> 2452</span> <span class="comment">// using the UTF-8 encoding.</span></div><div class="line"><a name="l02453"></a><span class="lineno"> 2453</span> Message& <a class="code" href="namespacetesting.html#a266e39b7c4691fedb856047673a412d8">Message::operator <<</a>(<span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* wide_c_str) {</div><div class="line"><a name="l02454"></a><span class="lineno"> 2454</span>  <span class="keywordflow">return</span> *<span class="keyword">this</span> << internal::String::ShowWideCString(wide_c_str);</div><div class="line"><a name="l02455"></a><span class="lineno"> 2455</span> }</div><div class="line"><a name="l02456"></a><span class="lineno"> 2456</span> Message& <a class="code" href="namespacetesting.html#a266e39b7c4691fedb856047673a412d8">Message::operator <<</a>(<span class="keywordtype">wchar_t</span>* wide_c_str) {</div><div class="line"><a name="l02457"></a><span class="lineno"> 2457</span>  <span class="keywordflow">return</span> *<span class="keyword">this</span> << internal::String::ShowWideCString(wide_c_str);</div><div class="line"><a name="l02458"></a><span class="lineno"> 2458</span> }</div><div class="line"><a name="l02459"></a><span class="lineno"> 2459</span> </div><div class="line"><a name="l02460"></a><span class="lineno"> 2460</span> <span class="preprocessor">#if GTEST_HAS_STD_WSTRING</span></div><div class="line"><a name="l02461"></a><span class="lineno"> 2461</span> <span class="comment">// Converts the given wide string to a narrow string using the UTF-8</span></div><div class="line"><a name="l02462"></a><span class="lineno"> 2462</span> <span class="comment">// encoding, and streams the result to this Message object.</span></div><div class="line"><a name="l02463"></a><span class="lineno"> 2463</span> Message& <a class="code" href="namespacetesting.html#a266e39b7c4691fedb856047673a412d8">Message::operator <<</a>(<a class="code" href="namespacetesting_1_1internal.html#a3f543179329c353aee1d7b54a9a8e335">const ::std::wstring</a>& wstr) {</div><div class="line"><a name="l02464"></a><span class="lineno"> 2464</span>  internal::StreamWideCharsToMessage(wstr.c_str(), wstr.length(), <span class="keyword">this</span>);</div><div class="line"><a name="l02465"></a><span class="lineno"> 2465</span>  <span class="keywordflow">return</span> *<span class="keyword">this</span>;</div><div class="line"><a name="l02466"></a><span class="lineno"> 2466</span> }</div><div class="line"><a name="l02467"></a><span class="lineno"> 2467</span> <span class="preprocessor">#endif // GTEST_HAS_STD_WSTRING</span></div><div class="line"><a name="l02468"></a><span class="lineno"> 2468</span> </div><div class="line"><a name="l02469"></a><span class="lineno"> 2469</span> <span class="preprocessor">#if GTEST_HAS_GLOBAL_WSTRING</span></div><div class="line"><a name="l02470"></a><span class="lineno"> 2470</span> <span class="comment">// Converts the given wide string to a narrow string using the UTF-8</span></div><div class="line"><a name="l02471"></a><span class="lineno"> 2471</span> <span class="comment">// encoding, and streams the result to this Message object.</span></div><div class="line"><a name="l02472"></a><span class="lineno"> 2472</span> Message& <a class="code" href="namespacetesting.html#a266e39b7c4691fedb856047673a412d8">Message::operator <<</a>(<a class="code" href="namespacetesting_1_1internal.html#a3f543179329c353aee1d7b54a9a8e335">const ::wstring</a>& wstr) {</div><div class="line"><a name="l02473"></a><span class="lineno"> 2473</span>  internal::StreamWideCharsToMessage(wstr.c_str(), wstr.length(), <span class="keyword">this</span>);</div><div class="line"><a name="l02474"></a><span class="lineno"> 2474</span>  <span class="keywordflow">return</span> *<span class="keyword">this</span>;</div><div class="line"><a name="l02475"></a><span class="lineno"> 2475</span> }</div><div class="line"><a name="l02476"></a><span class="lineno"> 2476</span> <span class="preprocessor">#endif // GTEST_HAS_GLOBAL_WSTRING</span></div><div class="line"><a name="l02477"></a><span class="lineno"> 2477</span> </div><div class="line"><a name="l02478"></a><span class="lineno"> 2478</span> <span class="comment">// Gets the text streamed to this object so far as an std::string.</span></div><div class="line"><a name="l02479"></a><span class="lineno"> 2479</span> <span class="comment">// Each '\0' character in the buffer is replaced with "\\0".</span></div><div class="line"><a name="l02480"></a><span class="lineno"> 2480</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> Message::GetString()<span class="keyword"> const </span>{</div><div class="line"><a name="l02481"></a><span class="lineno"> 2481</span>  <span class="keywordflow">return</span> internal::StringStreamToString(ss_.get());</div><div class="line"><a name="l02482"></a><span class="lineno"> 2482</span> }</div><div class="line"><a name="l02483"></a><span class="lineno"> 2483</span> </div><div class="line"><a name="l02484"></a><span class="lineno"> 2484</span> <span class="comment">// AssertionResult constructors.</span></div><div class="line"><a name="l02485"></a><span class="lineno"> 2485</span> <span class="comment">// Used in EXPECT_TRUE/FALSE(assertion_result).</span></div><div class="line"><a name="l02486"></a><span class="lineno"> 2486</span> AssertionResult::AssertionResult(<span class="keyword">const</span> AssertionResult& other)</div><div class="line"><a name="l02487"></a><span class="lineno"> 2487</span>  : success_(other.success_),</div><div class="line"><a name="l02488"></a><span class="lineno"> 2488</span>  message_(other.message_.<a class="code" href="namespaceutl.html#a29057d2e164fe6dd3f3095f0d69c6546">get</a>() != nullptr</div><div class="line"><a name="l02489"></a><span class="lineno"> 2489</span>  ? new ::std::<a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">string</a>(*other.message_)</div><div class="line"><a name="l02490"></a><span class="lineno"> 2490</span>  : static_cast< ::std::<a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">string</a>*>(nullptr)) {}</div><div class="line"><a name="l02491"></a><span class="lineno"> 2491</span> </div><div class="line"><a name="l02492"></a><span class="lineno"> 2492</span> <span class="comment">// Swaps two AssertionResults.</span></div><div class="line"><a name="l02493"></a><span class="lineno"> 2493</span> <span class="keywordtype">void</span> <a class="code" href="namespaceutl.html#ae0f873b4883af7cc18cb23dd2810f4e6">AssertionResult::swap</a>(AssertionResult& other) {</div><div class="line"><a name="l02494"></a><span class="lineno"> 2494</span>  <span class="keyword">using</span> <a class="code" href="namespaceutl.html#ae0f873b4883af7cc18cb23dd2810f4e6">std::swap</a>;</div><div class="line"><a name="l02495"></a><span class="lineno"> 2495</span>  <a class="code" href="namespaceutl.html#ae0f873b4883af7cc18cb23dd2810f4e6">swap</a>(success_, other.success_);</div><div class="line"><a name="l02496"></a><span class="lineno"> 2496</span>  <a class="code" href="namespaceutl.html#ae0f873b4883af7cc18cb23dd2810f4e6">swap</a>(message_, other.message_);</div><div class="line"><a name="l02497"></a><span class="lineno"> 2497</span> }</div><div class="line"><a name="l02498"></a><span class="lineno"> 2498</span> </div><div class="line"><a name="l02499"></a><span class="lineno"> 2499</span> <span class="comment">// Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.</span></div><div class="line"><a name="l02500"></a><span class="lineno"> 2500</span> AssertionResult AssertionResult::operator!()<span class="keyword"> const </span>{</div><div class="line"><a name="l02501"></a><span class="lineno"> 2501</span>  AssertionResult negation(!success_);</div><div class="line"><a name="l02502"></a><span class="lineno"> 2502</span>  <span class="keywordflow">if</span> (message_.get() != <span class="keyword">nullptr</span>) negation << *message_;</div><div class="line"><a name="l02503"></a><span class="lineno"> 2503</span>  <span class="keywordflow">return</span> negation;</div><div class="line"><a name="l02504"></a><span class="lineno"> 2504</span> }</div><div class="line"><a name="l02505"></a><span class="lineno"> 2505</span> </div><div class="line"><a name="l02506"></a><span class="lineno"> 2506</span> <span class="comment">// Makes a successful assertion result.</span></div><div class="line"><a name="l02507"></a><span class="lineno"> 2507</span> AssertionResult AssertionSuccess() {</div><div class="line"><a name="l02508"></a><span class="lineno"> 2508</span>  <span class="keywordflow">return</span> AssertionResult(<span class="keyword">true</span>);</div><div class="line"><a name="l02509"></a><span class="lineno"> 2509</span> }</div><div class="line"><a name="l02510"></a><span class="lineno"> 2510</span> </div><div class="line"><a name="l02511"></a><span class="lineno"> 2511</span> <span class="comment">// Makes a failed assertion result.</span></div><div class="line"><a name="l02512"></a><span class="lineno"> 2512</span> AssertionResult AssertionFailure() {</div><div class="line"><a name="l02513"></a><span class="lineno"> 2513</span>  <span class="keywordflow">return</span> AssertionResult(<span class="keyword">false</span>);</div><div class="line"><a name="l02514"></a><span class="lineno"> 2514</span> }</div><div class="line"><a name="l02515"></a><span class="lineno"> 2515</span> </div><div class="line"><a name="l02516"></a><span class="lineno"> 2516</span> <span class="comment">// Makes a failed assertion result with the given failure message.</span></div><div class="line"><a name="l02517"></a><span class="lineno"> 2517</span> <span class="comment">// Deprecated; use AssertionFailure() << message.</span></div><div class="line"><a name="l02518"></a><span class="lineno"> 2518</span> AssertionResult AssertionFailure(<span class="keyword">const</span> Message& message) {</div><div class="line"><a name="l02519"></a><span class="lineno"> 2519</span>  <span class="keywordflow">return</span> AssertionFailure() << message;</div><div class="line"><a name="l02520"></a><span class="lineno"> 2520</span> }</div><div class="line"><a name="l02521"></a><span class="lineno"> 2521</span> </div><div class="line"><a name="l02522"></a><span class="lineno"> 2522</span> <span class="keyword">namespace </span>internal {</div><div class="line"><a name="l02523"></a><span class="lineno"> 2523</span> </div><div class="line"><a name="l02524"></a><span class="lineno"> 2524</span> <span class="keyword">namespace </span>edit_distance {</div><div class="line"><a name="l02525"></a><span class="lineno"> 2525</span> std::vector<EditType> <a class="code" href="namespacetesting_1_1internal_1_1edit__distance.html#ad28f23b77f716200bc6644bfc7413a63">CalculateOptimalEdits</a>(<span class="keyword">const</span> std::vector<size_t>& left,</div><div class="line"><a name="l02526"></a><span class="lineno"> 2526</span>  <span class="keyword">const</span> std::vector<size_t>& right) {</div><div class="line"><a name="l02527"></a><span class="lineno"> 2527</span>  std::vector<std::vector<double> > costs(</div><div class="line"><a name="l02528"></a><span class="lineno"> 2528</span>  left.size() + 1, std::vector<double>(right.size() + 1));</div><div class="line"><a name="l02529"></a><span class="lineno"> 2529</span>  std::vector<std::vector<EditType> > best_move(</div><div class="line"><a name="l02530"></a><span class="lineno"> 2530</span>  left.size() + 1, std::vector<EditType>(right.size() + 1));</div><div class="line"><a name="l02531"></a><span class="lineno"> 2531</span> </div><div class="line"><a name="l02532"></a><span class="lineno"> 2532</span>  <span class="comment">// Populate for empty right.</span></div><div class="line"><a name="l02533"></a><span class="lineno"> 2533</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> l_i = 0; l_i < costs.size(); ++l_i) {</div><div class="line"><a name="l02534"></a><span class="lineno"> 2534</span>  costs[l_i][0] = <span class="keyword">static_cast<</span><span class="keywordtype">double</span><span class="keyword">></span>(l_i);</div><div class="line"><a name="l02535"></a><span class="lineno"> 2535</span>  best_move[l_i][0] = <a class="code" href="namespacetesting_1_1internal_1_1edit__distance.html#ad46aa6da12aec1a3f166310478b53a08a814768ef6cd0264a0a10b1e701a63e78">kRemove</a>;</div><div class="line"><a name="l02536"></a><span class="lineno"> 2536</span>  }</div><div class="line"><a name="l02537"></a><span class="lineno"> 2537</span>  <span class="comment">// Populate for empty left.</span></div><div class="line"><a name="l02538"></a><span class="lineno"> 2538</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> r_i = 1; r_i < costs[0].size(); ++r_i) {</div><div class="line"><a name="l02539"></a><span class="lineno"> 2539</span>  costs[0][r_i] = <span class="keyword">static_cast<</span><span class="keywordtype">double</span><span class="keyword">></span>(r_i);</div><div class="line"><a name="l02540"></a><span class="lineno"> 2540</span>  best_move[0][r_i] = <a class="code" href="namespacetesting_1_1internal_1_1edit__distance.html#ad46aa6da12aec1a3f166310478b53a08a63400b073f5b311a87d568b5ae27ffe8">kAdd</a>;</div><div class="line"><a name="l02541"></a><span class="lineno"> 2541</span>  }</div><div class="line"><a name="l02542"></a><span class="lineno"> 2542</span> </div><div class="line"><a name="l02543"></a><span class="lineno"> 2543</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> l_i = 0; l_i < left.size(); ++l_i) {</div><div class="line"><a name="l02544"></a><span class="lineno"> 2544</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> r_i = 0; r_i < right.size(); ++r_i) {</div><div class="line"><a name="l02545"></a><span class="lineno"> 2545</span>  <span class="keywordflow">if</span> (left[l_i] == right[r_i]) {</div><div class="line"><a name="l02546"></a><span class="lineno"> 2546</span>  <span class="comment">// Found a match. Consume it.</span></div><div class="line"><a name="l02547"></a><span class="lineno"> 2547</span>  costs[l_i + 1][r_i + 1] = costs[l_i][r_i];</div><div class="line"><a name="l02548"></a><span class="lineno"> 2548</span>  best_move[l_i + 1][r_i + 1] = <a class="code" href="namespacetesting_1_1internal_1_1edit__distance.html#ad46aa6da12aec1a3f166310478b53a08a7bdb9c74613a94f21b7489e0b5640a63">kMatch</a>;</div><div class="line"><a name="l02549"></a><span class="lineno"> 2549</span>  <span class="keywordflow">continue</span>;</div><div class="line"><a name="l02550"></a><span class="lineno"> 2550</span>  }</div><div class="line"><a name="l02551"></a><span class="lineno"> 2551</span> </div><div class="line"><a name="l02552"></a><span class="lineno"> 2552</span>  <span class="keyword">const</span> <span class="keywordtype">double</span> <a class="code" href="namespaceutl_1_1meta.html#a559ad95ef39fd2c81664bd1a22dd99c1">add</a> = costs[l_i + 1][r_i];</div><div class="line"><a name="l02553"></a><span class="lineno"> 2553</span>  <span class="keyword">const</span> <span class="keywordtype">double</span> <span class="keyword">remove</span> = costs[l_i][r_i + 1];</div><div class="line"><a name="l02554"></a><span class="lineno"> 2554</span>  <span class="keyword">const</span> <span class="keywordtype">double</span> <a class="code" href="namespaceutl_1_1meta.html#ac9d120f858ebfa2b0ef74c6305a9fb6d">replace</a> = costs[l_i][r_i];</div><div class="line"><a name="l02555"></a><span class="lineno"> 2555</span>  <span class="keywordflow">if</span> (<a class="code" href="namespaceutl_1_1meta.html#a559ad95ef39fd2c81664bd1a22dd99c1">add</a> < <span class="keyword">remove</span> && <a class="code" href="namespaceutl_1_1meta.html#a559ad95ef39fd2c81664bd1a22dd99c1">add</a> < <a class="code" href="namespaceutl_1_1meta.html#ac9d120f858ebfa2b0ef74c6305a9fb6d">replace</a>) {</div><div class="line"><a name="l02556"></a><span class="lineno"> 2556</span>  costs[l_i + 1][r_i + 1] = <a class="code" href="namespaceutl_1_1meta.html#a559ad95ef39fd2c81664bd1a22dd99c1">add</a> + 1;</div><div class="line"><a name="l02557"></a><span class="lineno"> 2557</span>  best_move[l_i + 1][r_i + 1] = <a class="code" href="namespacetesting_1_1internal_1_1edit__distance.html#ad46aa6da12aec1a3f166310478b53a08a63400b073f5b311a87d568b5ae27ffe8">kAdd</a>;</div><div class="line"><a name="l02558"></a><span class="lineno"> 2558</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keyword">remove</span> < <a class="code" href="namespaceutl_1_1meta.html#a559ad95ef39fd2c81664bd1a22dd99c1">add</a> && <span class="keyword">remove</span> < <a class="code" href="namespaceutl_1_1meta.html#ac9d120f858ebfa2b0ef74c6305a9fb6d">replace</a>) {</div><div class="line"><a name="l02559"></a><span class="lineno"> 2559</span>  costs[l_i + 1][r_i + 1] = <span class="keyword">remove</span> + 1;</div><div class="line"><a name="l02560"></a><span class="lineno"> 2560</span>  best_move[l_i + 1][r_i + 1] = <a class="code" href="namespacetesting_1_1internal_1_1edit__distance.html#ad46aa6da12aec1a3f166310478b53a08a814768ef6cd0264a0a10b1e701a63e78">kRemove</a>;</div><div class="line"><a name="l02561"></a><span class="lineno"> 2561</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l02562"></a><span class="lineno"> 2562</span>  <span class="comment">// We make replace a little more expensive than add/remove to lower</span></div><div class="line"><a name="l02563"></a><span class="lineno"> 2563</span>  <span class="comment">// their priority.</span></div><div class="line"><a name="l02564"></a><span class="lineno"> 2564</span>  costs[l_i + 1][r_i + 1] = <a class="code" href="namespaceutl_1_1meta.html#ac9d120f858ebfa2b0ef74c6305a9fb6d">replace</a> + 1.00001;</div><div class="line"><a name="l02565"></a><span class="lineno"> 2565</span>  best_move[l_i + 1][r_i + 1] = <a class="code" href="namespacetesting_1_1internal_1_1edit__distance.html#ad46aa6da12aec1a3f166310478b53a08afdbf30ecf9f32f60c646a34a358615f2">kReplace</a>;</div><div class="line"><a name="l02566"></a><span class="lineno"> 2566</span>  }</div><div class="line"><a name="l02567"></a><span class="lineno"> 2567</span>  }</div><div class="line"><a name="l02568"></a><span class="lineno"> 2568</span>  }</div><div class="line"><a name="l02569"></a><span class="lineno"> 2569</span> </div><div class="line"><a name="l02570"></a><span class="lineno"> 2570</span>  <span class="comment">// Reconstruct the best path. We do it in reverse order.</span></div><div class="line"><a name="l02571"></a><span class="lineno"> 2571</span>  std::vector<EditType> best_path;</div><div class="line"><a name="l02572"></a><span class="lineno"> 2572</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> l_i = left.size(), r_i = right.size(); l_i > 0 || r_i > 0;) {</div><div class="line"><a name="l02573"></a><span class="lineno"> 2573</span>  <a class="code" href="namespacetesting_1_1internal_1_1edit__distance.html#ad46aa6da12aec1a3f166310478b53a08">EditType</a> move = best_move[l_i][r_i];</div><div class="line"><a name="l02574"></a><span class="lineno"> 2574</span>  best_path.push_back(move);</div><div class="line"><a name="l02575"></a><span class="lineno"> 2575</span>  l_i -= move != <a class="code" href="namespacetesting_1_1internal_1_1edit__distance.html#ad46aa6da12aec1a3f166310478b53a08a63400b073f5b311a87d568b5ae27ffe8">kAdd</a>;</div><div class="line"><a name="l02576"></a><span class="lineno"> 2576</span>  r_i -= move != <a class="code" href="namespacetesting_1_1internal_1_1edit__distance.html#ad46aa6da12aec1a3f166310478b53a08a814768ef6cd0264a0a10b1e701a63e78">kRemove</a>;</div><div class="line"><a name="l02577"></a><span class="lineno"> 2577</span>  }</div><div class="line"><a name="l02578"></a><span class="lineno"> 2578</span>  <a class="code" href="namespaceutl_1_1meta.html#a2ae6bfa22f1912b0ba09d24e0ae2ccd9">std::reverse</a>(best_path.begin(), best_path.end());</div><div class="line"><a name="l02579"></a><span class="lineno"> 2579</span>  <span class="keywordflow">return</span> best_path;</div><div class="line"><a name="l02580"></a><span class="lineno"> 2580</span> }</div><div class="line"><a name="l02581"></a><span class="lineno"> 2581</span> </div><div class="line"><a name="l02582"></a><span class="lineno"> 2582</span> <span class="keyword">namespace </span>{</div><div class="line"><a name="l02583"></a><span class="lineno"> 2583</span> </div><div class="line"><a name="l02584"></a><span class="lineno"> 2584</span> <span class="comment">// Helper class to convert string into ids with deduplication.</span></div><div class="line"><a name="l02585"></a><span class="lineno"> 2585</span> <span class="keyword">class </span>InternalStrings {</div><div class="line"><a name="l02586"></a><span class="lineno"> 2586</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l02587"></a><span class="lineno"> 2587</span>  <span class="keywordtype">size_t</span> GetId(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& str) {</div><div class="line"><a name="l02588"></a><span class="lineno"> 2588</span>  IdMap::iterator it = ids_.find(str);</div><div class="line"><a name="l02589"></a><span class="lineno"> 2589</span>  <span class="keywordflow">if</span> (it != ids_.end()) <span class="keywordflow">return</span> it->second;</div><div class="line"><a name="l02590"></a><span class="lineno"> 2590</span>  <span class="keywordtype">size_t</span> <span class="keywordtype">id</span> = ids_.size();</div><div class="line"><a name="l02591"></a><span class="lineno"> 2591</span>  <span class="keywordflow">return</span> ids_[str] = id;</div><div class="line"><a name="l02592"></a><span class="lineno"> 2592</span>  }</div><div class="line"><a name="l02593"></a><span class="lineno"> 2593</span> </div><div class="line"><a name="l02594"></a><span class="lineno"> 2594</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l02595"></a><span class="lineno"> 2595</span>  <span class="keyword">typedef</span> std::map<std::string, size_t> IdMap;</div><div class="line"><a name="l02596"></a><span class="lineno"> 2596</span>  IdMap ids_;</div><div class="line"><a name="l02597"></a><span class="lineno"> 2597</span> };</div><div class="line"><a name="l02598"></a><span class="lineno"> 2598</span> </div><div class="line"><a name="l02599"></a><span class="lineno"> 2599</span> } <span class="comment">// namespace</span></div><div class="line"><a name="l02600"></a><span class="lineno"> 2600</span> </div><div class="line"><a name="l02601"></a><span class="lineno"> 2601</span> std::vector<EditType> <a class="code" href="namespacetesting_1_1internal_1_1edit__distance.html#ad28f23b77f716200bc6644bfc7413a63">CalculateOptimalEdits</a>(</div><div class="line"><a name="l02602"></a><span class="lineno"> 2602</span>  <span class="keyword">const</span> std::vector<std::string>& left,</div><div class="line"><a name="l02603"></a><span class="lineno"> 2603</span>  <span class="keyword">const</span> std::vector<std::string>& right) {</div><div class="line"><a name="l02604"></a><span class="lineno"> 2604</span>  std::vector<size_t> left_ids, right_ids;</div><div class="line"><a name="l02605"></a><span class="lineno"> 2605</span>  {</div><div class="line"><a name="l02606"></a><span class="lineno"> 2606</span>  InternalStrings intern_table;</div><div class="line"><a name="l02607"></a><span class="lineno"> 2607</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i < left.size(); ++i) {</div><div class="line"><a name="l02608"></a><span class="lineno"> 2608</span>  left_ids.push_back(intern_table.GetId(left[i]));</div><div class="line"><a name="l02609"></a><span class="lineno"> 2609</span>  }</div><div class="line"><a name="l02610"></a><span class="lineno"> 2610</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i < right.size(); ++i) {</div><div class="line"><a name="l02611"></a><span class="lineno"> 2611</span>  right_ids.push_back(intern_table.GetId(right[i]));</div><div class="line"><a name="l02612"></a><span class="lineno"> 2612</span>  }</div><div class="line"><a name="l02613"></a><span class="lineno"> 2613</span>  }</div><div class="line"><a name="l02614"></a><span class="lineno"> 2614</span>  <span class="keywordflow">return</span> <a class="code" href="namespacetesting_1_1internal_1_1edit__distance.html#ad28f23b77f716200bc6644bfc7413a63">CalculateOptimalEdits</a>(left_ids, right_ids);</div><div class="line"><a name="l02615"></a><span class="lineno"> 2615</span> }</div><div class="line"><a name="l02616"></a><span class="lineno"> 2616</span> </div><div class="line"><a name="l02617"></a><span class="lineno"> 2617</span> <span class="keyword">namespace </span>{</div><div class="line"><a name="l02618"></a><span class="lineno"> 2618</span> </div><div class="line"><a name="l02619"></a><span class="lineno"> 2619</span> <span class="comment">// Helper class that holds the state for one hunk and prints it out to the</span></div><div class="line"><a name="l02620"></a><span class="lineno"> 2620</span> <span class="comment">// stream.</span></div><div class="line"><a name="l02621"></a><span class="lineno"> 2621</span> <span class="comment">// It reorders adds/removes when possible to group all removes before all</span></div><div class="line"><a name="l02622"></a><span class="lineno"> 2622</span> <span class="comment">// adds. It also adds the hunk header before printint into the stream.</span></div><div class="line"><a name="l02623"></a><span class="lineno"> 2623</span> <span class="keyword">class </span>Hunk {</div><div class="line"><a name="l02624"></a><span class="lineno"> 2624</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l02625"></a><span class="lineno"> 2625</span>  Hunk(<span class="keywordtype">size_t</span> left_start, <span class="keywordtype">size_t</span> right_start)</div><div class="line"><a name="l02626"></a><span class="lineno"> 2626</span>  : left_start_(left_start),</div><div class="line"><a name="l02627"></a><span class="lineno"> 2627</span>  right_start_(right_start),</div><div class="line"><a name="l02628"></a><span class="lineno"> 2628</span>  adds_(),</div><div class="line"><a name="l02629"></a><span class="lineno"> 2629</span>  removes_(),</div><div class="line"><a name="l02630"></a><span class="lineno"> 2630</span>  common_() {}</div><div class="line"><a name="l02631"></a><span class="lineno"> 2631</span> </div><div class="line"><a name="l02632"></a><span class="lineno"> 2632</span>  <span class="keywordtype">void</span> PushLine(<span class="keywordtype">char</span> edit, <span class="keyword">const</span> <span class="keywordtype">char</span>* line) {</div><div class="line"><a name="l02633"></a><span class="lineno"> 2633</span>  <span class="keywordflow">switch</span> (edit) {</div><div class="line"><a name="l02634"></a><span class="lineno"> 2634</span>  <span class="keywordflow">case</span> <span class="charliteral">' '</span>:</div><div class="line"><a name="l02635"></a><span class="lineno"> 2635</span>  ++common_;</div><div class="line"><a name="l02636"></a><span class="lineno"> 2636</span>  FlushEdits();</div><div class="line"><a name="l02637"></a><span class="lineno"> 2637</span>  hunk_.push_back(std::make_pair(<span class="charliteral">' '</span>, line));</div><div class="line"><a name="l02638"></a><span class="lineno"> 2638</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l02639"></a><span class="lineno"> 2639</span>  <span class="keywordflow">case</span> <span class="charliteral">'-'</span>:</div><div class="line"><a name="l02640"></a><span class="lineno"> 2640</span>  ++removes_;</div><div class="line"><a name="l02641"></a><span class="lineno"> 2641</span>  hunk_removes_.push_back(std::make_pair(<span class="charliteral">'-'</span>, line));</div><div class="line"><a name="l02642"></a><span class="lineno"> 2642</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l02643"></a><span class="lineno"> 2643</span>  <span class="keywordflow">case</span> <span class="charliteral">'+'</span>:</div><div class="line"><a name="l02644"></a><span class="lineno"> 2644</span>  ++adds_;</div><div class="line"><a name="l02645"></a><span class="lineno"> 2645</span>  hunk_adds_.push_back(std::make_pair(<span class="charliteral">'+'</span>, line));</div><div class="line"><a name="l02646"></a><span class="lineno"> 2646</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l02647"></a><span class="lineno"> 2647</span>  }</div><div class="line"><a name="l02648"></a><span class="lineno"> 2648</span>  }</div><div class="line"><a name="l02649"></a><span class="lineno"> 2649</span> </div><div class="line"><a name="l02650"></a><span class="lineno"> 2650</span>  <span class="keywordtype">void</span> <a class="code" href="namespacetesting_1_1internal.html#afc20fb56b2547a8f91f9ff99650f2024">PrintTo</a>(std::ostream* os) {</div><div class="line"><a name="l02651"></a><span class="lineno"> 2651</span>  PrintHeader(os);</div><div class="line"><a name="l02652"></a><span class="lineno"> 2652</span>  FlushEdits();</div><div class="line"><a name="l02653"></a><span class="lineno"> 2653</span>  <span class="keywordflow">for</span> (std::list<std::pair<char, const char*> >::const_iterator it =</div><div class="line"><a name="l02654"></a><span class="lineno"> 2654</span>  hunk_.begin();</div><div class="line"><a name="l02655"></a><span class="lineno"> 2655</span>  it != hunk_.end(); ++it) {</div><div class="line"><a name="l02656"></a><span class="lineno"> 2656</span>  *os << it->first << it->second << <span class="stringliteral">"\n"</span>;</div><div class="line"><a name="l02657"></a><span class="lineno"> 2657</span>  }</div><div class="line"><a name="l02658"></a><span class="lineno"> 2658</span>  }</div><div class="line"><a name="l02659"></a><span class="lineno"> 2659</span> </div><div class="line"><a name="l02660"></a><span class="lineno"> 2660</span>  <span class="keywordtype">bool</span> has_edits()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> adds_ || removes_; }</div><div class="line"><a name="l02661"></a><span class="lineno"> 2661</span> </div><div class="line"><a name="l02662"></a><span class="lineno"> 2662</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l02663"></a><span class="lineno"> 2663</span>  <span class="keywordtype">void</span> FlushEdits() {</div><div class="line"><a name="l02664"></a><span class="lineno"> 2664</span>  hunk_.splice(hunk_.end(), hunk_removes_);</div><div class="line"><a name="l02665"></a><span class="lineno"> 2665</span>  hunk_.splice(hunk_.end(), hunk_adds_);</div><div class="line"><a name="l02666"></a><span class="lineno"> 2666</span>  }</div><div class="line"><a name="l02667"></a><span class="lineno"> 2667</span> </div><div class="line"><a name="l02668"></a><span class="lineno"> 2668</span>  <span class="comment">// Print a unified diff header for one hunk.</span></div><div class="line"><a name="l02669"></a><span class="lineno"> 2669</span>  <span class="comment">// The format is</span></div><div class="line"><a name="l02670"></a><span class="lineno"> 2670</span>  <span class="comment">// "@@ -<left_start>,<left_length> +<right_start>,<right_length> @@"</span></div><div class="line"><a name="l02671"></a><span class="lineno"> 2671</span>  <span class="comment">// where the left/right parts are omitted if unnecessary.</span></div><div class="line"><a name="l02672"></a><span class="lineno"> 2672</span>  <span class="keywordtype">void</span> PrintHeader(std::ostream* ss)<span class="keyword"> const </span>{</div><div class="line"><a name="l02673"></a><span class="lineno"> 2673</span>  *ss << <span class="stringliteral">"@@ "</span>;</div><div class="line"><a name="l02674"></a><span class="lineno"> 2674</span>  <span class="keywordflow">if</span> (removes_) {</div><div class="line"><a name="l02675"></a><span class="lineno"> 2675</span>  *ss << <span class="stringliteral">"-"</span> << left_start_ << <span class="stringliteral">","</span> << (removes_ + common_);</div><div class="line"><a name="l02676"></a><span class="lineno"> 2676</span>  }</div><div class="line"><a name="l02677"></a><span class="lineno"> 2677</span>  <span class="keywordflow">if</span> (removes_ && adds_) {</div><div class="line"><a name="l02678"></a><span class="lineno"> 2678</span>  *ss << <span class="stringliteral">" "</span>;</div><div class="line"><a name="l02679"></a><span class="lineno"> 2679</span>  }</div><div class="line"><a name="l02680"></a><span class="lineno"> 2680</span>  <span class="keywordflow">if</span> (adds_) {</div><div class="line"><a name="l02681"></a><span class="lineno"> 2681</span>  *ss << <span class="stringliteral">"+"</span> << right_start_ << <span class="stringliteral">","</span> << (adds_ + common_);</div><div class="line"><a name="l02682"></a><span class="lineno"> 2682</span>  }</div><div class="line"><a name="l02683"></a><span class="lineno"> 2683</span>  *ss << <span class="stringliteral">" @@\n"</span>;</div><div class="line"><a name="l02684"></a><span class="lineno"> 2684</span>  }</div><div class="line"><a name="l02685"></a><span class="lineno"> 2685</span> </div><div class="line"><a name="l02686"></a><span class="lineno"> 2686</span>  <span class="keywordtype">size_t</span> left_start_, right_start_;</div><div class="line"><a name="l02687"></a><span class="lineno"> 2687</span>  <span class="keywordtype">size_t</span> adds_, removes_, common_;</div><div class="line"><a name="l02688"></a><span class="lineno"> 2688</span>  std::list<std::pair<char, const char*> > hunk_, hunk_adds_, hunk_removes_;</div><div class="line"><a name="l02689"></a><span class="lineno"> 2689</span> };</div><div class="line"><a name="l02690"></a><span class="lineno"> 2690</span> </div><div class="line"><a name="l02691"></a><span class="lineno"> 2691</span> } <span class="comment">// namespace</span></div><div class="line"><a name="l02692"></a><span class="lineno"> 2692</span> </div><div class="line"><a name="l02693"></a><span class="lineno"> 2693</span> <span class="comment">// Create a list of diff hunks in Unified diff format.</span></div><div class="line"><a name="l02694"></a><span class="lineno"> 2694</span> <span class="comment">// Each hunk has a header generated by PrintHeader above plus a body with</span></div><div class="line"><a name="l02695"></a><span class="lineno"> 2695</span> <span class="comment">// lines prefixed with ' ' for no change, '-' for deletion and '+' for</span></div><div class="line"><a name="l02696"></a><span class="lineno"> 2696</span> <span class="comment">// addition.</span></div><div class="line"><a name="l02697"></a><span class="lineno"> 2697</span> <span class="comment">// 'context' represents the desired unchanged prefix/suffix around the diff.</span></div><div class="line"><a name="l02698"></a><span class="lineno"> 2698</span> <span class="comment">// If two hunks are close enough that their contexts overlap, then they are</span></div><div class="line"><a name="l02699"></a><span class="lineno"> 2699</span> <span class="comment">// joined into one hunk.</span></div><div class="line"><a name="l02700"></a><span class="lineno"> 2700</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> <a class="code" href="namespacetesting_1_1internal_1_1edit__distance.html#a48cffebc6d3169ad1df7849b5f7fb5ff">CreateUnifiedDiff</a>(<span class="keyword">const</span> std::vector<std::string>& left,</div><div class="line"><a name="l02701"></a><span class="lineno"> 2701</span>  <span class="keyword">const</span> std::vector<std::string>& right,</div><div class="line"><a name="l02702"></a><span class="lineno"> 2702</span>  <span class="keywordtype">size_t</span> context) {</div><div class="line"><a name="l02703"></a><span class="lineno"> 2703</span>  <span class="keyword">const</span> std::vector<EditType> edits = <a class="code" href="namespacetesting_1_1internal_1_1edit__distance.html#ad28f23b77f716200bc6644bfc7413a63">CalculateOptimalEdits</a>(left, right);</div><div class="line"><a name="l02704"></a><span class="lineno"> 2704</span> </div><div class="line"><a name="l02705"></a><span class="lineno"> 2705</span>  <span class="keywordtype">size_t</span> l_i = 0, r_i = 0, edit_i = 0;</div><div class="line"><a name="l02706"></a><span class="lineno"> 2706</span>  std::stringstream ss;</div><div class="line"><a name="l02707"></a><span class="lineno"> 2707</span>  <span class="keywordflow">while</span> (edit_i < edits.size()) {</div><div class="line"><a name="l02708"></a><span class="lineno"> 2708</span>  <span class="comment">// Find first edit.</span></div><div class="line"><a name="l02709"></a><span class="lineno"> 2709</span>  <span class="keywordflow">while</span> (edit_i < edits.size() && edits[edit_i] == <a class="code" href="namespacetesting_1_1internal_1_1edit__distance.html#ad46aa6da12aec1a3f166310478b53a08a7bdb9c74613a94f21b7489e0b5640a63">kMatch</a>) {</div><div class="line"><a name="l02710"></a><span class="lineno"> 2710</span>  ++l_i;</div><div class="line"><a name="l02711"></a><span class="lineno"> 2711</span>  ++r_i;</div><div class="line"><a name="l02712"></a><span class="lineno"> 2712</span>  ++edit_i;</div><div class="line"><a name="l02713"></a><span class="lineno"> 2713</span>  }</div><div class="line"><a name="l02714"></a><span class="lineno"> 2714</span> </div><div class="line"><a name="l02715"></a><span class="lineno"> 2715</span>  <span class="comment">// Find the first line to include in the hunk.</span></div><div class="line"><a name="l02716"></a><span class="lineno"> 2716</span>  <span class="keyword">const</span> <span class="keywordtype">size_t</span> prefix_context = std::min(l_i, context);</div><div class="line"><a name="l02717"></a><span class="lineno"> 2717</span>  Hunk hunk(l_i - prefix_context + 1, r_i - prefix_context + 1);</div><div class="line"><a name="l02718"></a><span class="lineno"> 2718</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = prefix_context; i > 0; --i) {</div><div class="line"><a name="l02719"></a><span class="lineno"> 2719</span>  hunk.PushLine(<span class="charliteral">' '</span>, left[l_i - i].c_str());</div><div class="line"><a name="l02720"></a><span class="lineno"> 2720</span>  }</div><div class="line"><a name="l02721"></a><span class="lineno"> 2721</span> </div><div class="line"><a name="l02722"></a><span class="lineno"> 2722</span>  <span class="comment">// Iterate the edits until we found enough suffix for the hunk or the input</span></div><div class="line"><a name="l02723"></a><span class="lineno"> 2723</span>  <span class="comment">// is over.</span></div><div class="line"><a name="l02724"></a><span class="lineno"> 2724</span>  <span class="keywordtype">size_t</span> n_suffix = 0;</div><div class="line"><a name="l02725"></a><span class="lineno"> 2725</span>  <span class="keywordflow">for</span> (; edit_i < edits.size(); ++edit_i) {</div><div class="line"><a name="l02726"></a><span class="lineno"> 2726</span>  <span class="keywordflow">if</span> (n_suffix >= context) {</div><div class="line"><a name="l02727"></a><span class="lineno"> 2727</span>  <span class="comment">// Continue only if the next hunk is very close.</span></div><div class="line"><a name="l02728"></a><span class="lineno"> 2728</span>  std::vector<EditType>::const_iterator it = edits.begin() + edit_i;</div><div class="line"><a name="l02729"></a><span class="lineno"> 2729</span>  <span class="keywordflow">while</span> (it != edits.end() && *it == <a class="code" href="namespacetesting_1_1internal_1_1edit__distance.html#ad46aa6da12aec1a3f166310478b53a08a7bdb9c74613a94f21b7489e0b5640a63">kMatch</a>) ++it;</div><div class="line"><a name="l02730"></a><span class="lineno"> 2730</span>  <span class="keywordflow">if</span> (it == edits.end() || (it - edits.begin()) - edit_i >= context) {</div><div class="line"><a name="l02731"></a><span class="lineno"> 2731</span>  <span class="comment">// There is no next edit or it is too far away.</span></div><div class="line"><a name="l02732"></a><span class="lineno"> 2732</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l02733"></a><span class="lineno"> 2733</span>  }</div><div class="line"><a name="l02734"></a><span class="lineno"> 2734</span>  }</div><div class="line"><a name="l02735"></a><span class="lineno"> 2735</span> </div><div class="line"><a name="l02736"></a><span class="lineno"> 2736</span>  <a class="code" href="namespacetesting_1_1internal_1_1edit__distance.html#ad46aa6da12aec1a3f166310478b53a08">EditType</a> edit = edits[edit_i];</div><div class="line"><a name="l02737"></a><span class="lineno"> 2737</span>  <span class="comment">// Reset count when a non match is found.</span></div><div class="line"><a name="l02738"></a><span class="lineno"> 2738</span>  n_suffix = edit == <a class="code" href="namespacetesting_1_1internal_1_1edit__distance.html#ad46aa6da12aec1a3f166310478b53a08a7bdb9c74613a94f21b7489e0b5640a63">kMatch</a> ? n_suffix + 1 : 0;</div><div class="line"><a name="l02739"></a><span class="lineno"> 2739</span> </div><div class="line"><a name="l02740"></a><span class="lineno"> 2740</span>  <span class="keywordflow">if</span> (edit == <a class="code" href="namespacetesting_1_1internal_1_1edit__distance.html#ad46aa6da12aec1a3f166310478b53a08a7bdb9c74613a94f21b7489e0b5640a63">kMatch</a> || edit == <a class="code" href="namespacetesting_1_1internal_1_1edit__distance.html#ad46aa6da12aec1a3f166310478b53a08a814768ef6cd0264a0a10b1e701a63e78">kRemove</a> || edit == <a class="code" href="namespacetesting_1_1internal_1_1edit__distance.html#ad46aa6da12aec1a3f166310478b53a08afdbf30ecf9f32f60c646a34a358615f2">kReplace</a>) {</div><div class="line"><a name="l02741"></a><span class="lineno"> 2741</span>  hunk.PushLine(edit == <a class="code" href="namespacetesting_1_1internal_1_1edit__distance.html#ad46aa6da12aec1a3f166310478b53a08a7bdb9c74613a94f21b7489e0b5640a63">kMatch</a> ? <span class="charliteral">' '</span> : <span class="charliteral">'-'</span>, left[l_i].c_str());</div><div class="line"><a name="l02742"></a><span class="lineno"> 2742</span>  }</div><div class="line"><a name="l02743"></a><span class="lineno"> 2743</span>  <span class="keywordflow">if</span> (edit == <a class="code" href="namespacetesting_1_1internal_1_1edit__distance.html#ad46aa6da12aec1a3f166310478b53a08a63400b073f5b311a87d568b5ae27ffe8">kAdd</a> || edit == <a class="code" href="namespacetesting_1_1internal_1_1edit__distance.html#ad46aa6da12aec1a3f166310478b53a08afdbf30ecf9f32f60c646a34a358615f2">kReplace</a>) {</div><div class="line"><a name="l02744"></a><span class="lineno"> 2744</span>  hunk.PushLine(<span class="charliteral">'+'</span>, right[r_i].c_str());</div><div class="line"><a name="l02745"></a><span class="lineno"> 2745</span>  }</div><div class="line"><a name="l02746"></a><span class="lineno"> 2746</span> </div><div class="line"><a name="l02747"></a><span class="lineno"> 2747</span>  <span class="comment">// Advance indices, depending on edit type.</span></div><div class="line"><a name="l02748"></a><span class="lineno"> 2748</span>  l_i += edit != <a class="code" href="namespacetesting_1_1internal_1_1edit__distance.html#ad46aa6da12aec1a3f166310478b53a08a63400b073f5b311a87d568b5ae27ffe8">kAdd</a>;</div><div class="line"><a name="l02749"></a><span class="lineno"> 2749</span>  r_i += edit != <a class="code" href="namespacetesting_1_1internal_1_1edit__distance.html#ad46aa6da12aec1a3f166310478b53a08a814768ef6cd0264a0a10b1e701a63e78">kRemove</a>;</div><div class="line"><a name="l02750"></a><span class="lineno"> 2750</span>  }</div><div class="line"><a name="l02751"></a><span class="lineno"> 2751</span> </div><div class="line"><a name="l02752"></a><span class="lineno"> 2752</span>  <span class="keywordflow">if</span> (!hunk.has_edits()) {</div><div class="line"><a name="l02753"></a><span class="lineno"> 2753</span>  <span class="comment">// We are done. We don't want this hunk.</span></div><div class="line"><a name="l02754"></a><span class="lineno"> 2754</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l02755"></a><span class="lineno"> 2755</span>  }</div><div class="line"><a name="l02756"></a><span class="lineno"> 2756</span> </div><div class="line"><a name="l02757"></a><span class="lineno"> 2757</span>  hunk.PrintTo(&ss);</div><div class="line"><a name="l02758"></a><span class="lineno"> 2758</span>  }</div><div class="line"><a name="l02759"></a><span class="lineno"> 2759</span>  <span class="keywordflow">return</span> ss.str();</div><div class="line"><a name="l02760"></a><span class="lineno"> 2760</span> }</div><div class="line"><a name="l02761"></a><span class="lineno"> 2761</span> </div><div class="line"><a name="l02762"></a><span class="lineno"> 2762</span> } <span class="comment">// namespace edit_distance</span></div><div class="line"><a name="l02763"></a><span class="lineno"> 2763</span> </div><div class="line"><a name="l02764"></a><span class="lineno"> 2764</span> <span class="keyword">namespace </span>{</div><div class="line"><a name="l02765"></a><span class="lineno"> 2765</span> </div><div class="line"><a name="l02766"></a><span class="lineno"> 2766</span> <span class="comment">// The string representation of the values received in EqFailure() are already</span></div><div class="line"><a name="l02767"></a><span class="lineno"> 2767</span> <span class="comment">// escaped. Split them on escaped '\n' boundaries. Leave all other escaped</span></div><div class="line"><a name="l02768"></a><span class="lineno"> 2768</span> <span class="comment">// characters the same.</span></div><div class="line"><a name="l02769"></a><span class="lineno"> 2769</span> std::vector<std::string> SplitEscapedString(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& str) {</div><div class="line"><a name="l02770"></a><span class="lineno"> 2770</span>  std::vector<std::string> lines;</div><div class="line"><a name="l02771"></a><span class="lineno"> 2771</span>  <span class="keywordtype">size_t</span> start = 0, end = str.size();</div><div class="line"><a name="l02772"></a><span class="lineno"> 2772</span>  <span class="keywordflow">if</span> (end > 2 && str[0] == <span class="charliteral">'"'</span> && str[end - 1] == <span class="charliteral">'"'</span>) {</div><div class="line"><a name="l02773"></a><span class="lineno"> 2773</span>  ++start;</div><div class="line"><a name="l02774"></a><span class="lineno"> 2774</span>  --end;</div><div class="line"><a name="l02775"></a><span class="lineno"> 2775</span>  }</div><div class="line"><a name="l02776"></a><span class="lineno"> 2776</span>  <span class="keywordtype">bool</span> escaped = <span class="keyword">false</span>;</div><div class="line"><a name="l02777"></a><span class="lineno"> 2777</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = start; i + 1 < end; ++i) {</div><div class="line"><a name="l02778"></a><span class="lineno"> 2778</span>  <span class="keywordflow">if</span> (escaped) {</div><div class="line"><a name="l02779"></a><span class="lineno"> 2779</span>  escaped = <span class="keyword">false</span>;</div><div class="line"><a name="l02780"></a><span class="lineno"> 2780</span>  <span class="keywordflow">if</span> (str[i] == <span class="charliteral">'n'</span>) {</div><div class="line"><a name="l02781"></a><span class="lineno"> 2781</span>  lines.push_back(str.substr(start, i - start - 1));</div><div class="line"><a name="l02782"></a><span class="lineno"> 2782</span>  start = i + 1;</div><div class="line"><a name="l02783"></a><span class="lineno"> 2783</span>  }</div><div class="line"><a name="l02784"></a><span class="lineno"> 2784</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l02785"></a><span class="lineno"> 2785</span>  escaped = str[i] == <span class="charliteral">'\\'</span>;</div><div class="line"><a name="l02786"></a><span class="lineno"> 2786</span>  }</div><div class="line"><a name="l02787"></a><span class="lineno"> 2787</span>  }</div><div class="line"><a name="l02788"></a><span class="lineno"> 2788</span>  lines.push_back(str.substr(start, end - start));</div><div class="line"><a name="l02789"></a><span class="lineno"> 2789</span>  <span class="keywordflow">return</span> lines;</div><div class="line"><a name="l02790"></a><span class="lineno"> 2790</span> }</div><div class="line"><a name="l02791"></a><span class="lineno"> 2791</span> </div><div class="line"><a name="l02792"></a><span class="lineno"> 2792</span> } <span class="comment">// namespace</span></div><div class="line"><a name="l02793"></a><span class="lineno"> 2793</span> </div><div class="line"><a name="l02794"></a><span class="lineno"> 2794</span> <span class="comment">// Constructs and returns the message for an equality assertion</span></div><div class="line"><a name="l02795"></a><span class="lineno"> 2795</span> <span class="comment">// (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure.</span></div><div class="line"><a name="l02796"></a><span class="lineno"> 2796</span> <span class="comment">//</span></div><div class="line"><a name="l02797"></a><span class="lineno"> 2797</span> <span class="comment">// The first four parameters are the expressions used in the assertion</span></div><div class="line"><a name="l02798"></a><span class="lineno"> 2798</span> <span class="comment">// and their values, as strings. For example, for ASSERT_EQ(foo, bar)</span></div><div class="line"><a name="l02799"></a><span class="lineno"> 2799</span> <span class="comment">// where foo is 5 and bar is 6, we have:</span></div><div class="line"><a name="l02800"></a><span class="lineno"> 2800</span> <span class="comment">//</span></div><div class="line"><a name="l02801"></a><span class="lineno"> 2801</span> <span class="comment">// lhs_expression: "foo"</span></div><div class="line"><a name="l02802"></a><span class="lineno"> 2802</span> <span class="comment">// rhs_expression: "bar"</span></div><div class="line"><a name="l02803"></a><span class="lineno"> 2803</span> <span class="comment">// lhs_value: "5"</span></div><div class="line"><a name="l02804"></a><span class="lineno"> 2804</span> <span class="comment">// rhs_value: "6"</span></div><div class="line"><a name="l02805"></a><span class="lineno"> 2805</span> <span class="comment">//</span></div><div class="line"><a name="l02806"></a><span class="lineno"> 2806</span> <span class="comment">// The ignoring_case parameter is true iff the assertion is a</span></div><div class="line"><a name="l02807"></a><span class="lineno"> 2807</span> <span class="comment">// *_STRCASEEQ*. When it's true, the string "Ignoring case" will</span></div><div class="line"><a name="l02808"></a><span class="lineno"> 2808</span> <span class="comment">// be inserted into the message.</span></div><div class="line"><a name="l02809"></a><span class="lineno"> 2809</span> AssertionResult <a class="code" href="namespacetesting_1_1internal.html#ac61e2ba2cbf259fd6ee5ffd4e49c9445">EqFailure</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* lhs_expression,</div><div class="line"><a name="l02810"></a><span class="lineno"> 2810</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* rhs_expression,</div><div class="line"><a name="l02811"></a><span class="lineno"> 2811</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& lhs_value,</div><div class="line"><a name="l02812"></a><span class="lineno"> 2812</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& rhs_value,</div><div class="line"><a name="l02813"></a><span class="lineno"> 2813</span>  <span class="keywordtype">bool</span> ignoring_case) {</div><div class="line"><a name="l02814"></a><span class="lineno"> 2814</span>  Message msg;</div><div class="line"><a name="l02815"></a><span class="lineno"> 2815</span>  msg << <span class="stringliteral">"Expected equality of these values:"</span>;</div><div class="line"><a name="l02816"></a><span class="lineno"> 2816</span>  msg << <span class="stringliteral">"\n "</span> << lhs_expression;</div><div class="line"><a name="l02817"></a><span class="lineno"> 2817</span>  <span class="keywordflow">if</span> (lhs_value != lhs_expression) {</div><div class="line"><a name="l02818"></a><span class="lineno"> 2818</span>  msg << <span class="stringliteral">"\n Which is: "</span> << lhs_value;</div><div class="line"><a name="l02819"></a><span class="lineno"> 2819</span>  }</div><div class="line"><a name="l02820"></a><span class="lineno"> 2820</span>  msg << <span class="stringliteral">"\n "</span> << rhs_expression;</div><div class="line"><a name="l02821"></a><span class="lineno"> 2821</span>  <span class="keywordflow">if</span> (rhs_value != rhs_expression) {</div><div class="line"><a name="l02822"></a><span class="lineno"> 2822</span>  msg << <span class="stringliteral">"\n Which is: "</span> << rhs_value;</div><div class="line"><a name="l02823"></a><span class="lineno"> 2823</span>  }</div><div class="line"><a name="l02824"></a><span class="lineno"> 2824</span> </div><div class="line"><a name="l02825"></a><span class="lineno"> 2825</span>  <span class="keywordflow">if</span> (ignoring_case) {</div><div class="line"><a name="l02826"></a><span class="lineno"> 2826</span>  msg << <span class="stringliteral">"\nIgnoring case"</span>;</div><div class="line"><a name="l02827"></a><span class="lineno"> 2827</span>  }</div><div class="line"><a name="l02828"></a><span class="lineno"> 2828</span> </div><div class="line"><a name="l02829"></a><span class="lineno"> 2829</span>  <span class="keywordflow">if</span> (!lhs_value.empty() && !rhs_value.empty()) {</div><div class="line"><a name="l02830"></a><span class="lineno"> 2830</span>  <span class="keyword">const</span> std::vector<std::string> lhs_lines =</div><div class="line"><a name="l02831"></a><span class="lineno"> 2831</span>  SplitEscapedString(lhs_value);</div><div class="line"><a name="l02832"></a><span class="lineno"> 2832</span>  <span class="keyword">const</span> std::vector<std::string> rhs_lines =</div><div class="line"><a name="l02833"></a><span class="lineno"> 2833</span>  SplitEscapedString(rhs_value);</div><div class="line"><a name="l02834"></a><span class="lineno"> 2834</span>  <span class="keywordflow">if</span> (lhs_lines.size() > 1 || rhs_lines.size() > 1) {</div><div class="line"><a name="l02835"></a><span class="lineno"> 2835</span>  msg << <span class="stringliteral">"\nWith diff:\n"</span></div><div class="line"><a name="l02836"></a><span class="lineno"> 2836</span>  << <a class="code" href="namespacetesting_1_1internal_1_1edit__distance.html#a48cffebc6d3169ad1df7849b5f7fb5ff">edit_distance::CreateUnifiedDiff</a>(lhs_lines, rhs_lines);</div><div class="line"><a name="l02837"></a><span class="lineno"> 2837</span>  }</div><div class="line"><a name="l02838"></a><span class="lineno"> 2838</span>  }</div><div class="line"><a name="l02839"></a><span class="lineno"> 2839</span> </div><div class="line"><a name="l02840"></a><span class="lineno"> 2840</span>  <span class="keywordflow">return</span> AssertionFailure() << msg;</div><div class="line"><a name="l02841"></a><span class="lineno"> 2841</span> }</div><div class="line"><a name="l02842"></a><span class="lineno"> 2842</span> </div><div class="line"><a name="l02843"></a><span class="lineno"> 2843</span> <span class="comment">// Constructs a failure message for Boolean assertions such as EXPECT_TRUE.</span></div><div class="line"><a name="l02844"></a><span class="lineno"> 2844</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> <a class="code" href="namespacetesting_1_1internal.html#aed8d3ad4341f8f2de53440e39c995632">GetBoolAssertionFailureMessage</a>(</div><div class="line"><a name="l02845"></a><span class="lineno"> 2845</span>  <span class="keyword">const</span> AssertionResult& assertion_result,</div><div class="line"><a name="l02846"></a><span class="lineno"> 2846</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* expression_text,</div><div class="line"><a name="l02847"></a><span class="lineno"> 2847</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* actual_predicate_value,</div><div class="line"><a name="l02848"></a><span class="lineno"> 2848</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* expected_predicate_value) {</div><div class="line"><a name="l02849"></a><span class="lineno"> 2849</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* actual_message = assertion_result.message();</div><div class="line"><a name="l02850"></a><span class="lineno"> 2850</span>  Message msg;</div><div class="line"><a name="l02851"></a><span class="lineno"> 2851</span>  msg << <span class="stringliteral">"Value of: "</span> << expression_text</div><div class="line"><a name="l02852"></a><span class="lineno"> 2852</span>  << <span class="stringliteral">"\n Actual: "</span> << actual_predicate_value;</div><div class="line"><a name="l02853"></a><span class="lineno"> 2853</span>  <span class="keywordflow">if</span> (actual_message[0] != <span class="charliteral">'\0'</span>)</div><div class="line"><a name="l02854"></a><span class="lineno"> 2854</span>  msg << <span class="stringliteral">" ("</span> << actual_message << <span class="stringliteral">")"</span>;</div><div class="line"><a name="l02855"></a><span class="lineno"> 2855</span>  msg << <span class="stringliteral">"\nExpected: "</span> << expected_predicate_value;</div><div class="line"><a name="l02856"></a><span class="lineno"> 2856</span>  <span class="keywordflow">return</span> msg.GetString();</div><div class="line"><a name="l02857"></a><span class="lineno"> 2857</span> }</div><div class="line"><a name="l02858"></a><span class="lineno"> 2858</span> </div><div class="line"><a name="l02859"></a><span class="lineno"> 2859</span> <span class="comment">// Helper function for implementing ASSERT_NEAR.</span></div><div class="line"><a name="l02860"></a><span class="lineno"> 2860</span> AssertionResult <a class="code" href="namespacetesting_1_1internal.html#aea60207c4cedc8946a70ada62e38da8f">DoubleNearPredFormat</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* expr1,</div><div class="line"><a name="l02861"></a><span class="lineno"> 2861</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* expr2,</div><div class="line"><a name="l02862"></a><span class="lineno"> 2862</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* abs_error_expr,</div><div class="line"><a name="l02863"></a><span class="lineno"> 2863</span>  <span class="keywordtype">double</span> val1,</div><div class="line"><a name="l02864"></a><span class="lineno"> 2864</span>  <span class="keywordtype">double</span> val2,</div><div class="line"><a name="l02865"></a><span class="lineno"> 2865</span>  <span class="keywordtype">double</span> abs_error) {</div><div class="line"><a name="l02866"></a><span class="lineno"> 2866</span>  <span class="keyword">const</span> <span class="keywordtype">double</span> diff = fabs(val1 - val2);</div><div class="line"><a name="l02867"></a><span class="lineno"> 2867</span>  <span class="keywordflow">if</span> (diff <= abs_error) <span class="keywordflow">return</span> AssertionSuccess();</div><div class="line"><a name="l02868"></a><span class="lineno"> 2868</span> </div><div class="line"><a name="l02869"></a><span class="lineno"> 2869</span>  <span class="keywordflow">return</span> AssertionFailure()</div><div class="line"><a name="l02870"></a><span class="lineno"> 2870</span>  << <span class="stringliteral">"The difference between "</span> << expr1 << <span class="stringliteral">" and "</span> << expr2</div><div class="line"><a name="l02871"></a><span class="lineno"> 2871</span>  << <span class="stringliteral">" is "</span> << diff << <span class="stringliteral">", which exceeds "</span> << abs_error_expr << <span class="stringliteral">", where\n"</span></div><div class="line"><a name="l02872"></a><span class="lineno"> 2872</span>  << expr1 << <span class="stringliteral">" evaluates to "</span> << val1 << <span class="stringliteral">",\n"</span></div><div class="line"><a name="l02873"></a><span class="lineno"> 2873</span>  << expr2 << <span class="stringliteral">" evaluates to "</span> << val2 << <span class="stringliteral">", and\n"</span></div><div class="line"><a name="l02874"></a><span class="lineno"> 2874</span>  << abs_error_expr << <span class="stringliteral">" evaluates to "</span> << abs_error << <span class="stringliteral">"."</span>;</div><div class="line"><a name="l02875"></a><span class="lineno"> 2875</span> }</div><div class="line"><a name="l02876"></a><span class="lineno"> 2876</span> </div><div class="line"><a name="l02877"></a><span class="lineno"> 2877</span> </div><div class="line"><a name="l02878"></a><span class="lineno"> 2878</span> <span class="comment">// Helper template for implementing FloatLE() and DoubleLE().</span></div><div class="line"><a name="l02879"></a><span class="lineno"> 2879</span> <span class="keyword">template</span> <<span class="keyword">typename</span> RawType></div><div class="line"><a name="l02880"></a><span class="lineno"> 2880</span> AssertionResult FloatingPointLE(<span class="keyword">const</span> <span class="keywordtype">char</span>* expr1,</div><div class="line"><a name="l02881"></a><span class="lineno"> 2881</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* expr2,</div><div class="line"><a name="l02882"></a><span class="lineno"> 2882</span>  RawType val1,</div><div class="line"><a name="l02883"></a><span class="lineno"> 2883</span>  RawType val2) {</div><div class="line"><a name="l02884"></a><span class="lineno"> 2884</span>  <span class="comment">// Returns success if val1 is less than val2,</span></div><div class="line"><a name="l02885"></a><span class="lineno"> 2885</span>  <span class="keywordflow">if</span> (val1 < val2) {</div><div class="line"><a name="l02886"></a><span class="lineno"> 2886</span>  <span class="keywordflow">return</span> AssertionSuccess();</div><div class="line"><a name="l02887"></a><span class="lineno"> 2887</span>  }</div><div class="line"><a name="l02888"></a><span class="lineno"> 2888</span> </div><div class="line"><a name="l02889"></a><span class="lineno"> 2889</span>  <span class="comment">// or if val1 is almost equal to val2.</span></div><div class="line"><a name="l02890"></a><span class="lineno"> 2890</span>  <span class="keyword">const</span> FloatingPoint<RawType> lhs(val1), rhs(val2);</div><div class="line"><a name="l02891"></a><span class="lineno"> 2891</span>  <span class="keywordflow">if</span> (lhs.AlmostEquals(rhs)) {</div><div class="line"><a name="l02892"></a><span class="lineno"> 2892</span>  <span class="keywordflow">return</span> AssertionSuccess();</div><div class="line"><a name="l02893"></a><span class="lineno"> 2893</span>  }</div><div class="line"><a name="l02894"></a><span class="lineno"> 2894</span> </div><div class="line"><a name="l02895"></a><span class="lineno"> 2895</span>  <span class="comment">// Note that the above two checks will both fail if either val1 or</span></div><div class="line"><a name="l02896"></a><span class="lineno"> 2896</span>  <span class="comment">// val2 is NaN, as the IEEE floating-point standard requires that</span></div><div class="line"><a name="l02897"></a><span class="lineno"> 2897</span>  <span class="comment">// any predicate involving a NaN must return false.</span></div><div class="line"><a name="l02898"></a><span class="lineno"> 2898</span> </div><div class="line"><a name="l02899"></a><span class="lineno"> 2899</span>  ::std::stringstream val1_ss;</div><div class="line"><a name="l02900"></a><span class="lineno"> 2900</span>  val1_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)</div><div class="line"><a name="l02901"></a><span class="lineno"> 2901</span>  << val1;</div><div class="line"><a name="l02902"></a><span class="lineno"> 2902</span> </div><div class="line"><a name="l02903"></a><span class="lineno"> 2903</span>  ::std::stringstream val2_ss;</div><div class="line"><a name="l02904"></a><span class="lineno"> 2904</span>  val2_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)</div><div class="line"><a name="l02905"></a><span class="lineno"> 2905</span>  << val2;</div><div class="line"><a name="l02906"></a><span class="lineno"> 2906</span> </div><div class="line"><a name="l02907"></a><span class="lineno"> 2907</span>  <span class="keywordflow">return</span> AssertionFailure()</div><div class="line"><a name="l02908"></a><span class="lineno"> 2908</span>  << <span class="stringliteral">"Expected: ("</span> << expr1 << <span class="stringliteral">") <= ("</span> << expr2 << <span class="stringliteral">")\n"</span></div><div class="line"><a name="l02909"></a><span class="lineno"> 2909</span>  << <span class="stringliteral">" Actual: "</span> << StringStreamToString(&val1_ss) << <span class="stringliteral">" vs "</span></div><div class="line"><a name="l02910"></a><span class="lineno"> 2910</span>  << StringStreamToString(&val2_ss);</div><div class="line"><a name="l02911"></a><span class="lineno"> 2911</span> }</div><div class="line"><a name="l02912"></a><span class="lineno"> 2912</span> </div><div class="line"><a name="l02913"></a><span class="lineno"> 2913</span> } <span class="comment">// namespace internal</span></div><div class="line"><a name="l02914"></a><span class="lineno"> 2914</span> </div><div class="line"><a name="l02915"></a><span class="lineno"> 2915</span> <span class="comment">// Asserts that val1 is less than, or almost equal to, val2. Fails</span></div><div class="line"><a name="l02916"></a><span class="lineno"> 2916</span> <span class="comment">// otherwise. In particular, it fails if either val1 or val2 is NaN.</span></div><div class="line"><a name="l02917"></a><span class="lineno"> 2917</span> AssertionResult <a class="code" href="namespacetesting.html#a69106491c2e7f50e50da0ce5e8ae4374">FloatLE</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* expr1, <span class="keyword">const</span> <span class="keywordtype">char</span>* expr2,</div><div class="line"><a name="l02918"></a><span class="lineno"> 2918</span>  <span class="keywordtype">float</span> val1, <span class="keywordtype">float</span> val2) {</div><div class="line"><a name="l02919"></a><span class="lineno"> 2919</span>  <span class="keywordflow">return</span> internal::FloatingPointLE<float>(expr1, expr2, val1, val2);</div><div class="line"><a name="l02920"></a><span class="lineno"> 2920</span> }</div><div class="line"><a name="l02921"></a><span class="lineno"> 2921</span> </div><div class="line"><a name="l02922"></a><span class="lineno"> 2922</span> <span class="comment">// Asserts that val1 is less than, or almost equal to, val2. Fails</span></div><div class="line"><a name="l02923"></a><span class="lineno"> 2923</span> <span class="comment">// otherwise. In particular, it fails if either val1 or val2 is NaN.</span></div><div class="line"><a name="l02924"></a><span class="lineno"> 2924</span> AssertionResult <a class="code" href="namespacetesting.html#a84c020b981d0eb4eabfb0feda155aaaf">DoubleLE</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* expr1, <span class="keyword">const</span> <span class="keywordtype">char</span>* expr2,</div><div class="line"><a name="l02925"></a><span class="lineno"> 2925</span>  <span class="keywordtype">double</span> val1, <span class="keywordtype">double</span> val2) {</div><div class="line"><a name="l02926"></a><span class="lineno"> 2926</span>  <span class="keywordflow">return</span> internal::FloatingPointLE<double>(expr1, expr2, val1, val2);</div><div class="line"><a name="l02927"></a><span class="lineno"> 2927</span> }</div><div class="line"><a name="l02928"></a><span class="lineno"> 2928</span> </div><div class="line"><a name="l02929"></a><span class="lineno"> 2929</span> <span class="keyword">namespace </span>internal {</div><div class="line"><a name="l02930"></a><span class="lineno"> 2930</span> </div><div class="line"><a name="l02931"></a><span class="lineno"> 2931</span> <span class="comment">// The helper function for {ASSERT|EXPECT}_EQ with int or enum</span></div><div class="line"><a name="l02932"></a><span class="lineno"> 2932</span> <span class="comment">// arguments.</span></div><div class="line"><a name="l02933"></a><span class="lineno"> 2933</span> AssertionResult <a class="code" href="namespacetesting_1_1internal.html#a4638c74d9b32e971f9b321af6fafc2f1">CmpHelperEQ</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* lhs_expression,</div><div class="line"><a name="l02934"></a><span class="lineno"> 2934</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* rhs_expression,</div><div class="line"><a name="l02935"></a><span class="lineno"> 2935</span>  <a class="code" href="namespacetesting_1_1internal.html#a05c6bd9ede5ccdf25191a590d610dcc6">BiggestInt</a> lhs,</div><div class="line"><a name="l02936"></a><span class="lineno"> 2936</span>  <a class="code" href="namespacetesting_1_1internal.html#a05c6bd9ede5ccdf25191a590d610dcc6">BiggestInt</a> rhs) {</div><div class="line"><a name="l02937"></a><span class="lineno"> 2937</span>  <span class="keywordflow">if</span> (lhs == rhs) {</div><div class="line"><a name="l02938"></a><span class="lineno"> 2938</span>  <span class="keywordflow">return</span> AssertionSuccess();</div><div class="line"><a name="l02939"></a><span class="lineno"> 2939</span>  }</div><div class="line"><a name="l02940"></a><span class="lineno"> 2940</span> </div><div class="line"><a name="l02941"></a><span class="lineno"> 2941</span>  <span class="keywordflow">return</span> <a class="code" href="namespacetesting_1_1internal.html#ac61e2ba2cbf259fd6ee5ffd4e49c9445">EqFailure</a>(lhs_expression,</div><div class="line"><a name="l02942"></a><span class="lineno"> 2942</span>  rhs_expression,</div><div class="line"><a name="l02943"></a><span class="lineno"> 2943</span>  <a class="code" href="namespacetesting_1_1internal.html#a91ab078f10adc669f09b7f604975c518">FormatForComparisonFailureMessage</a>(lhs, rhs),</div><div class="line"><a name="l02944"></a><span class="lineno"> 2944</span>  <a class="code" href="namespacetesting_1_1internal.html#a91ab078f10adc669f09b7f604975c518">FormatForComparisonFailureMessage</a>(rhs, lhs),</div><div class="line"><a name="l02945"></a><span class="lineno"> 2945</span>  <span class="keyword">false</span>);</div><div class="line"><a name="l02946"></a><span class="lineno"> 2946</span> }</div><div class="line"><a name="l02947"></a><span class="lineno"> 2947</span> </div><div class="line"><a name="l02948"></a><span class="lineno"> 2948</span> <span class="comment">// A macro for implementing the helper functions needed to implement</span></div><div class="line"><a name="l02949"></a><span class="lineno"> 2949</span> <span class="comment">// ASSERT_?? and EXPECT_?? with integer or enum arguments. It is here</span></div><div class="line"><a name="l02950"></a><span class="lineno"> 2950</span> <span class="comment">// just to avoid copy-and-paste of similar code.</span></div><div class="line"><a name="l02951"></a><span class="lineno"> 2951</span> <span class="preprocessor">#define GTEST_IMPL_CMP_HELPER_(op_name, op)\</span></div><div class="line"><a name="l02952"></a><span class="lineno"> 2952</span> <span class="preprocessor">AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \</span></div><div class="line"><a name="l02953"></a><span class="lineno"> 2953</span> <span class="preprocessor"> BiggestInt val1, BiggestInt val2) {\</span></div><div class="line"><a name="l02954"></a><span class="lineno"> 2954</span> <span class="preprocessor"> if (val1 op val2) {\</span></div><div class="line"><a name="l02955"></a><span class="lineno"> 2955</span> <span class="preprocessor"> return AssertionSuccess();\</span></div><div class="line"><a name="l02956"></a><span class="lineno"> 2956</span> <span class="preprocessor"> } else {\</span></div><div class="line"><a name="l02957"></a><span class="lineno"> 2957</span> <span class="preprocessor"> return AssertionFailure() \</span></div><div class="line"><a name="l02958"></a><span class="lineno"> 2958</span> <span class="preprocessor"> << "Expected: (" << expr1 << ") " #op " (" << expr2\</span></div><div class="line"><a name="l02959"></a><span class="lineno"> 2959</span> <span class="preprocessor"> << "), actual: " << FormatForComparisonFailureMessage(val1, val2)\</span></div><div class="line"><a name="l02960"></a><span class="lineno"> 2960</span> <span class="preprocessor"> << " vs " << FormatForComparisonFailureMessage(val2, val1);\</span></div><div class="line"><a name="l02961"></a><span class="lineno"> 2961</span> <span class="preprocessor"> }\</span></div><div class="line"><a name="l02962"></a><span class="lineno"> 2962</span> <span class="preprocessor">}</span></div><div class="line"><a name="l02963"></a><span class="lineno"> 2963</span> </div><div class="line"><a name="l02964"></a><span class="lineno"> 2964</span> <span class="comment">// Implements the helper function for {ASSERT|EXPECT}_NE with int or</span></div><div class="line"><a name="l02965"></a><span class="lineno"> 2965</span> <span class="comment">// enum arguments.</span></div><div class="line"><a name="l02966"></a><span class="lineno"> 2966</span> <a class="code" href="gtest-all_8cc.html#a4a5b6fbde5dd05e05dd6846ac5e5c18e">GTEST_IMPL_CMP_HELPER_</a>(NE, !=)</div><div class="line"><a name="l02967"></a><span class="lineno"> 2967</span> <span class="comment">// Implements the helper function for {ASSERT|EXPECT}_LE with int or</span></div><div class="line"><a name="l02968"></a><span class="lineno"> 2968</span> <span class="comment">// enum arguments.</span></div><div class="line"><a name="l02969"></a><span class="lineno"> 2969</span> <a class="code" href="gtest-all_8cc.html#a4a5b6fbde5dd05e05dd6846ac5e5c18e">GTEST_IMPL_CMP_HELPER_</a>(LE, <=)</div><div class="line"><a name="l02970"></a><span class="lineno"> 2970</span> <span class="comment">// Implements the helper function for {ASSERT|EXPECT}_LT with int or</span></div><div class="line"><a name="l02971"></a><span class="lineno"> 2971</span> <span class="comment">// enum arguments.</span></div><div class="line"><a name="l02972"></a><span class="lineno"> 2972</span> <a class="code" href="gtest-all_8cc.html#a4a5b6fbde5dd05e05dd6846ac5e5c18e">GTEST_IMPL_CMP_HELPER_</a>(LT, < )</div><div class="line"><a name="l02973"></a><span class="lineno"> 2973</span> <span class="comment">// Implements the helper function for {ASSERT|EXPECT}_GE with int or</span></div><div class="line"><a name="l02974"></a><span class="lineno"> 2974</span> <span class="comment">// enum arguments.</span></div><div class="line"><a name="l02975"></a><span class="lineno"> 2975</span> <a class="code" href="gtest-all_8cc.html#a4a5b6fbde5dd05e05dd6846ac5e5c18e">GTEST_IMPL_CMP_HELPER_</a>(GE, >=)</div><div class="line"><a name="l02976"></a><span class="lineno"> 2976</span> <span class="comment">// Implements the helper function for {ASSERT|EXPECT}_GT with int or</span></div><div class="line"><a name="l02977"></a><span class="lineno"> 2977</span> <span class="comment">// enum arguments.</span></div><div class="line"><a name="l02978"></a><span class="lineno"> 2978</span> <a class="code" href="gtest-all_8cc.html#a4a5b6fbde5dd05e05dd6846ac5e5c18e">GTEST_IMPL_CMP_HELPER_</a>(GT, > )</div><div class="line"><a name="l02979"></a><span class="lineno"> 2979</span> </div><div class="line"><a name="l02980"></a><span class="lineno"> 2980</span> <span class="preprocessor">#undef GTEST_IMPL_CMP_HELPER_</span></div><div class="line"><a name="l02981"></a><span class="lineno"> 2981</span> </div><div class="line"><a name="l02982"></a><span class="lineno"> 2982</span> <span class="comment">// The helper function for {ASSERT|EXPECT}_STREQ.</span></div><div class="line"><a name="l02983"></a><span class="lineno"> 2983</span> AssertionResult <a class="code" href="namespacetesting_1_1internal.html#a93eb9d61cac7faf1faff6301ae5f4a46">CmpHelperSTREQ</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* lhs_expression,</div><div class="line"><a name="l02984"></a><span class="lineno"> 2984</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* rhs_expression,</div><div class="line"><a name="l02985"></a><span class="lineno"> 2985</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* lhs,</div><div class="line"><a name="l02986"></a><span class="lineno"> 2986</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* rhs) {</div><div class="line"><a name="l02987"></a><span class="lineno"> 2987</span>  <span class="keywordflow">if</span> (String::CStringEquals(lhs, rhs)) {</div><div class="line"><a name="l02988"></a><span class="lineno"> 2988</span>  <span class="keywordflow">return</span> AssertionSuccess();</div><div class="line"><a name="l02989"></a><span class="lineno"> 2989</span>  }</div><div class="line"><a name="l02990"></a><span class="lineno"> 2990</span> </div><div class="line"><a name="l02991"></a><span class="lineno"> 2991</span>  <span class="keywordflow">return</span> <a class="code" href="namespacetesting_1_1internal.html#ac61e2ba2cbf259fd6ee5ffd4e49c9445">EqFailure</a>(lhs_expression,</div><div class="line"><a name="l02992"></a><span class="lineno"> 2992</span>  rhs_expression,</div><div class="line"><a name="l02993"></a><span class="lineno"> 2993</span>  <a class="code" href="namespacetesting.html#aa5717bb1144edd1d262d310ba70c82ed">PrintToString</a>(lhs),</div><div class="line"><a name="l02994"></a><span class="lineno"> 2994</span>  <a class="code" href="namespacetesting.html#aa5717bb1144edd1d262d310ba70c82ed">PrintToString</a>(rhs),</div><div class="line"><a name="l02995"></a><span class="lineno"> 2995</span>  <span class="keyword">false</span>);</div><div class="line"><a name="l02996"></a><span class="lineno"> 2996</span> }</div><div class="line"><a name="l02997"></a><span class="lineno"> 2997</span> </div><div class="line"><a name="l02998"></a><span class="lineno"> 2998</span> <span class="comment">// The helper function for {ASSERT|EXPECT}_STRCASEEQ.</span></div><div class="line"><a name="l02999"></a><span class="lineno"> 2999</span> AssertionResult <a class="code" href="namespacetesting_1_1internal.html#a00c3d012df6173622ef558a131bfb95d">CmpHelperSTRCASEEQ</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* lhs_expression,</div><div class="line"><a name="l03000"></a><span class="lineno"> 3000</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* rhs_expression,</div><div class="line"><a name="l03001"></a><span class="lineno"> 3001</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* lhs,</div><div class="line"><a name="l03002"></a><span class="lineno"> 3002</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* rhs) {</div><div class="line"><a name="l03003"></a><span class="lineno"> 3003</span>  <span class="keywordflow">if</span> (String::CaseInsensitiveCStringEquals(lhs, rhs)) {</div><div class="line"><a name="l03004"></a><span class="lineno"> 3004</span>  <span class="keywordflow">return</span> AssertionSuccess();</div><div class="line"><a name="l03005"></a><span class="lineno"> 3005</span>  }</div><div class="line"><a name="l03006"></a><span class="lineno"> 3006</span> </div><div class="line"><a name="l03007"></a><span class="lineno"> 3007</span>  <span class="keywordflow">return</span> <a class="code" href="namespacetesting_1_1internal.html#ac61e2ba2cbf259fd6ee5ffd4e49c9445">EqFailure</a>(lhs_expression,</div><div class="line"><a name="l03008"></a><span class="lineno"> 3008</span>  rhs_expression,</div><div class="line"><a name="l03009"></a><span class="lineno"> 3009</span>  <a class="code" href="namespacetesting.html#aa5717bb1144edd1d262d310ba70c82ed">PrintToString</a>(lhs),</div><div class="line"><a name="l03010"></a><span class="lineno"> 3010</span>  <a class="code" href="namespacetesting.html#aa5717bb1144edd1d262d310ba70c82ed">PrintToString</a>(rhs),</div><div class="line"><a name="l03011"></a><span class="lineno"> 3011</span>  <span class="keyword">true</span>);</div><div class="line"><a name="l03012"></a><span class="lineno"> 3012</span> }</div><div class="line"><a name="l03013"></a><span class="lineno"> 3013</span> </div><div class="line"><a name="l03014"></a><span class="lineno"> 3014</span> <span class="comment">// The helper function for {ASSERT|EXPECT}_STRNE.</span></div><div class="line"><a name="l03015"></a><span class="lineno"> 3015</span> AssertionResult <a class="code" href="namespacetesting_1_1internal.html#a6b485231a046ff760844a0321c04870b">CmpHelperSTRNE</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* s1_expression,</div><div class="line"><a name="l03016"></a><span class="lineno"> 3016</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* s2_expression,</div><div class="line"><a name="l03017"></a><span class="lineno"> 3017</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* s1,</div><div class="line"><a name="l03018"></a><span class="lineno"> 3018</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* s2) {</div><div class="line"><a name="l03019"></a><span class="lineno"> 3019</span>  <span class="keywordflow">if</span> (!String::CStringEquals(s1, s2)) {</div><div class="line"><a name="l03020"></a><span class="lineno"> 3020</span>  <span class="keywordflow">return</span> AssertionSuccess();</div><div class="line"><a name="l03021"></a><span class="lineno"> 3021</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l03022"></a><span class="lineno"> 3022</span>  <span class="keywordflow">return</span> AssertionFailure() << <span class="stringliteral">"Expected: ("</span> << s1_expression << <span class="stringliteral">") != ("</span></div><div class="line"><a name="l03023"></a><span class="lineno"> 3023</span>  << s2_expression << <span class="stringliteral">"), actual: \""</span></div><div class="line"><a name="l03024"></a><span class="lineno"> 3024</span>  << s1 << <span class="stringliteral">"\" vs \""</span> << s2 << <span class="stringliteral">"\""</span>;</div><div class="line"><a name="l03025"></a><span class="lineno"> 3025</span>  }</div><div class="line"><a name="l03026"></a><span class="lineno"> 3026</span> }</div><div class="line"><a name="l03027"></a><span class="lineno"> 3027</span> </div><div class="line"><a name="l03028"></a><span class="lineno"> 3028</span> <span class="comment">// The helper function for {ASSERT|EXPECT}_STRCASENE.</span></div><div class="line"><a name="l03029"></a><span class="lineno"> 3029</span> AssertionResult <a class="code" href="namespacetesting_1_1internal.html#a5f74b933606b0a742cd5a8ad2d7087e0">CmpHelperSTRCASENE</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* s1_expression,</div><div class="line"><a name="l03030"></a><span class="lineno"> 3030</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* s2_expression,</div><div class="line"><a name="l03031"></a><span class="lineno"> 3031</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* s1,</div><div class="line"><a name="l03032"></a><span class="lineno"> 3032</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* s2) {</div><div class="line"><a name="l03033"></a><span class="lineno"> 3033</span>  <span class="keywordflow">if</span> (!String::CaseInsensitiveCStringEquals(s1, s2)) {</div><div class="line"><a name="l03034"></a><span class="lineno"> 3034</span>  <span class="keywordflow">return</span> AssertionSuccess();</div><div class="line"><a name="l03035"></a><span class="lineno"> 3035</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l03036"></a><span class="lineno"> 3036</span>  <span class="keywordflow">return</span> AssertionFailure()</div><div class="line"><a name="l03037"></a><span class="lineno"> 3037</span>  << <span class="stringliteral">"Expected: ("</span> << s1_expression << <span class="stringliteral">") != ("</span></div><div class="line"><a name="l03038"></a><span class="lineno"> 3038</span>  << s2_expression << <span class="stringliteral">") (ignoring case), actual: \""</span></div><div class="line"><a name="l03039"></a><span class="lineno"> 3039</span>  << s1 << <span class="stringliteral">"\" vs \""</span> << s2 << <span class="stringliteral">"\""</span>;</div><div class="line"><a name="l03040"></a><span class="lineno"> 3040</span>  }</div><div class="line"><a name="l03041"></a><span class="lineno"> 3041</span> }</div><div class="line"><a name="l03042"></a><span class="lineno"> 3042</span> </div><div class="line"><a name="l03043"></a><span class="lineno"> 3043</span> } <span class="comment">// namespace internal</span></div><div class="line"><a name="l03044"></a><span class="lineno"> 3044</span> </div><div class="line"><a name="l03045"></a><span class="lineno"> 3045</span> <span class="keyword">namespace </span>{</div><div class="line"><a name="l03046"></a><span class="lineno"> 3046</span> </div><div class="line"><a name="l03047"></a><span class="lineno"> 3047</span> <span class="comment">// Helper functions for implementing IsSubString() and IsNotSubstring().</span></div><div class="line"><a name="l03048"></a><span class="lineno"> 3048</span> </div><div class="line"><a name="l03049"></a><span class="lineno"> 3049</span> <span class="comment">// This group of overloaded functions return true iff needle is a</span></div><div class="line"><a name="l03050"></a><span class="lineno"> 3050</span> <span class="comment">// substring of haystack. NULL is considered a substring of itself</span></div><div class="line"><a name="l03051"></a><span class="lineno"> 3051</span> <span class="comment">// only.</span></div><div class="line"><a name="l03052"></a><span class="lineno"> 3052</span> </div><div class="line"><a name="l03053"></a><span class="lineno"> 3053</span> <span class="keywordtype">bool</span> IsSubstringPred(<span class="keyword">const</span> <span class="keywordtype">char</span>* needle, <span class="keyword">const</span> <span class="keywordtype">char</span>* haystack) {</div><div class="line"><a name="l03054"></a><span class="lineno"> 3054</span>  <span class="keywordflow">if</span> (needle == <span class="keyword">nullptr</span> || haystack == <span class="keyword">nullptr</span>) <span class="keywordflow">return</span> needle == haystack;</div><div class="line"><a name="l03055"></a><span class="lineno"> 3055</span> </div><div class="line"><a name="l03056"></a><span class="lineno"> 3056</span>  <span class="keywordflow">return</span> strstr(haystack, needle) != <span class="keyword">nullptr</span>;</div><div class="line"><a name="l03057"></a><span class="lineno"> 3057</span> }</div><div class="line"><a name="l03058"></a><span class="lineno"> 3058</span> </div><div class="line"><a name="l03059"></a><span class="lineno"> 3059</span> <span class="keywordtype">bool</span> IsSubstringPred(<span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* needle, <span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* haystack) {</div><div class="line"><a name="l03060"></a><span class="lineno"> 3060</span>  <span class="keywordflow">if</span> (needle == <span class="keyword">nullptr</span> || haystack == <span class="keyword">nullptr</span>) <span class="keywordflow">return</span> needle == haystack;</div><div class="line"><a name="l03061"></a><span class="lineno"> 3061</span> </div><div class="line"><a name="l03062"></a><span class="lineno"> 3062</span>  <span class="keywordflow">return</span> wcsstr(haystack, needle) != <span class="keyword">nullptr</span>;</div><div class="line"><a name="l03063"></a><span class="lineno"> 3063</span> }</div><div class="line"><a name="l03064"></a><span class="lineno"> 3064</span> </div><div class="line"><a name="l03065"></a><span class="lineno"> 3065</span> <span class="comment">// StringType here can be either ::std::string or ::std::wstring.</span></div><div class="line"><a name="l03066"></a><span class="lineno"> 3066</span> <span class="keyword">template</span> <<span class="keyword">typename</span> StringType></div><div class="line"><a name="l03067"></a><span class="lineno"> 3067</span> <span class="keywordtype">bool</span> IsSubstringPred(<span class="keyword">const</span> StringType& needle,</div><div class="line"><a name="l03068"></a><span class="lineno"> 3068</span>  <span class="keyword">const</span> StringType& haystack) {</div><div class="line"><a name="l03069"></a><span class="lineno"> 3069</span>  <span class="keywordflow">return</span> haystack.find(needle) != StringType::npos;</div><div class="line"><a name="l03070"></a><span class="lineno"> 3070</span> }</div><div class="line"><a name="l03071"></a><span class="lineno"> 3071</span> </div><div class="line"><a name="l03072"></a><span class="lineno"> 3072</span> <span class="comment">// This function implements either IsSubstring() or IsNotSubstring(),</span></div><div class="line"><a name="l03073"></a><span class="lineno"> 3073</span> <span class="comment">// depending on the value of the expected_to_be_substring parameter.</span></div><div class="line"><a name="l03074"></a><span class="lineno"> 3074</span> <span class="comment">// StringType here can be const char*, const wchar_t*, ::std::string,</span></div><div class="line"><a name="l03075"></a><span class="lineno"> 3075</span> <span class="comment">// or ::std::wstring.</span></div><div class="line"><a name="l03076"></a><span class="lineno"> 3076</span> <span class="keyword">template</span> <<span class="keyword">typename</span> StringType></div><div class="line"><a name="l03077"></a><span class="lineno"> 3077</span> AssertionResult IsSubstringImpl(</div><div class="line"><a name="l03078"></a><span class="lineno"> 3078</span>  <span class="keywordtype">bool</span> expected_to_be_substring,</div><div class="line"><a name="l03079"></a><span class="lineno"> 3079</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* needle_expr, <span class="keyword">const</span> <span class="keywordtype">char</span>* haystack_expr,</div><div class="line"><a name="l03080"></a><span class="lineno"> 3080</span>  <span class="keyword">const</span> StringType& needle, <span class="keyword">const</span> StringType& haystack) {</div><div class="line"><a name="l03081"></a><span class="lineno"> 3081</span>  <span class="keywordflow">if</span> (IsSubstringPred(needle, haystack) == expected_to_be_substring)</div><div class="line"><a name="l03082"></a><span class="lineno"> 3082</span>  <span class="keywordflow">return</span> AssertionSuccess();</div><div class="line"><a name="l03083"></a><span class="lineno"> 3083</span> </div><div class="line"><a name="l03084"></a><span class="lineno"> 3084</span>  <span class="keyword">const</span> <span class="keywordtype">bool</span> is_wide_string = <span class="keyword">sizeof</span>(needle[0]) > 1;</div><div class="line"><a name="l03085"></a><span class="lineno"> 3085</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> begin_string_quote = is_wide_string ? <span class="stringliteral">"L\""</span> : <span class="stringliteral">"\""</span>;</div><div class="line"><a name="l03086"></a><span class="lineno"> 3086</span>  <span class="keywordflow">return</span> AssertionFailure()</div><div class="line"><a name="l03087"></a><span class="lineno"> 3087</span>  << <span class="stringliteral">"Value of: "</span> << needle_expr << <span class="stringliteral">"\n"</span></div><div class="line"><a name="l03088"></a><span class="lineno"> 3088</span>  << <span class="stringliteral">" Actual: "</span> << begin_string_quote << needle << <span class="stringliteral">"\"\n"</span></div><div class="line"><a name="l03089"></a><span class="lineno"> 3089</span>  << <span class="stringliteral">"Expected: "</span> << (expected_to_be_substring ? <span class="stringliteral">""</span> : <span class="stringliteral">"not "</span>)</div><div class="line"><a name="l03090"></a><span class="lineno"> 3090</span>  << <span class="stringliteral">"a substring of "</span> << haystack_expr << <span class="stringliteral">"\n"</span></div><div class="line"><a name="l03091"></a><span class="lineno"> 3091</span>  << <span class="stringliteral">"Which is: "</span> << begin_string_quote << haystack << <span class="stringliteral">"\""</span>;</div><div class="line"><a name="l03092"></a><span class="lineno"> 3092</span> }</div><div class="line"><a name="l03093"></a><span class="lineno"> 3093</span> </div><div class="line"><a name="l03094"></a><span class="lineno"> 3094</span> } <span class="comment">// namespace</span></div><div class="line"><a name="l03095"></a><span class="lineno"> 3095</span> </div><div class="line"><a name="l03096"></a><span class="lineno"> 3096</span> <span class="comment">// IsSubstring() and IsNotSubstring() check whether needle is a</span></div><div class="line"><a name="l03097"></a><span class="lineno"> 3097</span> <span class="comment">// substring of haystack (NULL is considered a substring of itself</span></div><div class="line"><a name="l03098"></a><span class="lineno"> 3098</span> <span class="comment">// only), and return an appropriate error message when they fail.</span></div><div class="line"><a name="l03099"></a><span class="lineno"> 3099</span> </div><div class="line"><a name="l03100"></a><span class="lineno"> 3100</span> AssertionResult <a class="code" href="namespacetesting.html#a5c90a86562b2470213c07742e0eeb0fe">IsSubstring</a>(</div><div class="line"><a name="l03101"></a><span class="lineno"> 3101</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* needle_expr, <span class="keyword">const</span> <span class="keywordtype">char</span>* haystack_expr,</div><div class="line"><a name="l03102"></a><span class="lineno"> 3102</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* needle, <span class="keyword">const</span> <span class="keywordtype">char</span>* haystack) {</div><div class="line"><a name="l03103"></a><span class="lineno"> 3103</span>  <span class="keywordflow">return</span> IsSubstringImpl(<span class="keyword">true</span>, needle_expr, haystack_expr, needle, haystack);</div><div class="line"><a name="l03104"></a><span class="lineno"> 3104</span> }</div><div class="line"><a name="l03105"></a><span class="lineno"> 3105</span> </div><div class="line"><a name="l03106"></a><span class="lineno"> 3106</span> AssertionResult <a class="code" href="namespacetesting.html#a5c90a86562b2470213c07742e0eeb0fe">IsSubstring</a>(</div><div class="line"><a name="l03107"></a><span class="lineno"> 3107</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* needle_expr, <span class="keyword">const</span> <span class="keywordtype">char</span>* haystack_expr,</div><div class="line"><a name="l03108"></a><span class="lineno"> 3108</span>  <span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* needle, <span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* haystack) {</div><div class="line"><a name="l03109"></a><span class="lineno"> 3109</span>  <span class="keywordflow">return</span> IsSubstringImpl(<span class="keyword">true</span>, needle_expr, haystack_expr, needle, haystack);</div><div class="line"><a name="l03110"></a><span class="lineno"> 3110</span> }</div><div class="line"><a name="l03111"></a><span class="lineno"> 3111</span> </div><div class="line"><a name="l03112"></a><span class="lineno"> 3112</span> AssertionResult <a class="code" href="namespacetesting.html#ab553b649b06ef2339cbd90f8dfa119f0">IsNotSubstring</a>(</div><div class="line"><a name="l03113"></a><span class="lineno"> 3113</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* needle_expr, <span class="keyword">const</span> <span class="keywordtype">char</span>* haystack_expr,</div><div class="line"><a name="l03114"></a><span class="lineno"> 3114</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* needle, <span class="keyword">const</span> <span class="keywordtype">char</span>* haystack) {</div><div class="line"><a name="l03115"></a><span class="lineno"> 3115</span>  <span class="keywordflow">return</span> IsSubstringImpl(<span class="keyword">false</span>, needle_expr, haystack_expr, needle, haystack);</div><div class="line"><a name="l03116"></a><span class="lineno"> 3116</span> }</div><div class="line"><a name="l03117"></a><span class="lineno"> 3117</span> </div><div class="line"><a name="l03118"></a><span class="lineno"> 3118</span> AssertionResult <a class="code" href="namespacetesting.html#ab553b649b06ef2339cbd90f8dfa119f0">IsNotSubstring</a>(</div><div class="line"><a name="l03119"></a><span class="lineno"> 3119</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* needle_expr, <span class="keyword">const</span> <span class="keywordtype">char</span>* haystack_expr,</div><div class="line"><a name="l03120"></a><span class="lineno"> 3120</span>  <span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* needle, <span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* haystack) {</div><div class="line"><a name="l03121"></a><span class="lineno"> 3121</span>  <span class="keywordflow">return</span> IsSubstringImpl(<span class="keyword">false</span>, needle_expr, haystack_expr, needle, haystack);</div><div class="line"><a name="l03122"></a><span class="lineno"> 3122</span> }</div><div class="line"><a name="l03123"></a><span class="lineno"> 3123</span> </div><div class="line"><a name="l03124"></a><span class="lineno"> 3124</span> AssertionResult <a class="code" href="namespacetesting.html#a5c90a86562b2470213c07742e0eeb0fe">IsSubstring</a>(</div><div class="line"><a name="l03125"></a><span class="lineno"> 3125</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* needle_expr, <span class="keyword">const</span> <span class="keywordtype">char</span>* haystack_expr,</div><div class="line"><a name="l03126"></a><span class="lineno"> 3126</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">const ::std::string</a>& needle, <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">const ::std::string</a>& haystack) {</div><div class="line"><a name="l03127"></a><span class="lineno"> 3127</span>  <span class="keywordflow">return</span> IsSubstringImpl(<span class="keyword">true</span>, needle_expr, haystack_expr, needle, haystack);</div><div class="line"><a name="l03128"></a><span class="lineno"> 3128</span> }</div><div class="line"><a name="l03129"></a><span class="lineno"> 3129</span> </div><div class="line"><a name="l03130"></a><span class="lineno"> 3130</span> AssertionResult <a class="code" href="namespacetesting.html#ab553b649b06ef2339cbd90f8dfa119f0">IsNotSubstring</a>(</div><div class="line"><a name="l03131"></a><span class="lineno"> 3131</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* needle_expr, <span class="keyword">const</span> <span class="keywordtype">char</span>* haystack_expr,</div><div class="line"><a name="l03132"></a><span class="lineno"> 3132</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">const ::std::string</a>& needle, <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">const ::std::string</a>& haystack) {</div><div class="line"><a name="l03133"></a><span class="lineno"> 3133</span>  <span class="keywordflow">return</span> IsSubstringImpl(<span class="keyword">false</span>, needle_expr, haystack_expr, needle, haystack);</div><div class="line"><a name="l03134"></a><span class="lineno"> 3134</span> }</div><div class="line"><a name="l03135"></a><span class="lineno"> 3135</span> </div><div class="line"><a name="l03136"></a><span class="lineno"> 3136</span> <span class="preprocessor">#if GTEST_HAS_STD_WSTRING</span></div><div class="line"><a name="l03137"></a><span class="lineno"> 3137</span> AssertionResult <a class="code" href="namespacetesting.html#a5c90a86562b2470213c07742e0eeb0fe">IsSubstring</a>(</div><div class="line"><a name="l03138"></a><span class="lineno"> 3138</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* needle_expr, <span class="keyword">const</span> <span class="keywordtype">char</span>* haystack_expr,</div><div class="line"><a name="l03139"></a><span class="lineno"> 3139</span>  <a class="code" href="namespacetesting_1_1internal.html#a3f543179329c353aee1d7b54a9a8e335">const ::std::wstring</a>& needle, <a class="code" href="namespacetesting_1_1internal.html#a3f543179329c353aee1d7b54a9a8e335">const ::std::wstring</a>& haystack) {</div><div class="line"><a name="l03140"></a><span class="lineno"> 3140</span>  <span class="keywordflow">return</span> IsSubstringImpl(<span class="keyword">true</span>, needle_expr, haystack_expr, needle, haystack);</div><div class="line"><a name="l03141"></a><span class="lineno"> 3141</span> }</div><div class="line"><a name="l03142"></a><span class="lineno"> 3142</span> </div><div class="line"><a name="l03143"></a><span class="lineno"> 3143</span> AssertionResult <a class="code" href="namespacetesting.html#ab553b649b06ef2339cbd90f8dfa119f0">IsNotSubstring</a>(</div><div class="line"><a name="l03144"></a><span class="lineno"> 3144</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* needle_expr, <span class="keyword">const</span> <span class="keywordtype">char</span>* haystack_expr,</div><div class="line"><a name="l03145"></a><span class="lineno"> 3145</span>  <a class="code" href="namespacetesting_1_1internal.html#a3f543179329c353aee1d7b54a9a8e335">const ::std::wstring</a>& needle, <a class="code" href="namespacetesting_1_1internal.html#a3f543179329c353aee1d7b54a9a8e335">const ::std::wstring</a>& haystack) {</div><div class="line"><a name="l03146"></a><span class="lineno"> 3146</span>  <span class="keywordflow">return</span> IsSubstringImpl(<span class="keyword">false</span>, needle_expr, haystack_expr, needle, haystack);</div><div class="line"><a name="l03147"></a><span class="lineno"> 3147</span> }</div><div class="line"><a name="l03148"></a><span class="lineno"> 3148</span> <span class="preprocessor">#endif // GTEST_HAS_STD_WSTRING</span></div><div class="line"><a name="l03149"></a><span class="lineno"> 3149</span> </div><div class="line"><a name="l03150"></a><span class="lineno"> 3150</span> <span class="keyword">namespace </span>internal {</div><div class="line"><a name="l03151"></a><span class="lineno"> 3151</span> </div><div class="line"><a name="l03152"></a><span class="lineno"> 3152</span> <span class="preprocessor">#if GTEST_OS_WINDOWS</span></div><div class="line"><a name="l03153"></a><span class="lineno"> 3153</span> </div><div class="line"><a name="l03154"></a><span class="lineno"> 3154</span> <span class="keyword">namespace </span>{</div><div class="line"><a name="l03155"></a><span class="lineno"> 3155</span> </div><div class="line"><a name="l03156"></a><span class="lineno"> 3156</span> <span class="comment">// Helper function for IsHRESULT{SuccessFailure} predicates</span></div><div class="line"><a name="l03157"></a><span class="lineno"> 3157</span> AssertionResult HRESULTFailureHelper(<span class="keyword">const</span> <span class="keywordtype">char</span>* expr,</div><div class="line"><a name="l03158"></a><span class="lineno"> 3158</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* expected,</div><div class="line"><a name="l03159"></a><span class="lineno"> 3159</span>  <span class="keywordtype">long</span> hr) { <span class="comment">// NOLINT</span></div><div class="line"><a name="l03160"></a><span class="lineno"> 3160</span> <span class="preprocessor"># if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_TV_TITLE</span></div><div class="line"><a name="l03161"></a><span class="lineno"> 3161</span> </div><div class="line"><a name="l03162"></a><span class="lineno"> 3162</span>  <span class="comment">// Windows CE doesn't support FormatMessage.</span></div><div class="line"><a name="l03163"></a><span class="lineno"> 3163</span>  <span class="keyword">const</span> <span class="keywordtype">char</span> error_text[] = <span class="stringliteral">""</span>;</div><div class="line"><a name="l03164"></a><span class="lineno"> 3164</span> </div><div class="line"><a name="l03165"></a><span class="lineno"> 3165</span> <span class="preprocessor"># else</span></div><div class="line"><a name="l03166"></a><span class="lineno"> 3166</span> </div><div class="line"><a name="l03167"></a><span class="lineno"> 3167</span>  <span class="comment">// Looks up the human-readable system message for the HRESULT code</span></div><div class="line"><a name="l03168"></a><span class="lineno"> 3168</span>  <span class="comment">// and since we're not passing any params to FormatMessage, we don't</span></div><div class="line"><a name="l03169"></a><span class="lineno"> 3169</span>  <span class="comment">// want inserts expanded.</span></div><div class="line"><a name="l03170"></a><span class="lineno"> 3170</span>  <span class="keyword">const</span> DWORD kFlags = FORMAT_MESSAGE_FROM_SYSTEM |</div><div class="line"><a name="l03171"></a><span class="lineno"> 3171</span>  FORMAT_MESSAGE_IGNORE_INSERTS;</div><div class="line"><a name="l03172"></a><span class="lineno"> 3172</span>  <span class="keyword">const</span> DWORD kBufSize = 4096;</div><div class="line"><a name="l03173"></a><span class="lineno"> 3173</span>  <span class="comment">// Gets the system's human readable message string for this HRESULT.</span></div><div class="line"><a name="l03174"></a><span class="lineno"> 3174</span>  <span class="keywordtype">char</span> error_text[kBufSize] = { <span class="charliteral">'\0'</span> };</div><div class="line"><a name="l03175"></a><span class="lineno"> 3175</span>  DWORD message_length = ::FormatMessageA(kFlags,</div><div class="line"><a name="l03176"></a><span class="lineno"> 3176</span>  0, <span class="comment">// no source, we're asking system</span></div><div class="line"><a name="l03177"></a><span class="lineno"> 3177</span>  hr, <span class="comment">// the error</span></div><div class="line"><a name="l03178"></a><span class="lineno"> 3178</span>  0, <span class="comment">// no line width restrictions</span></div><div class="line"><a name="l03179"></a><span class="lineno"> 3179</span>  error_text, <span class="comment">// output buffer</span></div><div class="line"><a name="l03180"></a><span class="lineno"> 3180</span>  kBufSize, <span class="comment">// buf size</span></div><div class="line"><a name="l03181"></a><span class="lineno"> 3181</span>  <span class="keyword">nullptr</span>); <span class="comment">// no arguments for inserts</span></div><div class="line"><a name="l03182"></a><span class="lineno"> 3182</span>  <span class="comment">// Trims tailing white space (FormatMessage leaves a trailing CR-LF)</span></div><div class="line"><a name="l03183"></a><span class="lineno"> 3183</span>  <span class="keywordflow">for</span> (; message_length && <a class="code" href="namespacetesting_1_1internal.html#af429e04f70f9c10f6aa76a5d1ccd389f">IsSpace</a>(error_text[message_length - 1]);</div><div class="line"><a name="l03184"></a><span class="lineno"> 3184</span>  --message_length) {</div><div class="line"><a name="l03185"></a><span class="lineno"> 3185</span>  error_text[message_length - 1] = <span class="charliteral">'\0'</span>;</div><div class="line"><a name="l03186"></a><span class="lineno"> 3186</span>  }</div><div class="line"><a name="l03187"></a><span class="lineno"> 3187</span> </div><div class="line"><a name="l03188"></a><span class="lineno"> 3188</span> <span class="preprocessor"># endif // GTEST_OS_WINDOWS_MOBILE</span></div><div class="line"><a name="l03189"></a><span class="lineno"> 3189</span> </div><div class="line"><a name="l03190"></a><span class="lineno"> 3190</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> error_hex(<span class="stringliteral">"0x"</span> + String::FormatHexInt(hr));</div><div class="line"><a name="l03191"></a><span class="lineno"> 3191</span>  return ::testing::AssertionFailure()</div><div class="line"><a name="l03192"></a><span class="lineno"> 3192</span>  << <span class="stringliteral">"Expected: "</span> << expr << <span class="stringliteral">" "</span> << expected << <span class="stringliteral">".\n"</span></div><div class="line"><a name="l03193"></a><span class="lineno"> 3193</span>  << <span class="stringliteral">" Actual: "</span> << error_hex << <span class="stringliteral">" "</span> << error_text << <span class="stringliteral">"\n"</span>;</div><div class="line"><a name="l03194"></a><span class="lineno"> 3194</span> }</div><div class="line"><a name="l03195"></a><span class="lineno"> 3195</span> </div><div class="line"><a name="l03196"></a><span class="lineno"> 3196</span> } <span class="comment">// namespace</span></div><div class="line"><a name="l03197"></a><span class="lineno"> 3197</span> </div><div class="line"><a name="l03198"></a><span class="lineno"> 3198</span> AssertionResult IsHRESULTSuccess(<span class="keyword">const</span> <span class="keywordtype">char</span>* expr, <span class="keywordtype">long</span> hr) { <span class="comment">// NOLINT</span></div><div class="line"><a name="l03199"></a><span class="lineno"> 3199</span>  <span class="keywordflow">if</span> (SUCCEEDED(hr)) {</div><div class="line"><a name="l03200"></a><span class="lineno"> 3200</span>  <span class="keywordflow">return</span> AssertionSuccess();</div><div class="line"><a name="l03201"></a><span class="lineno"> 3201</span>  }</div><div class="line"><a name="l03202"></a><span class="lineno"> 3202</span>  <span class="keywordflow">return</span> HRESULTFailureHelper(expr, <span class="stringliteral">"succeeds"</span>, hr);</div><div class="line"><a name="l03203"></a><span class="lineno"> 3203</span> }</div><div class="line"><a name="l03204"></a><span class="lineno"> 3204</span> </div><div class="line"><a name="l03205"></a><span class="lineno"> 3205</span> AssertionResult IsHRESULTFailure(<span class="keyword">const</span> <span class="keywordtype">char</span>* expr, <span class="keywordtype">long</span> hr) { <span class="comment">// NOLINT</span></div><div class="line"><a name="l03206"></a><span class="lineno"> 3206</span>  <span class="keywordflow">if</span> (FAILED(hr)) {</div><div class="line"><a name="l03207"></a><span class="lineno"> 3207</span>  <span class="keywordflow">return</span> AssertionSuccess();</div><div class="line"><a name="l03208"></a><span class="lineno"> 3208</span>  }</div><div class="line"><a name="l03209"></a><span class="lineno"> 3209</span>  <span class="keywordflow">return</span> HRESULTFailureHelper(expr, <span class="stringliteral">"fails"</span>, hr);</div><div class="line"><a name="l03210"></a><span class="lineno"> 3210</span> }</div><div class="line"><a name="l03211"></a><span class="lineno"> 3211</span> </div><div class="line"><a name="l03212"></a><span class="lineno"> 3212</span> <span class="preprocessor">#endif // GTEST_OS_WINDOWS</span></div><div class="line"><a name="l03213"></a><span class="lineno"> 3213</span> </div><div class="line"><a name="l03214"></a><span class="lineno"> 3214</span> <span class="comment">// Utility functions for encoding Unicode text (wide strings) in</span></div><div class="line"><a name="l03215"></a><span class="lineno"> 3215</span> <span class="comment">// UTF-8.</span></div><div class="line"><a name="l03216"></a><span class="lineno"> 3216</span> </div><div class="line"><a name="l03217"></a><span class="lineno"> 3217</span> <span class="comment">// A Unicode code-point can have up to 21 bits, and is encoded in UTF-8</span></div><div class="line"><a name="l03218"></a><span class="lineno"> 3218</span> <span class="comment">// like this:</span></div><div class="line"><a name="l03219"></a><span class="lineno"> 3219</span> <span class="comment">//</span></div><div class="line"><a name="l03220"></a><span class="lineno"> 3220</span> <span class="comment">// Code-point length Encoding</span></div><div class="line"><a name="l03221"></a><span class="lineno"> 3221</span> <span class="comment">// 0 - 7 bits 0xxxxxxx</span></div><div class="line"><a name="l03222"></a><span class="lineno"> 3222</span> <span class="comment">// 8 - 11 bits 110xxxxx 10xxxxxx</span></div><div class="line"><a name="l03223"></a><span class="lineno"> 3223</span> <span class="comment">// 12 - 16 bits 1110xxxx 10xxxxxx 10xxxxxx</span></div><div class="line"><a name="l03224"></a><span class="lineno"> 3224</span> <span class="comment">// 17 - 21 bits 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx</span></div><div class="line"><a name="l03225"></a><span class="lineno"> 3225</span> </div><div class="line"><a name="l03226"></a><span class="lineno"> 3226</span> <span class="comment">// The maximum code-point a one-byte UTF-8 sequence can represent.</span></div><div class="line"><a name="l03227"></a><span class="lineno"> 3227</span> <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a40d4fffcd2bf56f18b1c380615aa85e3">UInt32</a> kMaxCodePoint1 = (<span class="keyword">static_cast<</span><a class="code" href="namespacetesting_1_1internal.html#a40d4fffcd2bf56f18b1c380615aa85e3">UInt32</a><span class="keyword">></span>(1) << 7) - 1;</div><div class="line"><a name="l03228"></a><span class="lineno"> 3228</span> </div><div class="line"><a name="l03229"></a><span class="lineno"> 3229</span> <span class="comment">// The maximum code-point a two-byte UTF-8 sequence can represent.</span></div><div class="line"><a name="l03230"></a><span class="lineno"> 3230</span> <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a40d4fffcd2bf56f18b1c380615aa85e3">UInt32</a> kMaxCodePoint2 = (<span class="keyword">static_cast<</span><a class="code" href="namespacetesting_1_1internal.html#a40d4fffcd2bf56f18b1c380615aa85e3">UInt32</a><span class="keyword">></span>(1) << (5 + 6)) - 1;</div><div class="line"><a name="l03231"></a><span class="lineno"> 3231</span> </div><div class="line"><a name="l03232"></a><span class="lineno"> 3232</span> <span class="comment">// The maximum code-point a three-byte UTF-8 sequence can represent.</span></div><div class="line"><a name="l03233"></a><span class="lineno"> 3233</span> <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a40d4fffcd2bf56f18b1c380615aa85e3">UInt32</a> kMaxCodePoint3 = (<span class="keyword">static_cast<</span><a class="code" href="namespacetesting_1_1internal.html#a40d4fffcd2bf56f18b1c380615aa85e3">UInt32</a><span class="keyword">></span>(1) << (4 + 2*6)) - 1;</div><div class="line"><a name="l03234"></a><span class="lineno"> 3234</span> </div><div class="line"><a name="l03235"></a><span class="lineno"> 3235</span> <span class="comment">// The maximum code-point a four-byte UTF-8 sequence can represent.</span></div><div class="line"><a name="l03236"></a><span class="lineno"> 3236</span> <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a40d4fffcd2bf56f18b1c380615aa85e3">UInt32</a> kMaxCodePoint4 = (<span class="keyword">static_cast<</span><a class="code" href="namespacetesting_1_1internal.html#a40d4fffcd2bf56f18b1c380615aa85e3">UInt32</a><span class="keyword">></span>(1) << (3 + 3*6)) - 1;</div><div class="line"><a name="l03237"></a><span class="lineno"> 3237</span> </div><div class="line"><a name="l03238"></a><span class="lineno"> 3238</span> <span class="comment">// Chops off the n lowest bits from a bit pattern. Returns the n</span></div><div class="line"><a name="l03239"></a><span class="lineno"> 3239</span> <span class="comment">// lowest bits. As a side effect, the original bit pattern will be</span></div><div class="line"><a name="l03240"></a><span class="lineno"> 3240</span> <span class="comment">// shifted to the right by n bits.</span></div><div class="line"><a name="l03241"></a><span class="lineno"> 3241</span> <span class="keyword">inline</span> <a class="code" href="namespacetesting_1_1internal.html#a40d4fffcd2bf56f18b1c380615aa85e3">UInt32</a> ChopLowBits(<a class="code" href="namespacetesting_1_1internal.html#a40d4fffcd2bf56f18b1c380615aa85e3">UInt32</a>* bits, <span class="keywordtype">int</span> n) {</div><div class="line"><a name="l03242"></a><span class="lineno"> 3242</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a40d4fffcd2bf56f18b1c380615aa85e3">UInt32</a> low_bits = *bits & ((<span class="keyword">static_cast<</span><a class="code" href="namespacetesting_1_1internal.html#a40d4fffcd2bf56f18b1c380615aa85e3">UInt32</a><span class="keyword">></span>(1) << n) - 1);</div><div class="line"><a name="l03243"></a><span class="lineno"> 3243</span>  *bits >>= n;</div><div class="line"><a name="l03244"></a><span class="lineno"> 3244</span>  <span class="keywordflow">return</span> low_bits;</div><div class="line"><a name="l03245"></a><span class="lineno"> 3245</span> }</div><div class="line"><a name="l03246"></a><span class="lineno"> 3246</span> </div><div class="line"><a name="l03247"></a><span class="lineno"> 3247</span> <span class="comment">// Converts a Unicode code point to a narrow string in UTF-8 encoding.</span></div><div class="line"><a name="l03248"></a><span class="lineno"> 3248</span> <span class="comment">// code_point parameter is of type UInt32 because wchar_t may not be</span></div><div class="line"><a name="l03249"></a><span class="lineno"> 3249</span> <span class="comment">// wide enough to contain a code point.</span></div><div class="line"><a name="l03250"></a><span class="lineno"> 3250</span> <span class="comment">// If the code_point is not a valid Unicode code point</span></div><div class="line"><a name="l03251"></a><span class="lineno"> 3251</span> <span class="comment">// (i.e. outside of Unicode range U+0 to U+10FFFF) it will be converted</span></div><div class="line"><a name="l03252"></a><span class="lineno"> 3252</span> <span class="comment">// to "(Invalid Unicode 0xXXXXXXXX)".</span></div><div class="line"><a name="l03253"></a><span class="lineno"> 3253</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> CodePointToUtf8(<a class="code" href="namespacetesting_1_1internal.html#a40d4fffcd2bf56f18b1c380615aa85e3">UInt32</a> code_point) {</div><div class="line"><a name="l03254"></a><span class="lineno"> 3254</span>  <span class="keywordflow">if</span> (code_point > kMaxCodePoint4) {</div><div class="line"><a name="l03255"></a><span class="lineno"> 3255</span>  <span class="keywordflow">return</span> <span class="stringliteral">"(Invalid Unicode 0x"</span> + String::FormatHexInt(code_point) + <span class="stringliteral">")"</span>;</div><div class="line"><a name="l03256"></a><span class="lineno"> 3256</span>  }</div><div class="line"><a name="l03257"></a><span class="lineno"> 3257</span> </div><div class="line"><a name="l03258"></a><span class="lineno"> 3258</span>  <span class="keywordtype">char</span> str[5]; <span class="comment">// Big enough for the largest valid code point.</span></div><div class="line"><a name="l03259"></a><span class="lineno"> 3259</span>  <span class="keywordflow">if</span> (code_point <= kMaxCodePoint1) {</div><div class="line"><a name="l03260"></a><span class="lineno"> 3260</span>  str[1] = <span class="charliteral">'\0'</span>;</div><div class="line"><a name="l03261"></a><span class="lineno"> 3261</span>  str[0] = <span class="keyword">static_cast<</span><span class="keywordtype">char</span><span class="keyword">></span>(code_point); <span class="comment">// 0xxxxxxx</span></div><div class="line"><a name="l03262"></a><span class="lineno"> 3262</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (code_point <= kMaxCodePoint2) {</div><div class="line"><a name="l03263"></a><span class="lineno"> 3263</span>  str[2] = <span class="charliteral">'\0'</span>;</div><div class="line"><a name="l03264"></a><span class="lineno"> 3264</span>  str[1] = <span class="keyword">static_cast<</span><span class="keywordtype">char</span><span class="keyword">></span>(0x80 | ChopLowBits(&code_point, 6)); <span class="comment">// 10xxxxxx</span></div><div class="line"><a name="l03265"></a><span class="lineno"> 3265</span>  str[0] = <span class="keyword">static_cast<</span><span class="keywordtype">char</span><span class="keyword">></span>(0xC0 | code_point); <span class="comment">// 110xxxxx</span></div><div class="line"><a name="l03266"></a><span class="lineno"> 3266</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (code_point <= kMaxCodePoint3) {</div><div class="line"><a name="l03267"></a><span class="lineno"> 3267</span>  str[3] = <span class="charliteral">'\0'</span>;</div><div class="line"><a name="l03268"></a><span class="lineno"> 3268</span>  str[2] = <span class="keyword">static_cast<</span><span class="keywordtype">char</span><span class="keyword">></span>(0x80 | ChopLowBits(&code_point, 6)); <span class="comment">// 10xxxxxx</span></div><div class="line"><a name="l03269"></a><span class="lineno"> 3269</span>  str[1] = <span class="keyword">static_cast<</span><span class="keywordtype">char</span><span class="keyword">></span>(0x80 | ChopLowBits(&code_point, 6)); <span class="comment">// 10xxxxxx</span></div><div class="line"><a name="l03270"></a><span class="lineno"> 3270</span>  str[0] = <span class="keyword">static_cast<</span><span class="keywordtype">char</span><span class="keyword">></span>(0xE0 | code_point); <span class="comment">// 1110xxxx</span></div><div class="line"><a name="l03271"></a><span class="lineno"> 3271</span>  } <span class="keywordflow">else</span> { <span class="comment">// code_point <= kMaxCodePoint4</span></div><div class="line"><a name="l03272"></a><span class="lineno"> 3272</span>  str[4] = <span class="charliteral">'\0'</span>;</div><div class="line"><a name="l03273"></a><span class="lineno"> 3273</span>  str[3] = <span class="keyword">static_cast<</span><span class="keywordtype">char</span><span class="keyword">></span>(0x80 | ChopLowBits(&code_point, 6)); <span class="comment">// 10xxxxxx</span></div><div class="line"><a name="l03274"></a><span class="lineno"> 3274</span>  str[2] = <span class="keyword">static_cast<</span><span class="keywordtype">char</span><span class="keyword">></span>(0x80 | ChopLowBits(&code_point, 6)); <span class="comment">// 10xxxxxx</span></div><div class="line"><a name="l03275"></a><span class="lineno"> 3275</span>  str[1] = <span class="keyword">static_cast<</span><span class="keywordtype">char</span><span class="keyword">></span>(0x80 | ChopLowBits(&code_point, 6)); <span class="comment">// 10xxxxxx</span></div><div class="line"><a name="l03276"></a><span class="lineno"> 3276</span>  str[0] = <span class="keyword">static_cast<</span><span class="keywordtype">char</span><span class="keyword">></span>(0xF0 | code_point); <span class="comment">// 11110xxx</span></div><div class="line"><a name="l03277"></a><span class="lineno"> 3277</span>  }</div><div class="line"><a name="l03278"></a><span class="lineno"> 3278</span>  <span class="keywordflow">return</span> str;</div><div class="line"><a name="l03279"></a><span class="lineno"> 3279</span> }</div><div class="line"><a name="l03280"></a><span class="lineno"> 3280</span> </div><div class="line"><a name="l03281"></a><span class="lineno"> 3281</span> <span class="comment">// The following two functions only make sense if the system</span></div><div class="line"><a name="l03282"></a><span class="lineno"> 3282</span> <span class="comment">// uses UTF-16 for wide string encoding. All supported systems</span></div><div class="line"><a name="l03283"></a><span class="lineno"> 3283</span> <span class="comment">// with 16 bit wchar_t (Windows, Cygwin) do use UTF-16.</span></div><div class="line"><a name="l03284"></a><span class="lineno"> 3284</span> </div><div class="line"><a name="l03285"></a><span class="lineno"> 3285</span> <span class="comment">// Determines if the arguments constitute UTF-16 surrogate pair</span></div><div class="line"><a name="l03286"></a><span class="lineno"> 3286</span> <span class="comment">// and thus should be combined into a single Unicode code point</span></div><div class="line"><a name="l03287"></a><span class="lineno"> 3287</span> <span class="comment">// using CreateCodePointFromUtf16SurrogatePair.</span></div><div class="line"><a name="l03288"></a><span class="lineno"> 3288</span> <span class="keyword">inline</span> <span class="keywordtype">bool</span> IsUtf16SurrogatePair(<span class="keywordtype">wchar_t</span> first, <span class="keywordtype">wchar_t</span> second) {</div><div class="line"><a name="l03289"></a><span class="lineno"> 3289</span>  <span class="keywordflow">return</span> <span class="keyword">sizeof</span>(wchar_t) == 2 &&</div><div class="line"><a name="l03290"></a><span class="lineno"> 3290</span>  (first & 0xFC00) == 0xD800 && (second & 0xFC00) == 0xDC00;</div><div class="line"><a name="l03291"></a><span class="lineno"> 3291</span> }</div><div class="line"><a name="l03292"></a><span class="lineno"> 3292</span> </div><div class="line"><a name="l03293"></a><span class="lineno"> 3293</span> <span class="comment">// Creates a Unicode code point from UTF16 surrogate pair.</span></div><div class="line"><a name="l03294"></a><span class="lineno"> 3294</span> <span class="keyword">inline</span> <a class="code" href="namespacetesting_1_1internal.html#a40d4fffcd2bf56f18b1c380615aa85e3">UInt32</a> CreateCodePointFromUtf16SurrogatePair(<span class="keywordtype">wchar_t</span> first,</div><div class="line"><a name="l03295"></a><span class="lineno"> 3295</span>  <span class="keywordtype">wchar_t</span> second) {</div><div class="line"><a name="l03296"></a><span class="lineno"> 3296</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a40d4fffcd2bf56f18b1c380615aa85e3">UInt32</a> mask = (1 << 10) - 1;</div><div class="line"><a name="l03297"></a><span class="lineno"> 3297</span>  <span class="keywordflow">return</span> (<span class="keyword">sizeof</span>(<span class="keywordtype">wchar_t</span>) == 2) ?</div><div class="line"><a name="l03298"></a><span class="lineno"> 3298</span>  (((first & mask) << 10) | (second & mask)) + 0x10000 :</div><div class="line"><a name="l03299"></a><span class="lineno"> 3299</span>  <span class="comment">// This function should not be called when the condition is</span></div><div class="line"><a name="l03300"></a><span class="lineno"> 3300</span>  <span class="comment">// false, but we provide a sensible default in case it is.</span></div><div class="line"><a name="l03301"></a><span class="lineno"> 3301</span>  <span class="keyword">static_cast<</span><a class="code" href="namespacetesting_1_1internal.html#a40d4fffcd2bf56f18b1c380615aa85e3">UInt32</a><span class="keyword">></span>(first);</div><div class="line"><a name="l03302"></a><span class="lineno"> 3302</span> }</div><div class="line"><a name="l03303"></a><span class="lineno"> 3303</span> </div><div class="line"><a name="l03304"></a><span class="lineno"> 3304</span> <span class="comment">// Converts a wide string to a narrow string in UTF-8 encoding.</span></div><div class="line"><a name="l03305"></a><span class="lineno"> 3305</span> <span class="comment">// The wide string is assumed to have the following encoding:</span></div><div class="line"><a name="l03306"></a><span class="lineno"> 3306</span> <span class="comment">// UTF-16 if sizeof(wchar_t) == 2 (on Windows, Cygwin)</span></div><div class="line"><a name="l03307"></a><span class="lineno"> 3307</span> <span class="comment">// UTF-32 if sizeof(wchar_t) == 4 (on Linux)</span></div><div class="line"><a name="l03308"></a><span class="lineno"> 3308</span> <span class="comment">// Parameter str points to a null-terminated wide string.</span></div><div class="line"><a name="l03309"></a><span class="lineno"> 3309</span> <span class="comment">// Parameter num_chars may additionally limit the number</span></div><div class="line"><a name="l03310"></a><span class="lineno"> 3310</span> <span class="comment">// of wchar_t characters processed. -1 is used when the entire string</span></div><div class="line"><a name="l03311"></a><span class="lineno"> 3311</span> <span class="comment">// should be processed.</span></div><div class="line"><a name="l03312"></a><span class="lineno"> 3312</span> <span class="comment">// If the string contains code points that are not valid Unicode code points</span></div><div class="line"><a name="l03313"></a><span class="lineno"> 3313</span> <span class="comment">// (i.e. outside of Unicode range U+0 to U+10FFFF) they will be output</span></div><div class="line"><a name="l03314"></a><span class="lineno"> 3314</span> <span class="comment">// as '(Invalid Unicode 0xXXXXXXXX)'. If the string is in UTF16 encoding</span></div><div class="line"><a name="l03315"></a><span class="lineno"> 3315</span> <span class="comment">// and contains invalid UTF-16 surrogate pairs, values in those pairs</span></div><div class="line"><a name="l03316"></a><span class="lineno"> 3316</span> <span class="comment">// will be encoded as individual Unicode characters from Basic Normal Plane.</span></div><div class="line"><a name="l03317"></a><span class="lineno"> 3317</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> WideStringToUtf8(<span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* str, <span class="keywordtype">int</span> num_chars) {</div><div class="line"><a name="l03318"></a><span class="lineno"> 3318</span>  <span class="keywordflow">if</span> (num_chars == -1)</div><div class="line"><a name="l03319"></a><span class="lineno"> 3319</span>  num_chars = <span class="keyword">static_cast<</span><span class="keywordtype">int</span><span class="keyword">></span>(wcslen(str));</div><div class="line"><a name="l03320"></a><span class="lineno"> 3320</span> </div><div class="line"><a name="l03321"></a><span class="lineno"> 3321</span>  ::std::stringstream stream;</div><div class="line"><a name="l03322"></a><span class="lineno"> 3322</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < num_chars; ++i) {</div><div class="line"><a name="l03323"></a><span class="lineno"> 3323</span>  <a class="code" href="namespacetesting_1_1internal.html#a40d4fffcd2bf56f18b1c380615aa85e3">UInt32</a> unicode_code_point;</div><div class="line"><a name="l03324"></a><span class="lineno"> 3324</span> </div><div class="line"><a name="l03325"></a><span class="lineno"> 3325</span>  <span class="keywordflow">if</span> (str[i] == L<span class="charliteral">'\0'</span>) {</div><div class="line"><a name="l03326"></a><span class="lineno"> 3326</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l03327"></a><span class="lineno"> 3327</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (i + 1 < num_chars && IsUtf16SurrogatePair(str[i], str[i + 1])) {</div><div class="line"><a name="l03328"></a><span class="lineno"> 3328</span>  unicode_code_point = CreateCodePointFromUtf16SurrogatePair(str[i],</div><div class="line"><a name="l03329"></a><span class="lineno"> 3329</span>  str[i + 1]);</div><div class="line"><a name="l03330"></a><span class="lineno"> 3330</span>  i++;</div><div class="line"><a name="l03331"></a><span class="lineno"> 3331</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l03332"></a><span class="lineno"> 3332</span>  unicode_code_point = <span class="keyword">static_cast<</span><a class="code" href="namespacetesting_1_1internal.html#a40d4fffcd2bf56f18b1c380615aa85e3">UInt32</a><span class="keyword">></span>(str[i]);</div><div class="line"><a name="l03333"></a><span class="lineno"> 3333</span>  }</div><div class="line"><a name="l03334"></a><span class="lineno"> 3334</span> </div><div class="line"><a name="l03335"></a><span class="lineno"> 3335</span>  stream << CodePointToUtf8(unicode_code_point);</div><div class="line"><a name="l03336"></a><span class="lineno"> 3336</span>  }</div><div class="line"><a name="l03337"></a><span class="lineno"> 3337</span>  <span class="keywordflow">return</span> StringStreamToString(&stream);</div><div class="line"><a name="l03338"></a><span class="lineno"> 3338</span> }</div><div class="line"><a name="l03339"></a><span class="lineno"> 3339</span> </div><div class="line"><a name="l03340"></a><span class="lineno"> 3340</span> <span class="comment">// Converts a wide C string to an std::string using the UTF-8 encoding.</span></div><div class="line"><a name="l03341"></a><span class="lineno"> 3341</span> <span class="comment">// NULL will be converted to "(null)".</span></div><div class="line"><a name="l03342"></a><span class="lineno"> 3342</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> String::ShowWideCString(<span class="keyword">const</span> <span class="keywordtype">wchar_t</span> * wide_c_str) {</div><div class="line"><a name="l03343"></a><span class="lineno"> 3343</span>  <span class="keywordflow">if</span> (wide_c_str == <span class="keyword">nullptr</span>) <span class="keywordflow">return</span> <span class="stringliteral">"(null)"</span>;</div><div class="line"><a name="l03344"></a><span class="lineno"> 3344</span> </div><div class="line"><a name="l03345"></a><span class="lineno"> 3345</span>  <span class="keywordflow">return</span> internal::WideStringToUtf8(wide_c_str, -1);</div><div class="line"><a name="l03346"></a><span class="lineno"> 3346</span> }</div><div class="line"><a name="l03347"></a><span class="lineno"> 3347</span> </div><div class="line"><a name="l03348"></a><span class="lineno"> 3348</span> <span class="comment">// Compares two wide C strings. Returns true iff they have the same</span></div><div class="line"><a name="l03349"></a><span class="lineno"> 3349</span> <span class="comment">// content.</span></div><div class="line"><a name="l03350"></a><span class="lineno"> 3350</span> <span class="comment">//</span></div><div class="line"><a name="l03351"></a><span class="lineno"> 3351</span> <span class="comment">// Unlike wcscmp(), this function can handle NULL argument(s). A NULL</span></div><div class="line"><a name="l03352"></a><span class="lineno"> 3352</span> <span class="comment">// C string is considered different to any non-NULL C string,</span></div><div class="line"><a name="l03353"></a><span class="lineno"> 3353</span> <span class="comment">// including the empty string.</span></div><div class="line"><a name="l03354"></a><span class="lineno"> 3354</span> <span class="keywordtype">bool</span> String::WideCStringEquals(<span class="keyword">const</span> <span class="keywordtype">wchar_t</span> * lhs, <span class="keyword">const</span> <span class="keywordtype">wchar_t</span> * rhs) {</div><div class="line"><a name="l03355"></a><span class="lineno"> 3355</span>  <span class="keywordflow">if</span> (lhs == <span class="keyword">nullptr</span>) <span class="keywordflow">return</span> rhs == <span class="keyword">nullptr</span>;</div><div class="line"><a name="l03356"></a><span class="lineno"> 3356</span> </div><div class="line"><a name="l03357"></a><span class="lineno"> 3357</span>  <span class="keywordflow">if</span> (rhs == <span class="keyword">nullptr</span>) <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l03358"></a><span class="lineno"> 3358</span> </div><div class="line"><a name="l03359"></a><span class="lineno"> 3359</span>  <span class="keywordflow">return</span> wcscmp(lhs, rhs) == 0;</div><div class="line"><a name="l03360"></a><span class="lineno"> 3360</span> }</div><div class="line"><a name="l03361"></a><span class="lineno"> 3361</span> </div><div class="line"><a name="l03362"></a><span class="lineno"> 3362</span> <span class="comment">// Helper function for *_STREQ on wide strings.</span></div><div class="line"><a name="l03363"></a><span class="lineno"> 3363</span> AssertionResult <a class="code" href="namespacetesting_1_1internal.html#a93eb9d61cac7faf1faff6301ae5f4a46">CmpHelperSTREQ</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* lhs_expression,</div><div class="line"><a name="l03364"></a><span class="lineno"> 3364</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* rhs_expression,</div><div class="line"><a name="l03365"></a><span class="lineno"> 3365</span>  <span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* lhs,</div><div class="line"><a name="l03366"></a><span class="lineno"> 3366</span>  <span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* rhs) {</div><div class="line"><a name="l03367"></a><span class="lineno"> 3367</span>  <span class="keywordflow">if</span> (String::WideCStringEquals(lhs, rhs)) {</div><div class="line"><a name="l03368"></a><span class="lineno"> 3368</span>  <span class="keywordflow">return</span> AssertionSuccess();</div><div class="line"><a name="l03369"></a><span class="lineno"> 3369</span>  }</div><div class="line"><a name="l03370"></a><span class="lineno"> 3370</span> </div><div class="line"><a name="l03371"></a><span class="lineno"> 3371</span>  <span class="keywordflow">return</span> <a class="code" href="namespacetesting_1_1internal.html#ac61e2ba2cbf259fd6ee5ffd4e49c9445">EqFailure</a>(lhs_expression,</div><div class="line"><a name="l03372"></a><span class="lineno"> 3372</span>  rhs_expression,</div><div class="line"><a name="l03373"></a><span class="lineno"> 3373</span>  <a class="code" href="namespacetesting.html#aa5717bb1144edd1d262d310ba70c82ed">PrintToString</a>(lhs),</div><div class="line"><a name="l03374"></a><span class="lineno"> 3374</span>  <a class="code" href="namespacetesting.html#aa5717bb1144edd1d262d310ba70c82ed">PrintToString</a>(rhs),</div><div class="line"><a name="l03375"></a><span class="lineno"> 3375</span>  <span class="keyword">false</span>);</div><div class="line"><a name="l03376"></a><span class="lineno"> 3376</span> }</div><div class="line"><a name="l03377"></a><span class="lineno"> 3377</span> </div><div class="line"><a name="l03378"></a><span class="lineno"> 3378</span> <span class="comment">// Helper function for *_STRNE on wide strings.</span></div><div class="line"><a name="l03379"></a><span class="lineno"> 3379</span> AssertionResult <a class="code" href="namespacetesting_1_1internal.html#a6b485231a046ff760844a0321c04870b">CmpHelperSTRNE</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* s1_expression,</div><div class="line"><a name="l03380"></a><span class="lineno"> 3380</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* s2_expression,</div><div class="line"><a name="l03381"></a><span class="lineno"> 3381</span>  <span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* s1,</div><div class="line"><a name="l03382"></a><span class="lineno"> 3382</span>  <span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* s2) {</div><div class="line"><a name="l03383"></a><span class="lineno"> 3383</span>  <span class="keywordflow">if</span> (!String::WideCStringEquals(s1, s2)) {</div><div class="line"><a name="l03384"></a><span class="lineno"> 3384</span>  <span class="keywordflow">return</span> AssertionSuccess();</div><div class="line"><a name="l03385"></a><span class="lineno"> 3385</span>  }</div><div class="line"><a name="l03386"></a><span class="lineno"> 3386</span> </div><div class="line"><a name="l03387"></a><span class="lineno"> 3387</span>  <span class="keywordflow">return</span> AssertionFailure() << <span class="stringliteral">"Expected: ("</span> << s1_expression << <span class="stringliteral">") != ("</span></div><div class="line"><a name="l03388"></a><span class="lineno"> 3388</span>  << s2_expression << <span class="stringliteral">"), actual: "</span></div><div class="line"><a name="l03389"></a><span class="lineno"> 3389</span>  << <a class="code" href="namespacetesting.html#aa5717bb1144edd1d262d310ba70c82ed">PrintToString</a>(s1)</div><div class="line"><a name="l03390"></a><span class="lineno"> 3390</span>  << <span class="stringliteral">" vs "</span> << <a class="code" href="namespacetesting.html#aa5717bb1144edd1d262d310ba70c82ed">PrintToString</a>(s2);</div><div class="line"><a name="l03391"></a><span class="lineno"> 3391</span> }</div><div class="line"><a name="l03392"></a><span class="lineno"> 3392</span> </div><div class="line"><a name="l03393"></a><span class="lineno"> 3393</span> <span class="comment">// Compares two C strings, ignoring case. Returns true iff they have</span></div><div class="line"><a name="l03394"></a><span class="lineno"> 3394</span> <span class="comment">// the same content.</span></div><div class="line"><a name="l03395"></a><span class="lineno"> 3395</span> <span class="comment">//</span></div><div class="line"><a name="l03396"></a><span class="lineno"> 3396</span> <span class="comment">// Unlike strcasecmp(), this function can handle NULL argument(s). A</span></div><div class="line"><a name="l03397"></a><span class="lineno"> 3397</span> <span class="comment">// NULL C string is considered different to any non-NULL C string,</span></div><div class="line"><a name="l03398"></a><span class="lineno"> 3398</span> <span class="comment">// including the empty string.</span></div><div class="line"><a name="l03399"></a><span class="lineno"> 3399</span> <span class="keywordtype">bool</span> String::CaseInsensitiveCStringEquals(<span class="keyword">const</span> <span class="keywordtype">char</span> * lhs, <span class="keyword">const</span> <span class="keywordtype">char</span> * rhs) {</div><div class="line"><a name="l03400"></a><span class="lineno"> 3400</span>  <span class="keywordflow">if</span> (lhs == <span class="keyword">nullptr</span>) <span class="keywordflow">return</span> rhs == <span class="keyword">nullptr</span>;</div><div class="line"><a name="l03401"></a><span class="lineno"> 3401</span>  <span class="keywordflow">if</span> (rhs == <span class="keyword">nullptr</span>) <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l03402"></a><span class="lineno"> 3402</span>  <span class="keywordflow">return</span> <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a1ef2385a7f8e4c706054da35967e76bd">posix::StrCaseCmp</a>(lhs, rhs) == 0;</div><div class="line"><a name="l03403"></a><span class="lineno"> 3403</span> }</div><div class="line"><a name="l03404"></a><span class="lineno"> 3404</span> </div><div class="line"><a name="l03405"></a><span class="lineno"> 3405</span>  <span class="comment">// Compares two wide C strings, ignoring case. Returns true iff they</span></div><div class="line"><a name="l03406"></a><span class="lineno"> 3406</span>  <span class="comment">// have the same content.</span></div><div class="line"><a name="l03407"></a><span class="lineno"> 3407</span>  <span class="comment">//</span></div><div class="line"><a name="l03408"></a><span class="lineno"> 3408</span>  <span class="comment">// Unlike wcscasecmp(), this function can handle NULL argument(s).</span></div><div class="line"><a name="l03409"></a><span class="lineno"> 3409</span>  <span class="comment">// A NULL C string is considered different to any non-NULL wide C string,</span></div><div class="line"><a name="l03410"></a><span class="lineno"> 3410</span>  <span class="comment">// including the empty string.</span></div><div class="line"><a name="l03411"></a><span class="lineno"> 3411</span>  <span class="comment">// NB: The implementations on different platforms slightly differ.</span></div><div class="line"><a name="l03412"></a><span class="lineno"> 3412</span>  <span class="comment">// On windows, this method uses _wcsicmp which compares according to LC_CTYPE</span></div><div class="line"><a name="l03413"></a><span class="lineno"> 3413</span>  <span class="comment">// environment variable. On GNU platform this method uses wcscasecmp</span></div><div class="line"><a name="l03414"></a><span class="lineno"> 3414</span>  <span class="comment">// which compares according to LC_CTYPE category of the current locale.</span></div><div class="line"><a name="l03415"></a><span class="lineno"> 3415</span>  <span class="comment">// On MacOS X, it uses towlower, which also uses LC_CTYPE category of the</span></div><div class="line"><a name="l03416"></a><span class="lineno"> 3416</span>  <span class="comment">// current locale.</span></div><div class="line"><a name="l03417"></a><span class="lineno"> 3417</span> <span class="keywordtype">bool</span> String::CaseInsensitiveWideCStringEquals(<span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* lhs,</div><div class="line"><a name="l03418"></a><span class="lineno"> 3418</span>  <span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* rhs) {</div><div class="line"><a name="l03419"></a><span class="lineno"> 3419</span>  <span class="keywordflow">if</span> (lhs == <span class="keyword">nullptr</span>) <span class="keywordflow">return</span> rhs == <span class="keyword">nullptr</span>;</div><div class="line"><a name="l03420"></a><span class="lineno"> 3420</span> </div><div class="line"><a name="l03421"></a><span class="lineno"> 3421</span>  <span class="keywordflow">if</span> (rhs == <span class="keyword">nullptr</span>) <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l03422"></a><span class="lineno"> 3422</span> </div><div class="line"><a name="l03423"></a><span class="lineno"> 3423</span> <span class="preprocessor">#if GTEST_OS_WINDOWS</span></div><div class="line"><a name="l03424"></a><span class="lineno"> 3424</span>  <span class="keywordflow">return</span> _wcsicmp(lhs, rhs) == 0;</div><div class="line"><a name="l03425"></a><span class="lineno"> 3425</span> <span class="preprocessor">#elif GTEST_OS_LINUX && !GTEST_OS_LINUX_ANDROID</span></div><div class="line"><a name="l03426"></a><span class="lineno"> 3426</span>  <span class="keywordflow">return</span> wcscasecmp(lhs, rhs) == 0;</div><div class="line"><a name="l03427"></a><span class="lineno"> 3427</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l03428"></a><span class="lineno"> 3428</span>  <span class="comment">// Android, Mac OS X and Cygwin don't define wcscasecmp.</span></div><div class="line"><a name="l03429"></a><span class="lineno"> 3429</span>  <span class="comment">// Other unknown OSes may not define it either.</span></div><div class="line"><a name="l03430"></a><span class="lineno"> 3430</span>  wint_t left, right;</div><div class="line"><a name="l03431"></a><span class="lineno"> 3431</span>  <span class="keywordflow">do</span> {</div><div class="line"><a name="l03432"></a><span class="lineno"> 3432</span>  left = towlower(*lhs++);</div><div class="line"><a name="l03433"></a><span class="lineno"> 3433</span>  right = towlower(*rhs++);</div><div class="line"><a name="l03434"></a><span class="lineno"> 3434</span>  } <span class="keywordflow">while</span> (left && left == right);</div><div class="line"><a name="l03435"></a><span class="lineno"> 3435</span>  <span class="keywordflow">return</span> left == right;</div><div class="line"><a name="l03436"></a><span class="lineno"> 3436</span> <span class="preprocessor">#endif // OS selector</span></div><div class="line"><a name="l03437"></a><span class="lineno"> 3437</span> }</div><div class="line"><a name="l03438"></a><span class="lineno"> 3438</span> </div><div class="line"><a name="l03439"></a><span class="lineno"> 3439</span> <span class="comment">// Returns true iff str ends with the given suffix, ignoring case.</span></div><div class="line"><a name="l03440"></a><span class="lineno"> 3440</span> <span class="comment">// Any string is considered to end with an empty suffix.</span></div><div class="line"><a name="l03441"></a><span class="lineno"> 3441</span> <span class="keywordtype">bool</span> String::EndsWithCaseInsensitive(</div><div class="line"><a name="l03442"></a><span class="lineno"> 3442</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& str, <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& suffix) {</div><div class="line"><a name="l03443"></a><span class="lineno"> 3443</span>  <span class="keyword">const</span> <span class="keywordtype">size_t</span> str_len = str.length();</div><div class="line"><a name="l03444"></a><span class="lineno"> 3444</span>  <span class="keyword">const</span> <span class="keywordtype">size_t</span> suffix_len = suffix.length();</div><div class="line"><a name="l03445"></a><span class="lineno"> 3445</span>  <span class="keywordflow">return</span> (str_len >= suffix_len) &&</div><div class="line"><a name="l03446"></a><span class="lineno"> 3446</span>  CaseInsensitiveCStringEquals(str.c_str() + str_len - suffix_len,</div><div class="line"><a name="l03447"></a><span class="lineno"> 3447</span>  suffix.c_str());</div><div class="line"><a name="l03448"></a><span class="lineno"> 3448</span> }</div><div class="line"><a name="l03449"></a><span class="lineno"> 3449</span> </div><div class="line"><a name="l03450"></a><span class="lineno"> 3450</span> <span class="comment">// Formats an int value as "%02d".</span></div><div class="line"><a name="l03451"></a><span class="lineno"> 3451</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> String::FormatIntWidth2(<span class="keywordtype">int</span> value) {</div><div class="line"><a name="l03452"></a><span class="lineno"> 3452</span>  std::stringstream ss;</div><div class="line"><a name="l03453"></a><span class="lineno"> 3453</span>  ss << std::setfill(<span class="charliteral">'0'</span>) << std::setw(2) << value;</div><div class="line"><a name="l03454"></a><span class="lineno"> 3454</span>  <span class="keywordflow">return</span> ss.str();</div><div class="line"><a name="l03455"></a><span class="lineno"> 3455</span> }</div><div class="line"><a name="l03456"></a><span class="lineno"> 3456</span> </div><div class="line"><a name="l03457"></a><span class="lineno"> 3457</span> <span class="comment">// Formats an int value as "%X".</span></div><div class="line"><a name="l03458"></a><span class="lineno"> 3458</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> String::FormatHexInt(<span class="keywordtype">int</span> value) {</div><div class="line"><a name="l03459"></a><span class="lineno"> 3459</span>  std::stringstream ss;</div><div class="line"><a name="l03460"></a><span class="lineno"> 3460</span>  ss << std::hex << std::uppercase << value;</div><div class="line"><a name="l03461"></a><span class="lineno"> 3461</span>  <span class="keywordflow">return</span> ss.str();</div><div class="line"><a name="l03462"></a><span class="lineno"> 3462</span> }</div><div class="line"><a name="l03463"></a><span class="lineno"> 3463</span> </div><div class="line"><a name="l03464"></a><span class="lineno"> 3464</span> <span class="comment">// Formats a byte as "%02X".</span></div><div class="line"><a name="l03465"></a><span class="lineno"> 3465</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> String::FormatByte(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> value) {</div><div class="line"><a name="l03466"></a><span class="lineno"> 3466</span>  std::stringstream ss;</div><div class="line"><a name="l03467"></a><span class="lineno"> 3467</span>  ss << std::setfill(<span class="charliteral">'0'</span>) << std::setw(2) << std::hex << std::uppercase</div><div class="line"><a name="l03468"></a><span class="lineno"> 3468</span>  << <span class="keyword">static_cast<</span><span class="keywordtype">unsigned</span> <span class="keywordtype">int</span><span class="keyword">></span>(value);</div><div class="line"><a name="l03469"></a><span class="lineno"> 3469</span>  <span class="keywordflow">return</span> ss.str();</div><div class="line"><a name="l03470"></a><span class="lineno"> 3470</span> }</div><div class="line"><a name="l03471"></a><span class="lineno"> 3471</span> </div><div class="line"><a name="l03472"></a><span class="lineno"> 3472</span> <span class="comment">// Converts the buffer in a stringstream to an std::string, converting NUL</span></div><div class="line"><a name="l03473"></a><span class="lineno"> 3473</span> <span class="comment">// bytes to "\\0" along the way.</span></div><div class="line"><a name="l03474"></a><span class="lineno"> 3474</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> StringStreamToString(::std::stringstream* ss) {</div><div class="line"><a name="l03475"></a><span class="lineno"> 3475</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">const ::std::string</a>& str = ss->str();</div><div class="line"><a name="l03476"></a><span class="lineno"> 3476</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> start = str.c_str();</div><div class="line"><a name="l03477"></a><span class="lineno"> 3477</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> end = start + str.length();</div><div class="line"><a name="l03478"></a><span class="lineno"> 3478</span> </div><div class="line"><a name="l03479"></a><span class="lineno"> 3479</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> result;</div><div class="line"><a name="l03480"></a><span class="lineno"> 3480</span>  result.reserve(2 * (end - start));</div><div class="line"><a name="l03481"></a><span class="lineno"> 3481</span>  <span class="keywordflow">for</span> (<span class="keyword">const</span> <span class="keywordtype">char</span>* ch = start; ch != end; ++ch) {</div><div class="line"><a name="l03482"></a><span class="lineno"> 3482</span>  <span class="keywordflow">if</span> (*ch == <span class="charliteral">'\0'</span>) {</div><div class="line"><a name="l03483"></a><span class="lineno"> 3483</span>  result += <span class="stringliteral">"\\0"</span>; <span class="comment">// Replaces NUL with "\\0";</span></div><div class="line"><a name="l03484"></a><span class="lineno"> 3484</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l03485"></a><span class="lineno"> 3485</span>  result += *ch;</div><div class="line"><a name="l03486"></a><span class="lineno"> 3486</span>  }</div><div class="line"><a name="l03487"></a><span class="lineno"> 3487</span>  }</div><div class="line"><a name="l03488"></a><span class="lineno"> 3488</span> </div><div class="line"><a name="l03489"></a><span class="lineno"> 3489</span>  <span class="keywordflow">return</span> result;</div><div class="line"><a name="l03490"></a><span class="lineno"> 3490</span> }</div><div class="line"><a name="l03491"></a><span class="lineno"> 3491</span> </div><div class="line"><a name="l03492"></a><span class="lineno"> 3492</span> <span class="comment">// Appends the user-supplied message to the Google-Test-generated message.</span></div><div class="line"><a name="l03493"></a><span class="lineno"> 3493</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> <a class="code" href="namespacetesting_1_1internal.html#af69e146a989e8d48def39a0cc59461c9">AppendUserMessage</a>(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& gtest_msg,</div><div class="line"><a name="l03494"></a><span class="lineno"> 3494</span>  <span class="keyword">const</span> Message& user_msg) {</div><div class="line"><a name="l03495"></a><span class="lineno"> 3495</span>  <span class="comment">// Appends the user message if it's non-empty.</span></div><div class="line"><a name="l03496"></a><span class="lineno"> 3496</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> user_msg_string = user_msg.GetString();</div><div class="line"><a name="l03497"></a><span class="lineno"> 3497</span>  <span class="keywordflow">if</span> (user_msg_string.empty()) {</div><div class="line"><a name="l03498"></a><span class="lineno"> 3498</span>  <span class="keywordflow">return</span> gtest_msg;</div><div class="line"><a name="l03499"></a><span class="lineno"> 3499</span>  }</div><div class="line"><a name="l03500"></a><span class="lineno"> 3500</span> </div><div class="line"><a name="l03501"></a><span class="lineno"> 3501</span>  <span class="keywordflow">return</span> gtest_msg + <span class="stringliteral">"\n"</span> + user_msg_string;</div><div class="line"><a name="l03502"></a><span class="lineno"> 3502</span> }</div><div class="line"><a name="l03503"></a><span class="lineno"> 3503</span> </div><div class="line"><a name="l03504"></a><span class="lineno"> 3504</span> } <span class="comment">// namespace internal</span></div><div class="line"><a name="l03505"></a><span class="lineno"> 3505</span> </div><div class="line"><a name="l03506"></a><span class="lineno"> 3506</span> <span class="comment">// class TestResult</span></div><div class="line"><a name="l03507"></a><span class="lineno"> 3507</span> </div><div class="line"><a name="l03508"></a><span class="lineno"> 3508</span> <span class="comment">// Creates an empty TestResult.</span></div><div class="line"><a name="l03509"></a><span class="lineno"> 3509</span> TestResult::TestResult()</div><div class="line"><a name="l03510"></a><span class="lineno"> 3510</span>  : death_test_count_(0),</div><div class="line"><a name="l03511"></a><span class="lineno"> 3511</span>  elapsed_time_(0) {</div><div class="line"><a name="l03512"></a><span class="lineno"> 3512</span> }</div><div class="line"><a name="l03513"></a><span class="lineno"> 3513</span> </div><div class="line"><a name="l03514"></a><span class="lineno"> 3514</span> <span class="comment">// D'tor.</span></div><div class="line"><a name="l03515"></a><span class="lineno"> 3515</span> TestResult::~TestResult() {</div><div class="line"><a name="l03516"></a><span class="lineno"> 3516</span> }</div><div class="line"><a name="l03517"></a><span class="lineno"> 3517</span> </div><div class="line"><a name="l03518"></a><span class="lineno"> 3518</span> <span class="comment">// Returns the i-th test part result among all the results. i can</span></div><div class="line"><a name="l03519"></a><span class="lineno"> 3519</span> <span class="comment">// range from 0 to total_part_count() - 1. If i is not in that range,</span></div><div class="line"><a name="l03520"></a><span class="lineno"> 3520</span> <span class="comment">// aborts the program.</span></div><div class="line"><a name="l03521"></a><span class="lineno"> 3521</span> <span class="keyword">const</span> TestPartResult& TestResult::GetTestPartResult(<span class="keywordtype">int</span> i)<span class="keyword"> const </span>{</div><div class="line"><a name="l03522"></a><span class="lineno"> 3522</span>  <span class="keywordflow">if</span> (i < 0 || i >= total_part_count())</div><div class="line"><a name="l03523"></a><span class="lineno"> 3523</span>  <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a69b8278c59359dd6a6f941b4643db9fb">internal::posix::Abort</a>();</div><div class="line"><a name="l03524"></a><span class="lineno"> 3524</span>  <span class="keywordflow">return</span> test_part_results_.at(i);</div><div class="line"><a name="l03525"></a><span class="lineno"> 3525</span> }</div><div class="line"><a name="l03526"></a><span class="lineno"> 3526</span> </div><div class="line"><a name="l03527"></a><span class="lineno"> 3527</span> <span class="comment">// Returns the i-th test property. i can range from 0 to</span></div><div class="line"><a name="l03528"></a><span class="lineno"> 3528</span> <span class="comment">// test_property_count() - 1. If i is not in that range, aborts the</span></div><div class="line"><a name="l03529"></a><span class="lineno"> 3529</span> <span class="comment">// program.</span></div><div class="line"><a name="l03530"></a><span class="lineno"> 3530</span> <span class="keyword">const</span> TestProperty& TestResult::GetTestProperty(<span class="keywordtype">int</span> i)<span class="keyword"> const </span>{</div><div class="line"><a name="l03531"></a><span class="lineno"> 3531</span>  <span class="keywordflow">if</span> (i < 0 || i >= test_property_count())</div><div class="line"><a name="l03532"></a><span class="lineno"> 3532</span>  <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a69b8278c59359dd6a6f941b4643db9fb">internal::posix::Abort</a>();</div><div class="line"><a name="l03533"></a><span class="lineno"> 3533</span>  <span class="keywordflow">return</span> test_properties_.at(i);</div><div class="line"><a name="l03534"></a><span class="lineno"> 3534</span> }</div><div class="line"><a name="l03535"></a><span class="lineno"> 3535</span> </div><div class="line"><a name="l03536"></a><span class="lineno"> 3536</span> <span class="comment">// Clears the test part results.</span></div><div class="line"><a name="l03537"></a><span class="lineno"> 3537</span> <span class="keywordtype">void</span> TestResult::ClearTestPartResults() {</div><div class="line"><a name="l03538"></a><span class="lineno"> 3538</span>  test_part_results_.clear();</div><div class="line"><a name="l03539"></a><span class="lineno"> 3539</span> }</div><div class="line"><a name="l03540"></a><span class="lineno"> 3540</span> </div><div class="line"><a name="l03541"></a><span class="lineno"> 3541</span> <span class="comment">// Adds a test part result to the list.</span></div><div class="line"><a name="l03542"></a><span class="lineno"> 3542</span> <span class="keywordtype">void</span> TestResult::AddTestPartResult(<span class="keyword">const</span> TestPartResult& test_part_result) {</div><div class="line"><a name="l03543"></a><span class="lineno"> 3543</span>  test_part_results_.push_back(test_part_result);</div><div class="line"><a name="l03544"></a><span class="lineno"> 3544</span> }</div><div class="line"><a name="l03545"></a><span class="lineno"> 3545</span> </div><div class="line"><a name="l03546"></a><span class="lineno"> 3546</span> <span class="comment">// Adds a test property to the list. If a property with the same key as the</span></div><div class="line"><a name="l03547"></a><span class="lineno"> 3547</span> <span class="comment">// supplied property is already represented, the value of this test_property</span></div><div class="line"><a name="l03548"></a><span class="lineno"> 3548</span> <span class="comment">// replaces the old value for that key.</span></div><div class="line"><a name="l03549"></a><span class="lineno"> 3549</span> <span class="keywordtype">void</span> TestResult::RecordProperty(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& xml_element,</div><div class="line"><a name="l03550"></a><span class="lineno"> 3550</span>  <span class="keyword">const</span> TestProperty& test_property) {</div><div class="line"><a name="l03551"></a><span class="lineno"> 3551</span>  <span class="keywordflow">if</span> (!ValidateTestProperty(xml_element, test_property)) {</div><div class="line"><a name="l03552"></a><span class="lineno"> 3552</span>  <span class="keywordflow">return</span>;</div><div class="line"><a name="l03553"></a><span class="lineno"> 3553</span>  }</div><div class="line"><a name="l03554"></a><span class="lineno"> 3554</span>  <a class="code" href="namespacetesting_1_1internal.html#a08b187c6cc4e28400aadf9a32fccc8de">internal::MutexLock</a> lock(&test_properites_mutex_);</div><div class="line"><a name="l03555"></a><span class="lineno"> 3555</span>  <span class="keyword">const</span> std::vector<TestProperty>::iterator property_with_matching_key =</div><div class="line"><a name="l03556"></a><span class="lineno"> 3556</span>  <a class="code" href="namespaceutl_1_1meta.html#aacf124929c0cbb3b29d34679bff50a96">std::find_if</a>(test_properties_.begin(), test_properties_.end(),</div><div class="line"><a name="l03557"></a><span class="lineno"> 3557</span>  internal::TestPropertyKeyIs(test_property.key()));</div><div class="line"><a name="l03558"></a><span class="lineno"> 3558</span>  <span class="keywordflow">if</span> (property_with_matching_key == test_properties_.end()) {</div><div class="line"><a name="l03559"></a><span class="lineno"> 3559</span>  test_properties_.push_back(test_property);</div><div class="line"><a name="l03560"></a><span class="lineno"> 3560</span>  <span class="keywordflow">return</span>;</div><div class="line"><a name="l03561"></a><span class="lineno"> 3561</span>  }</div><div class="line"><a name="l03562"></a><span class="lineno"> 3562</span>  property_with_matching_key->SetValue(test_property.value());</div><div class="line"><a name="l03563"></a><span class="lineno"> 3563</span> }</div><div class="line"><a name="l03564"></a><span class="lineno"> 3564</span> </div><div class="line"><a name="l03565"></a><span class="lineno"> 3565</span> <span class="comment">// The list of reserved attributes used in the <testsuites> element of XML</span></div><div class="line"><a name="l03566"></a><span class="lineno"> 3566</span> <span class="comment">// output.</span></div><div class="line"><a name="l03567"></a><span class="lineno"> 3567</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> kReservedTestSuitesAttributes[] = {</div><div class="line"><a name="l03568"></a><span class="lineno"> 3568</span>  <span class="stringliteral">"disabled"</span>,</div><div class="line"><a name="l03569"></a><span class="lineno"> 3569</span>  <span class="stringliteral">"errors"</span>,</div><div class="line"><a name="l03570"></a><span class="lineno"> 3570</span>  <span class="stringliteral">"failures"</span>,</div><div class="line"><a name="l03571"></a><span class="lineno"> 3571</span>  <span class="stringliteral">"name"</span>,</div><div class="line"><a name="l03572"></a><span class="lineno"> 3572</span>  <span class="stringliteral">"random_seed"</span>,</div><div class="line"><a name="l03573"></a><span class="lineno"> 3573</span>  <span class="stringliteral">"tests"</span>,</div><div class="line"><a name="l03574"></a><span class="lineno"> 3574</span>  <span class="stringliteral">"time"</span>,</div><div class="line"><a name="l03575"></a><span class="lineno"> 3575</span>  <span class="stringliteral">"timestamp"</span></div><div class="line"><a name="l03576"></a><span class="lineno"> 3576</span> };</div><div class="line"><a name="l03577"></a><span class="lineno"> 3577</span> </div><div class="line"><a name="l03578"></a><span class="lineno"> 3578</span> <span class="comment">// The list of reserved attributes used in the <testsuite> element of XML</span></div><div class="line"><a name="l03579"></a><span class="lineno"> 3579</span> <span class="comment">// output.</span></div><div class="line"><a name="l03580"></a><span class="lineno"> 3580</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> kReservedTestSuiteAttributes[] = {</div><div class="line"><a name="l03581"></a><span class="lineno"> 3581</span>  <span class="stringliteral">"disabled"</span>,</div><div class="line"><a name="l03582"></a><span class="lineno"> 3582</span>  <span class="stringliteral">"errors"</span>,</div><div class="line"><a name="l03583"></a><span class="lineno"> 3583</span>  <span class="stringliteral">"failures"</span>,</div><div class="line"><a name="l03584"></a><span class="lineno"> 3584</span>  <span class="stringliteral">"name"</span>,</div><div class="line"><a name="l03585"></a><span class="lineno"> 3585</span>  <span class="stringliteral">"tests"</span>,</div><div class="line"><a name="l03586"></a><span class="lineno"> 3586</span>  <span class="stringliteral">"time"</span></div><div class="line"><a name="l03587"></a><span class="lineno"> 3587</span> };</div><div class="line"><a name="l03588"></a><span class="lineno"> 3588</span> </div><div class="line"><a name="l03589"></a><span class="lineno"> 3589</span> <span class="comment">// The list of reserved attributes used in the <testcase> element of XML output.</span></div><div class="line"><a name="l03590"></a><span class="lineno"> 3590</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> kReservedTestCaseAttributes[] = {</div><div class="line"><a name="l03591"></a><span class="lineno"> 3591</span>  <span class="stringliteral">"classname"</span>, <span class="stringliteral">"name"</span>, <span class="stringliteral">"status"</span>, <span class="stringliteral">"time"</span>,</div><div class="line"><a name="l03592"></a><span class="lineno"> 3592</span>  <span class="stringliteral">"type_param"</span>, <span class="stringliteral">"value_param"</span>, <span class="stringliteral">"file"</span>, <span class="stringliteral">"line"</span>};</div><div class="line"><a name="l03593"></a><span class="lineno"> 3593</span> </div><div class="line"><a name="l03594"></a><span class="lineno"> 3594</span> <span class="keyword">template</span> <<span class="keywordtype">int</span> kSize></div><div class="line"><a name="l03595"></a><span class="lineno"> 3595</span> std::vector<std::string> ArrayAsVector(<span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> (&array)[kSize]) {</div><div class="line"><a name="l03596"></a><span class="lineno"> 3596</span>  <span class="keywordflow">return</span> std::vector<std::string>(array, array + kSize);</div><div class="line"><a name="l03597"></a><span class="lineno"> 3597</span> }</div><div class="line"><a name="l03598"></a><span class="lineno"> 3598</span> </div><div class="line"><a name="l03599"></a><span class="lineno"> 3599</span> <span class="keyword">static</span> std::vector<std::string> GetReservedAttributesForElement(</div><div class="line"><a name="l03600"></a><span class="lineno"> 3600</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& xml_element) {</div><div class="line"><a name="l03601"></a><span class="lineno"> 3601</span>  <span class="keywordflow">if</span> (xml_element == <span class="stringliteral">"testsuites"</span>) {</div><div class="line"><a name="l03602"></a><span class="lineno"> 3602</span>  <span class="keywordflow">return</span> ArrayAsVector(kReservedTestSuitesAttributes);</div><div class="line"><a name="l03603"></a><span class="lineno"> 3603</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (xml_element == <span class="stringliteral">"testsuite"</span>) {</div><div class="line"><a name="l03604"></a><span class="lineno"> 3604</span>  <span class="keywordflow">return</span> ArrayAsVector(kReservedTestSuiteAttributes);</div><div class="line"><a name="l03605"></a><span class="lineno"> 3605</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (xml_element == <span class="stringliteral">"testcase"</span>) {</div><div class="line"><a name="l03606"></a><span class="lineno"> 3606</span>  <span class="keywordflow">return</span> ArrayAsVector(kReservedTestCaseAttributes);</div><div class="line"><a name="l03607"></a><span class="lineno"> 3607</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l03608"></a><span class="lineno"> 3608</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(<span class="keyword">false</span>) << <span class="stringliteral">"Unrecognized xml_element provided: "</span> << xml_element;</div><div class="line"><a name="l03609"></a><span class="lineno"> 3609</span>  }</div><div class="line"><a name="l03610"></a><span class="lineno"> 3610</span>  <span class="comment">// This code is unreachable but some compilers may not realizes that.</span></div><div class="line"><a name="l03611"></a><span class="lineno"> 3611</span>  <span class="keywordflow">return</span> std::vector<std::string>();</div><div class="line"><a name="l03612"></a><span class="lineno"> 3612</span> }</div><div class="line"><a name="l03613"></a><span class="lineno"> 3613</span> </div><div class="line"><a name="l03614"></a><span class="lineno"> 3614</span> <span class="keyword">static</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> FormatWordList(<span class="keyword">const</span> std::vector<std::string>& words) {</div><div class="line"><a name="l03615"></a><span class="lineno"> 3615</span>  Message word_list;</div><div class="line"><a name="l03616"></a><span class="lineno"> 3616</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i < words.size(); ++i) {</div><div class="line"><a name="l03617"></a><span class="lineno"> 3617</span>  <span class="keywordflow">if</span> (i > 0 && words.size() > 2) {</div><div class="line"><a name="l03618"></a><span class="lineno"> 3618</span>  word_list << <span class="stringliteral">", "</span>;</div><div class="line"><a name="l03619"></a><span class="lineno"> 3619</span>  }</div><div class="line"><a name="l03620"></a><span class="lineno"> 3620</span>  <span class="keywordflow">if</span> (i == words.size() - 1) {</div><div class="line"><a name="l03621"></a><span class="lineno"> 3621</span>  word_list << <span class="stringliteral">"and "</span>;</div><div class="line"><a name="l03622"></a><span class="lineno"> 3622</span>  }</div><div class="line"><a name="l03623"></a><span class="lineno"> 3623</span>  word_list << <span class="stringliteral">"'"</span> << words[i] << <span class="stringliteral">"'"</span>;</div><div class="line"><a name="l03624"></a><span class="lineno"> 3624</span>  }</div><div class="line"><a name="l03625"></a><span class="lineno"> 3625</span>  <span class="keywordflow">return</span> word_list.GetString();</div><div class="line"><a name="l03626"></a><span class="lineno"> 3626</span> }</div><div class="line"><a name="l03627"></a><span class="lineno"> 3627</span> </div><div class="line"><a name="l03628"></a><span class="lineno"> 3628</span> <span class="keyword">static</span> <span class="keywordtype">bool</span> ValidateTestPropertyName(</div><div class="line"><a name="l03629"></a><span class="lineno"> 3629</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& property_name,</div><div class="line"><a name="l03630"></a><span class="lineno"> 3630</span>  <span class="keyword">const</span> std::vector<std::string>& reserved_names) {</div><div class="line"><a name="l03631"></a><span class="lineno"> 3631</span>  <span class="keywordflow">if</span> (<a class="code" href="namespaceutl_1_1meta.html#af4c9b6350bba98cc0dd73e87cb4ce413">std::find</a>(reserved_names.begin(), reserved_names.end(), property_name) !=</div><div class="line"><a name="l03632"></a><span class="lineno"> 3632</span>  reserved_names.end()) {</div><div class="line"><a name="l03633"></a><span class="lineno"> 3633</span>  <a class="code" href="gtest_8h.html#adc16b5b0a740c39084ea5c9e960e3063">ADD_FAILURE</a>() << <span class="stringliteral">"Reserved key used in RecordProperty(): "</span> << property_name</div><div class="line"><a name="l03634"></a><span class="lineno"> 3634</span>  << <span class="stringliteral">" ("</span> << FormatWordList(reserved_names)</div><div class="line"><a name="l03635"></a><span class="lineno"> 3635</span>  << <span class="stringliteral">" are reserved by "</span> << <a class="code" href="gtest_8h.html#a13d98c217176bd8722c395b9225fc19d">GTEST_NAME_</a> << <span class="stringliteral">")"</span>;</div><div class="line"><a name="l03636"></a><span class="lineno"> 3636</span>  <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l03637"></a><span class="lineno"> 3637</span>  }</div><div class="line"><a name="l03638"></a><span class="lineno"> 3638</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l03639"></a><span class="lineno"> 3639</span> }</div><div class="line"><a name="l03640"></a><span class="lineno"> 3640</span> </div><div class="line"><a name="l03641"></a><span class="lineno"> 3641</span> <span class="comment">// Adds a failure if the key is a reserved attribute of the element named</span></div><div class="line"><a name="l03642"></a><span class="lineno"> 3642</span> <span class="comment">// xml_element. Returns true if the property is valid.</span></div><div class="line"><a name="l03643"></a><span class="lineno"> 3643</span> <span class="keywordtype">bool</span> TestResult::ValidateTestProperty(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& xml_element,</div><div class="line"><a name="l03644"></a><span class="lineno"> 3644</span>  <span class="keyword">const</span> TestProperty& test_property) {</div><div class="line"><a name="l03645"></a><span class="lineno"> 3645</span>  <span class="keywordflow">return</span> ValidateTestPropertyName(test_property.key(),</div><div class="line"><a name="l03646"></a><span class="lineno"> 3646</span>  GetReservedAttributesForElement(xml_element));</div><div class="line"><a name="l03647"></a><span class="lineno"> 3647</span> }</div><div class="line"><a name="l03648"></a><span class="lineno"> 3648</span> </div><div class="line"><a name="l03649"></a><span class="lineno"> 3649</span> <span class="comment">// Clears the object.</span></div><div class="line"><a name="l03650"></a><span class="lineno"> 3650</span> <span class="keywordtype">void</span> TestResult::Clear() {</div><div class="line"><a name="l03651"></a><span class="lineno"> 3651</span>  test_part_results_.clear();</div><div class="line"><a name="l03652"></a><span class="lineno"> 3652</span>  test_properties_.clear();</div><div class="line"><a name="l03653"></a><span class="lineno"> 3653</span>  death_test_count_ = 0;</div><div class="line"><a name="l03654"></a><span class="lineno"> 3654</span>  elapsed_time_ = 0;</div><div class="line"><a name="l03655"></a><span class="lineno"> 3655</span> }</div><div class="line"><a name="l03656"></a><span class="lineno"> 3656</span> </div><div class="line"><a name="l03657"></a><span class="lineno"> 3657</span> <span class="comment">// Returns true off the test part was skipped.</span></div><div class="line"><a name="l03658"></a><span class="lineno"> 3658</span> <span class="keyword">static</span> <span class="keywordtype">bool</span> TestPartSkipped(<span class="keyword">const</span> TestPartResult& result) {</div><div class="line"><a name="l03659"></a><span class="lineno"> 3659</span>  <span class="keywordflow">return</span> result.skipped();</div><div class="line"><a name="l03660"></a><span class="lineno"> 3660</span> }</div><div class="line"><a name="l03661"></a><span class="lineno"> 3661</span> </div><div class="line"><a name="l03662"></a><span class="lineno"> 3662</span> <span class="comment">// Returns true iff the test was skipped.</span></div><div class="line"><a name="l03663"></a><span class="lineno"> 3663</span> <span class="keywordtype">bool</span> TestResult::Skipped()<span class="keyword"> const </span>{</div><div class="line"><a name="l03664"></a><span class="lineno"> 3664</span>  <span class="keywordflow">return</span> !Failed() && CountIf(test_part_results_, TestPartSkipped) > 0;</div><div class="line"><a name="l03665"></a><span class="lineno"> 3665</span> }</div><div class="line"><a name="l03666"></a><span class="lineno"> 3666</span> </div><div class="line"><a name="l03667"></a><span class="lineno"> 3667</span> <span class="comment">// Returns true iff the test failed.</span></div><div class="line"><a name="l03668"></a><span class="lineno"> 3668</span> <span class="keywordtype">bool</span> TestResult::Failed()<span class="keyword"> const </span>{</div><div class="line"><a name="l03669"></a><span class="lineno"> 3669</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < total_part_count(); ++i) {</div><div class="line"><a name="l03670"></a><span class="lineno"> 3670</span>  <span class="keywordflow">if</span> (GetTestPartResult(i).failed())</div><div class="line"><a name="l03671"></a><span class="lineno"> 3671</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l03672"></a><span class="lineno"> 3672</span>  }</div><div class="line"><a name="l03673"></a><span class="lineno"> 3673</span>  <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l03674"></a><span class="lineno"> 3674</span> }</div><div class="line"><a name="l03675"></a><span class="lineno"> 3675</span> </div><div class="line"><a name="l03676"></a><span class="lineno"> 3676</span> <span class="comment">// Returns true iff the test part fatally failed.</span></div><div class="line"><a name="l03677"></a><span class="lineno"> 3677</span> <span class="keyword">static</span> <span class="keywordtype">bool</span> TestPartFatallyFailed(<span class="keyword">const</span> TestPartResult& result) {</div><div class="line"><a name="l03678"></a><span class="lineno"> 3678</span>  <span class="keywordflow">return</span> result.fatally_failed();</div><div class="line"><a name="l03679"></a><span class="lineno"> 3679</span> }</div><div class="line"><a name="l03680"></a><span class="lineno"> 3680</span> </div><div class="line"><a name="l03681"></a><span class="lineno"> 3681</span> <span class="comment">// Returns true iff the test fatally failed.</span></div><div class="line"><a name="l03682"></a><span class="lineno"> 3682</span> <span class="keywordtype">bool</span> TestResult::HasFatalFailure()<span class="keyword"> const </span>{</div><div class="line"><a name="l03683"></a><span class="lineno"> 3683</span>  <span class="keywordflow">return</span> CountIf(test_part_results_, TestPartFatallyFailed) > 0;</div><div class="line"><a name="l03684"></a><span class="lineno"> 3684</span> }</div><div class="line"><a name="l03685"></a><span class="lineno"> 3685</span> </div><div class="line"><a name="l03686"></a><span class="lineno"> 3686</span> <span class="comment">// Returns true iff the test part non-fatally failed.</span></div><div class="line"><a name="l03687"></a><span class="lineno"> 3687</span> <span class="keyword">static</span> <span class="keywordtype">bool</span> TestPartNonfatallyFailed(<span class="keyword">const</span> TestPartResult& result) {</div><div class="line"><a name="l03688"></a><span class="lineno"> 3688</span>  <span class="keywordflow">return</span> result.nonfatally_failed();</div><div class="line"><a name="l03689"></a><span class="lineno"> 3689</span> }</div><div class="line"><a name="l03690"></a><span class="lineno"> 3690</span> </div><div class="line"><a name="l03691"></a><span class="lineno"> 3691</span> <span class="comment">// Returns true iff the test has a non-fatal failure.</span></div><div class="line"><a name="l03692"></a><span class="lineno"> 3692</span> <span class="keywordtype">bool</span> TestResult::HasNonfatalFailure()<span class="keyword"> const </span>{</div><div class="line"><a name="l03693"></a><span class="lineno"> 3693</span>  <span class="keywordflow">return</span> CountIf(test_part_results_, TestPartNonfatallyFailed) > 0;</div><div class="line"><a name="l03694"></a><span class="lineno"> 3694</span> }</div><div class="line"><a name="l03695"></a><span class="lineno"> 3695</span> </div><div class="line"><a name="l03696"></a><span class="lineno"> 3696</span> <span class="comment">// Gets the number of all test parts. This is the sum of the number</span></div><div class="line"><a name="l03697"></a><span class="lineno"> 3697</span> <span class="comment">// of successful test parts and the number of failed test parts.</span></div><div class="line"><a name="l03698"></a><span class="lineno"> 3698</span> <span class="keywordtype">int</span> TestResult::total_part_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l03699"></a><span class="lineno"> 3699</span>  <span class="keywordflow">return</span> <span class="keyword">static_cast<</span><span class="keywordtype">int</span><span class="keyword">></span>(test_part_results_.size());</div><div class="line"><a name="l03700"></a><span class="lineno"> 3700</span> }</div><div class="line"><a name="l03701"></a><span class="lineno"> 3701</span> </div><div class="line"><a name="l03702"></a><span class="lineno"> 3702</span> <span class="comment">// Returns the number of the test properties.</span></div><div class="line"><a name="l03703"></a><span class="lineno"> 3703</span> <span class="keywordtype">int</span> TestResult::test_property_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l03704"></a><span class="lineno"> 3704</span>  <span class="keywordflow">return</span> <span class="keyword">static_cast<</span><span class="keywordtype">int</span><span class="keyword">></span>(test_properties_.size());</div><div class="line"><a name="l03705"></a><span class="lineno"> 3705</span> }</div><div class="line"><a name="l03706"></a><span class="lineno"> 3706</span> </div><div class="line"><a name="l03707"></a><span class="lineno"> 3707</span> <span class="comment">// class Test</span></div><div class="line"><a name="l03708"></a><span class="lineno"> 3708</span> </div><div class="line"><a name="l03709"></a><span class="lineno"> 3709</span> <span class="comment">// Creates a Test object.</span></div><div class="line"><a name="l03710"></a><span class="lineno"> 3710</span> </div><div class="line"><a name="l03711"></a><span class="lineno"> 3711</span> <span class="comment">// The c'tor saves the states of all flags.</span></div><div class="line"><a name="l03712"></a><span class="lineno"> 3712</span> Test::Test()</div><div class="line"><a name="l03713"></a><span class="lineno"> 3713</span>  : gtest_flag_saver_(new <a class="code" href="gtest_8h.html#a3749ef4fba6b3c3993609b336031644d">GTEST_FLAG_SAVER_</a>) {</div><div class="line"><a name="l03714"></a><span class="lineno"> 3714</span> }</div><div class="line"><a name="l03715"></a><span class="lineno"> 3715</span> </div><div class="line"><a name="l03716"></a><span class="lineno"> 3716</span> <span class="comment">// The d'tor restores the states of all flags. The actual work is</span></div><div class="line"><a name="l03717"></a><span class="lineno"> 3717</span> <span class="comment">// done by the d'tor of the gtest_flag_saver_ field, and thus not</span></div><div class="line"><a name="l03718"></a><span class="lineno"> 3718</span> <span class="comment">// visible here.</span></div><div class="line"><a name="l03719"></a><span class="lineno"> 3719</span> Test::~Test() {</div><div class="line"><a name="l03720"></a><span class="lineno"> 3720</span> }</div><div class="line"><a name="l03721"></a><span class="lineno"> 3721</span> </div><div class="line"><a name="l03722"></a><span class="lineno"> 3722</span> <span class="comment">// Sets up the test fixture.</span></div><div class="line"><a name="l03723"></a><span class="lineno"> 3723</span> <span class="comment">//</span></div><div class="line"><a name="l03724"></a><span class="lineno"> 3724</span> <span class="comment">// A sub-class may override this.</span></div><div class="line"><a name="l03725"></a><span class="lineno"> 3725</span> <span class="keywordtype">void</span> Test::SetUp() {</div><div class="line"><a name="l03726"></a><span class="lineno"> 3726</span> }</div><div class="line"><a name="l03727"></a><span class="lineno"> 3727</span> </div><div class="line"><a name="l03728"></a><span class="lineno"> 3728</span> <span class="comment">// Tears down the test fixture.</span></div><div class="line"><a name="l03729"></a><span class="lineno"> 3729</span> <span class="comment">//</span></div><div class="line"><a name="l03730"></a><span class="lineno"> 3730</span> <span class="comment">// A sub-class may override this.</span></div><div class="line"><a name="l03731"></a><span class="lineno"> 3731</span> <span class="keywordtype">void</span> Test::TearDown() {</div><div class="line"><a name="l03732"></a><span class="lineno"> 3732</span> }</div><div class="line"><a name="l03733"></a><span class="lineno"> 3733</span> </div><div class="line"><a name="l03734"></a><span class="lineno"> 3734</span> <span class="comment">// Allows user supplied key value pairs to be recorded for later output.</span></div><div class="line"><a name="l03735"></a><span class="lineno"> 3735</span> <span class="keywordtype">void</span> Test::RecordProperty(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& key, <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& value) {</div><div class="line"><a name="l03736"></a><span class="lineno"> 3736</span>  UnitTest::GetInstance()->RecordProperty(key, value);</div><div class="line"><a name="l03737"></a><span class="lineno"> 3737</span> }</div><div class="line"><a name="l03738"></a><span class="lineno"> 3738</span> </div><div class="line"><a name="l03739"></a><span class="lineno"> 3739</span> <span class="comment">// Allows user supplied key value pairs to be recorded for later output.</span></div><div class="line"><a name="l03740"></a><span class="lineno"> 3740</span> <span class="keywordtype">void</span> Test::RecordProperty(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& key, <span class="keywordtype">int</span> value) {</div><div class="line"><a name="l03741"></a><span class="lineno"> 3741</span>  Message value_message;</div><div class="line"><a name="l03742"></a><span class="lineno"> 3742</span>  value_message << value;</div><div class="line"><a name="l03743"></a><span class="lineno"> 3743</span>  RecordProperty(key, value_message.GetString().c_str());</div><div class="line"><a name="l03744"></a><span class="lineno"> 3744</span> }</div><div class="line"><a name="l03745"></a><span class="lineno"> 3745</span> </div><div class="line"><a name="l03746"></a><span class="lineno"> 3746</span> <span class="keyword">namespace </span>internal {</div><div class="line"><a name="l03747"></a><span class="lineno"> 3747</span> </div><div class="line"><a name="l03748"></a><span class="lineno"> 3748</span> <span class="keywordtype">void</span> ReportFailureInUnknownLocation(TestPartResult::Type result_type,</div><div class="line"><a name="l03749"></a><span class="lineno"> 3749</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& message) {</div><div class="line"><a name="l03750"></a><span class="lineno"> 3750</span>  <span class="comment">// This function is a friend of UnitTest and as such has access to</span></div><div class="line"><a name="l03751"></a><span class="lineno"> 3751</span>  <span class="comment">// AddTestPartResult.</span></div><div class="line"><a name="l03752"></a><span class="lineno"> 3752</span>  UnitTest::GetInstance()->AddTestPartResult(</div><div class="line"><a name="l03753"></a><span class="lineno"> 3753</span>  result_type,</div><div class="line"><a name="l03754"></a><span class="lineno"> 3754</span>  <span class="keyword">nullptr</span>, <span class="comment">// No info about the source file where the exception occurred.</span></div><div class="line"><a name="l03755"></a><span class="lineno"> 3755</span>  -1, <span class="comment">// We have no info on which line caused the exception.</span></div><div class="line"><a name="l03756"></a><span class="lineno"> 3756</span>  message,</div><div class="line"><a name="l03757"></a><span class="lineno"> 3757</span>  <span class="stringliteral">""</span>); <span class="comment">// No stack trace, either.</span></div><div class="line"><a name="l03758"></a><span class="lineno"> 3758</span> }</div><div class="line"><a name="l03759"></a><span class="lineno"> 3759</span> </div><div class="line"><a name="l03760"></a><span class="lineno"> 3760</span> } <span class="comment">// namespace internal</span></div><div class="line"><a name="l03761"></a><span class="lineno"> 3761</span> </div><div class="line"><a name="l03762"></a><span class="lineno"> 3762</span> <span class="comment">// Google Test requires all tests in the same test suite to use the same test</span></div><div class="line"><a name="l03763"></a><span class="lineno"> 3763</span> <span class="comment">// fixture class. This function checks if the current test has the</span></div><div class="line"><a name="l03764"></a><span class="lineno"> 3764</span> <span class="comment">// same fixture class as the first test in the current test suite. If</span></div><div class="line"><a name="l03765"></a><span class="lineno"> 3765</span> <span class="comment">// yes, it returns true; otherwise it generates a Google Test failure and</span></div><div class="line"><a name="l03766"></a><span class="lineno"> 3766</span> <span class="comment">// returns false.</span></div><div class="line"><a name="l03767"></a><span class="lineno"> 3767</span> <span class="keywordtype">bool</span> Test::HasSameFixtureClass() {</div><div class="line"><a name="l03768"></a><span class="lineno"> 3768</span>  internal::UnitTestImpl* <span class="keyword">const</span> impl = internal::GetUnitTestImpl();</div><div class="line"><a name="l03769"></a><span class="lineno"> 3769</span>  <span class="keyword">const</span> TestSuite* <span class="keyword">const</span> test_suite = impl->current_test_suite();</div><div class="line"><a name="l03770"></a><span class="lineno"> 3770</span> </div><div class="line"><a name="l03771"></a><span class="lineno"> 3771</span>  <span class="comment">// Info about the first test in the current test suite.</span></div><div class="line"><a name="l03772"></a><span class="lineno"> 3772</span>  <span class="keyword">const</span> TestInfo* <span class="keyword">const</span> first_test_info = test_suite->test_info_list()[0];</div><div class="line"><a name="l03773"></a><span class="lineno"> 3773</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#ab1114197d3c657d8b7f8e0c5caa12d00">internal::TypeId</a> first_fixture_id = first_test_info->fixture_class_id_;</div><div class="line"><a name="l03774"></a><span class="lineno"> 3774</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> first_test_name = first_test_info->name();</div><div class="line"><a name="l03775"></a><span class="lineno"> 3775</span> </div><div class="line"><a name="l03776"></a><span class="lineno"> 3776</span>  <span class="comment">// Info about the current test.</span></div><div class="line"><a name="l03777"></a><span class="lineno"> 3777</span>  <span class="keyword">const</span> TestInfo* <span class="keyword">const</span> this_test_info = impl->current_test_info();</div><div class="line"><a name="l03778"></a><span class="lineno"> 3778</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#ab1114197d3c657d8b7f8e0c5caa12d00">internal::TypeId</a> this_fixture_id = this_test_info->fixture_class_id_;</div><div class="line"><a name="l03779"></a><span class="lineno"> 3779</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> this_test_name = this_test_info->name();</div><div class="line"><a name="l03780"></a><span class="lineno"> 3780</span> </div><div class="line"><a name="l03781"></a><span class="lineno"> 3781</span>  <span class="keywordflow">if</span> (this_fixture_id != first_fixture_id) {</div><div class="line"><a name="l03782"></a><span class="lineno"> 3782</span>  <span class="comment">// Is the first test defined using TEST?</span></div><div class="line"><a name="l03783"></a><span class="lineno"> 3783</span>  <span class="keyword">const</span> <span class="keywordtype">bool</span> first_is_TEST = first_fixture_id == <a class="code" href="namespacetesting_1_1internal.html#a1e85cf16bb95b60f879d48ba1fbfc1c9">internal::GetTestTypeId</a>();</div><div class="line"><a name="l03784"></a><span class="lineno"> 3784</span>  <span class="comment">// Is this test defined using TEST?</span></div><div class="line"><a name="l03785"></a><span class="lineno"> 3785</span>  <span class="keyword">const</span> <span class="keywordtype">bool</span> this_is_TEST = this_fixture_id == <a class="code" href="namespacetesting_1_1internal.html#a1e85cf16bb95b60f879d48ba1fbfc1c9">internal::GetTestTypeId</a>();</div><div class="line"><a name="l03786"></a><span class="lineno"> 3786</span> </div><div class="line"><a name="l03787"></a><span class="lineno"> 3787</span>  <span class="keywordflow">if</span> (first_is_TEST || this_is_TEST) {</div><div class="line"><a name="l03788"></a><span class="lineno"> 3788</span>  <span class="comment">// Both TEST and TEST_F appear in same test suite, which is incorrect.</span></div><div class="line"><a name="l03789"></a><span class="lineno"> 3789</span>  <span class="comment">// Tell the user how to fix this.</span></div><div class="line"><a name="l03790"></a><span class="lineno"> 3790</span> </div><div class="line"><a name="l03791"></a><span class="lineno"> 3791</span>  <span class="comment">// Gets the name of the TEST and the name of the TEST_F. Note</span></div><div class="line"><a name="l03792"></a><span class="lineno"> 3792</span>  <span class="comment">// that first_is_TEST and this_is_TEST cannot both be true, as</span></div><div class="line"><a name="l03793"></a><span class="lineno"> 3793</span>  <span class="comment">// the fixture IDs are different for the two tests.</span></div><div class="line"><a name="l03794"></a><span class="lineno"> 3794</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> TEST_name =</div><div class="line"><a name="l03795"></a><span class="lineno"> 3795</span>  first_is_TEST ? first_test_name : this_test_name;</div><div class="line"><a name="l03796"></a><span class="lineno"> 3796</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> TEST_F_name =</div><div class="line"><a name="l03797"></a><span class="lineno"> 3797</span>  first_is_TEST ? this_test_name : first_test_name;</div><div class="line"><a name="l03798"></a><span class="lineno"> 3798</span> </div><div class="line"><a name="l03799"></a><span class="lineno"> 3799</span>  <a class="code" href="gtest_8h.html#adc16b5b0a740c39084ea5c9e960e3063">ADD_FAILURE</a>()</div><div class="line"><a name="l03800"></a><span class="lineno"> 3800</span>  << <span class="stringliteral">"All tests in the same test suite must use the same test fixture\n"</span></div><div class="line"><a name="l03801"></a><span class="lineno"> 3801</span>  << <span class="stringliteral">"class, so mixing TEST_F and TEST in the same test suite is\n"</span></div><div class="line"><a name="l03802"></a><span class="lineno"> 3802</span>  << <span class="stringliteral">"illegal. In test suite "</span> << this_test_info->test_suite_name()</div><div class="line"><a name="l03803"></a><span class="lineno"> 3803</span>  << <span class="stringliteral">",\n"</span></div><div class="line"><a name="l03804"></a><span class="lineno"> 3804</span>  << <span class="stringliteral">"test "</span> << TEST_F_name << <span class="stringliteral">" is defined using TEST_F but\n"</span></div><div class="line"><a name="l03805"></a><span class="lineno"> 3805</span>  << <span class="stringliteral">"test "</span> << TEST_name << <span class="stringliteral">" is defined using TEST. You probably\n"</span></div><div class="line"><a name="l03806"></a><span class="lineno"> 3806</span>  << <span class="stringliteral">"want to change the TEST to TEST_F or move it to another test\n"</span></div><div class="line"><a name="l03807"></a><span class="lineno"> 3807</span>  << <span class="stringliteral">"case."</span>;</div><div class="line"><a name="l03808"></a><span class="lineno"> 3808</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l03809"></a><span class="lineno"> 3809</span>  <span class="comment">// Two fixture classes with the same name appear in two different</span></div><div class="line"><a name="l03810"></a><span class="lineno"> 3810</span>  <span class="comment">// namespaces, which is not allowed. Tell the user how to fix this.</span></div><div class="line"><a name="l03811"></a><span class="lineno"> 3811</span>  <a class="code" href="gtest_8h.html#adc16b5b0a740c39084ea5c9e960e3063">ADD_FAILURE</a>()</div><div class="line"><a name="l03812"></a><span class="lineno"> 3812</span>  << <span class="stringliteral">"All tests in the same test suite must use the same test fixture\n"</span></div><div class="line"><a name="l03813"></a><span class="lineno"> 3813</span>  << <span class="stringliteral">"class. However, in test suite "</span></div><div class="line"><a name="l03814"></a><span class="lineno"> 3814</span>  << this_test_info->test_suite_name() << <span class="stringliteral">",\n"</span></div><div class="line"><a name="l03815"></a><span class="lineno"> 3815</span>  << <span class="stringliteral">"you defined test "</span> << first_test_name << <span class="stringliteral">" and test "</span></div><div class="line"><a name="l03816"></a><span class="lineno"> 3816</span>  << this_test_name << <span class="stringliteral">"\n"</span></div><div class="line"><a name="l03817"></a><span class="lineno"> 3817</span>  << <span class="stringliteral">"using two different test fixture classes. This can happen if\n"</span></div><div class="line"><a name="l03818"></a><span class="lineno"> 3818</span>  << <span class="stringliteral">"the two classes are from different namespaces or translation\n"</span></div><div class="line"><a name="l03819"></a><span class="lineno"> 3819</span>  << <span class="stringliteral">"units and have the same name. You should probably rename one\n"</span></div><div class="line"><a name="l03820"></a><span class="lineno"> 3820</span>  << <span class="stringliteral">"of the classes to put the tests into different test suites."</span>;</div><div class="line"><a name="l03821"></a><span class="lineno"> 3821</span>  }</div><div class="line"><a name="l03822"></a><span class="lineno"> 3822</span>  <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l03823"></a><span class="lineno"> 3823</span>  }</div><div class="line"><a name="l03824"></a><span class="lineno"> 3824</span> </div><div class="line"><a name="l03825"></a><span class="lineno"> 3825</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l03826"></a><span class="lineno"> 3826</span> }</div><div class="line"><a name="l03827"></a><span class="lineno"> 3827</span> </div><div class="line"><a name="l03828"></a><span class="lineno"> 3828</span> <span class="preprocessor">#if GTEST_HAS_SEH</span></div><div class="line"><a name="l03829"></a><span class="lineno"> 3829</span> </div><div class="line"><a name="l03830"></a><span class="lineno"> 3830</span> <span class="comment">// Adds an "exception thrown" fatal failure to the current test. This</span></div><div class="line"><a name="l03831"></a><span class="lineno"> 3831</span> <span class="comment">// function returns its result via an output parameter pointer because VC++</span></div><div class="line"><a name="l03832"></a><span class="lineno"> 3832</span> <span class="comment">// prohibits creation of objects with destructors on stack in functions</span></div><div class="line"><a name="l03833"></a><span class="lineno"> 3833</span> <span class="comment">// using __try (see error C2712).</span></div><div class="line"><a name="l03834"></a><span class="lineno"> 3834</span> <span class="keyword">static</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>* FormatSehExceptionMessage(DWORD exception_code,</div><div class="line"><a name="l03835"></a><span class="lineno"> 3835</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* location) {</div><div class="line"><a name="l03836"></a><span class="lineno"> 3836</span>  Message message;</div><div class="line"><a name="l03837"></a><span class="lineno"> 3837</span>  message << <span class="stringliteral">"SEH exception with code 0x"</span> << std::setbase(16) <<</div><div class="line"><a name="l03838"></a><span class="lineno"> 3838</span>  exception_code << std::setbase(10) << <span class="stringliteral">" thrown in "</span> << location << <span class="stringliteral">"."</span>;</div><div class="line"><a name="l03839"></a><span class="lineno"> 3839</span> </div><div class="line"><a name="l03840"></a><span class="lineno"> 3840</span>  <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(message.GetString());</div><div class="line"><a name="l03841"></a><span class="lineno"> 3841</span> }</div><div class="line"><a name="l03842"></a><span class="lineno"> 3842</span> </div><div class="line"><a name="l03843"></a><span class="lineno"> 3843</span> <span class="preprocessor">#endif // GTEST_HAS_SEH</span></div><div class="line"><a name="l03844"></a><span class="lineno"> 3844</span> </div><div class="line"><a name="l03845"></a><span class="lineno"> 3845</span> <span class="keyword">namespace </span>internal {</div><div class="line"><a name="l03846"></a><span class="lineno"> 3846</span> </div><div class="line"><a name="l03847"></a><span class="lineno"> 3847</span> <span class="preprocessor">#if GTEST_HAS_EXCEPTIONS</span></div><div class="line"><a name="l03848"></a><span class="lineno"> 3848</span> </div><div class="line"><a name="l03849"></a><span class="lineno"> 3849</span> <span class="comment">// Adds an "exception thrown" fatal failure to the current test.</span></div><div class="line"><a name="l03850"></a><span class="lineno"> 3850</span> <span class="keyword">static</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> FormatCxxExceptionMessage(<span class="keyword">const</span> <span class="keywordtype">char</span>* description,</div><div class="line"><a name="l03851"></a><span class="lineno"> 3851</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* location) {</div><div class="line"><a name="l03852"></a><span class="lineno"> 3852</span>  Message message;</div><div class="line"><a name="l03853"></a><span class="lineno"> 3853</span>  <span class="keywordflow">if</span> (description != <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l03854"></a><span class="lineno"> 3854</span>  message << <span class="stringliteral">"C++ exception with description \""</span> << description << <span class="stringliteral">"\""</span>;</div><div class="line"><a name="l03855"></a><span class="lineno"> 3855</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l03856"></a><span class="lineno"> 3856</span>  message << <span class="stringliteral">"Unknown C++ exception"</span>;</div><div class="line"><a name="l03857"></a><span class="lineno"> 3857</span>  }</div><div class="line"><a name="l03858"></a><span class="lineno"> 3858</span>  message << <span class="stringliteral">" thrown in "</span> << location << <span class="stringliteral">"."</span>;</div><div class="line"><a name="l03859"></a><span class="lineno"> 3859</span> </div><div class="line"><a name="l03860"></a><span class="lineno"> 3860</span>  <span class="keywordflow">return</span> message.GetString();</div><div class="line"><a name="l03861"></a><span class="lineno"> 3861</span> }</div><div class="line"><a name="l03862"></a><span class="lineno"> 3862</span> </div><div class="line"><a name="l03863"></a><span class="lineno"> 3863</span> <span class="keyword">static</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> PrintTestPartResultToString(</div><div class="line"><a name="l03864"></a><span class="lineno"> 3864</span>  <span class="keyword">const</span> TestPartResult& test_part_result);</div><div class="line"><a name="l03865"></a><span class="lineno"> 3865</span> </div><div class="line"><a name="l03866"></a><span class="lineno"> 3866</span> GoogleTestFailureException::GoogleTestFailureException(</div><div class="line"><a name="l03867"></a><span class="lineno"> 3867</span>  <span class="keyword">const</span> TestPartResult& failure)</div><div class="line"><a name="l03868"></a><span class="lineno"> 3868</span>  : ::std::runtime_error(PrintTestPartResultToString(failure).c_str()) {}</div><div class="line"><a name="l03869"></a><span class="lineno"> 3869</span> </div><div class="line"><a name="l03870"></a><span class="lineno"> 3870</span> <span class="preprocessor">#endif // GTEST_HAS_EXCEPTIONS</span></div><div class="line"><a name="l03871"></a><span class="lineno"> 3871</span> </div><div class="line"><a name="l03872"></a><span class="lineno"> 3872</span> <span class="comment">// We put these helper functions in the internal namespace as IBM's xlC</span></div><div class="line"><a name="l03873"></a><span class="lineno"> 3873</span> <span class="comment">// compiler rejects the code if they were declared static.</span></div><div class="line"><a name="l03874"></a><span class="lineno"> 3874</span> </div><div class="line"><a name="l03875"></a><span class="lineno"> 3875</span> <span class="comment">// Runs the given method and handles SEH exceptions it throws, when</span></div><div class="line"><a name="l03876"></a><span class="lineno"> 3876</span> <span class="comment">// SEH is supported; returns the 0-value for type Result in case of an</span></div><div class="line"><a name="l03877"></a><span class="lineno"> 3877</span> <span class="comment">// SEH exception. (Microsoft compilers cannot handle SEH and C++</span></div><div class="line"><a name="l03878"></a><span class="lineno"> 3878</span> <span class="comment">// exceptions in the same function. Therefore, we provide a separate</span></div><div class="line"><a name="l03879"></a><span class="lineno"> 3879</span> <span class="comment">// wrapper function for handling SEH exceptions.)</span></div><div class="line"><a name="l03880"></a><span class="lineno"> 3880</span> <span class="keyword">template</span> <<span class="keyword">class</span> T, <span class="keyword">typename</span> Result></div><div class="line"><a name="l03881"></a><span class="lineno"> 3881</span> Result HandleSehExceptionsInMethodIfSupported(</div><div class="line"><a name="l03882"></a><span class="lineno"> 3882</span>  T* <span class="keywordtype">object</span>, Result (T::*method)(), <span class="keyword">const</span> <span class="keywordtype">char</span>* location) {</div><div class="line"><a name="l03883"></a><span class="lineno"> 3883</span> <span class="preprocessor">#if GTEST_HAS_SEH</span></div><div class="line"><a name="l03884"></a><span class="lineno"> 3884</span>  __try {</div><div class="line"><a name="l03885"></a><span class="lineno"> 3885</span>  <span class="keywordflow">return</span> (object->*method)();</div><div class="line"><a name="l03886"></a><span class="lineno"> 3886</span>  } __except (internal::UnitTestOptions::GTestShouldProcessSEH( <span class="comment">// NOLINT</span></div><div class="line"><a name="l03887"></a><span class="lineno"> 3887</span>  GetExceptionCode())) {</div><div class="line"><a name="l03888"></a><span class="lineno"> 3888</span>  <span class="comment">// We create the exception message on the heap because VC++ prohibits</span></div><div class="line"><a name="l03889"></a><span class="lineno"> 3889</span>  <span class="comment">// creation of objects with destructors on stack in functions using __try</span></div><div class="line"><a name="l03890"></a><span class="lineno"> 3890</span>  <span class="comment">// (see error C2712).</span></div><div class="line"><a name="l03891"></a><span class="lineno"> 3891</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>* exception_message = FormatSehExceptionMessage(</div><div class="line"><a name="l03892"></a><span class="lineno"> 3892</span>  GetExceptionCode(), location);</div><div class="line"><a name="l03893"></a><span class="lineno"> 3893</span>  internal::ReportFailureInUnknownLocation(TestPartResult::kFatalFailure,</div><div class="line"><a name="l03894"></a><span class="lineno"> 3894</span>  *exception_message);</div><div class="line"><a name="l03895"></a><span class="lineno"> 3895</span>  <span class="keyword">delete</span> exception_message;</div><div class="line"><a name="l03896"></a><span class="lineno"> 3896</span>  <span class="keywordflow">return</span> <span class="keyword">static_cast<</span>Result<span class="keyword">></span>(0);</div><div class="line"><a name="l03897"></a><span class="lineno"> 3897</span>  }</div><div class="line"><a name="l03898"></a><span class="lineno"> 3898</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l03899"></a><span class="lineno"> 3899</span>  (void)location;</div><div class="line"><a name="l03900"></a><span class="lineno"> 3900</span>  <span class="keywordflow">return</span> (object->*method)();</div><div class="line"><a name="l03901"></a><span class="lineno"> 3901</span> <span class="preprocessor">#endif // GTEST_HAS_SEH</span></div><div class="line"><a name="l03902"></a><span class="lineno"> 3902</span> }</div><div class="line"><a name="l03903"></a><span class="lineno"> 3903</span> </div><div class="line"><a name="l03904"></a><span class="lineno"> 3904</span> <span class="comment">// Runs the given method and catches and reports C++ and/or SEH-style</span></div><div class="line"><a name="l03905"></a><span class="lineno"> 3905</span> <span class="comment">// exceptions, if they are supported; returns the 0-value for type</span></div><div class="line"><a name="l03906"></a><span class="lineno"> 3906</span> <span class="comment">// Result in case of an SEH exception.</span></div><div class="line"><a name="l03907"></a><span class="lineno"> 3907</span> <span class="keyword">template</span> <<span class="keyword">class</span> T, <span class="keyword">typename</span> Result></div><div class="line"><a name="l03908"></a><span class="lineno"> 3908</span> Result HandleExceptionsInMethodIfSupported(</div><div class="line"><a name="l03909"></a><span class="lineno"> 3909</span>  T* <span class="keywordtype">object</span>, Result (T::*method)(), <span class="keyword">const</span> <span class="keywordtype">char</span>* location) {</div><div class="line"><a name="l03910"></a><span class="lineno"> 3910</span>  <span class="comment">// NOTE: The user code can affect the way in which Google Test handles</span></div><div class="line"><a name="l03911"></a><span class="lineno"> 3911</span>  <span class="comment">// exceptions by setting GTEST_FLAG(catch_exceptions), but only before</span></div><div class="line"><a name="l03912"></a><span class="lineno"> 3912</span>  <span class="comment">// RUN_ALL_TESTS() starts. It is technically possible to check the flag</span></div><div class="line"><a name="l03913"></a><span class="lineno"> 3913</span>  <span class="comment">// after the exception is caught and either report or re-throw the</span></div><div class="line"><a name="l03914"></a><span class="lineno"> 3914</span>  <span class="comment">// exception based on the flag's value:</span></div><div class="line"><a name="l03915"></a><span class="lineno"> 3915</span>  <span class="comment">//</span></div><div class="line"><a name="l03916"></a><span class="lineno"> 3916</span>  <span class="comment">// try {</span></div><div class="line"><a name="l03917"></a><span class="lineno"> 3917</span>  <span class="comment">// // Perform the test method.</span></div><div class="line"><a name="l03918"></a><span class="lineno"> 3918</span>  <span class="comment">// } catch (...) {</span></div><div class="line"><a name="l03919"></a><span class="lineno"> 3919</span>  <span class="comment">// if (GTEST_FLAG(catch_exceptions))</span></div><div class="line"><a name="l03920"></a><span class="lineno"> 3920</span>  <span class="comment">// // Report the exception as failure.</span></div><div class="line"><a name="l03921"></a><span class="lineno"> 3921</span>  <span class="comment">// else</span></div><div class="line"><a name="l03922"></a><span class="lineno"> 3922</span>  <span class="comment">// throw; // Re-throws the original exception.</span></div><div class="line"><a name="l03923"></a><span class="lineno"> 3923</span>  <span class="comment">// }</span></div><div class="line"><a name="l03924"></a><span class="lineno"> 3924</span>  <span class="comment">//</span></div><div class="line"><a name="l03925"></a><span class="lineno"> 3925</span>  <span class="comment">// However, the purpose of this flag is to allow the program to drop into</span></div><div class="line"><a name="l03926"></a><span class="lineno"> 3926</span>  <span class="comment">// the debugger when the exception is thrown. On most platforms, once the</span></div><div class="line"><a name="l03927"></a><span class="lineno"> 3927</span>  <span class="comment">// control enters the catch block, the exception origin information is</span></div><div class="line"><a name="l03928"></a><span class="lineno"> 3928</span>  <span class="comment">// lost and the debugger will stop the program at the point of the</span></div><div class="line"><a name="l03929"></a><span class="lineno"> 3929</span>  <span class="comment">// re-throw in this function -- instead of at the point of the original</span></div><div class="line"><a name="l03930"></a><span class="lineno"> 3930</span>  <span class="comment">// throw statement in the code under test. For this reason, we perform</span></div><div class="line"><a name="l03931"></a><span class="lineno"> 3931</span>  <span class="comment">// the check early, sacrificing the ability to affect Google Test's</span></div><div class="line"><a name="l03932"></a><span class="lineno"> 3932</span>  <span class="comment">// exception handling in the method where the exception is thrown.</span></div><div class="line"><a name="l03933"></a><span class="lineno"> 3933</span>  <span class="keywordflow">if</span> (internal::GetUnitTestImpl()->catch_exceptions()) {</div><div class="line"><a name="l03934"></a><span class="lineno"> 3934</span> <span class="preprocessor">#if GTEST_HAS_EXCEPTIONS</span></div><div class="line"><a name="l03935"></a><span class="lineno"> 3935</span>  <span class="keywordflow">try</span> {</div><div class="line"><a name="l03936"></a><span class="lineno"> 3936</span>  <span class="keywordflow">return</span> HandleSehExceptionsInMethodIfSupported(<span class="keywordtype">object</span>, method, location);</div><div class="line"><a name="l03937"></a><span class="lineno"> 3937</span>  } <span class="keywordflow">catch</span> (<span class="keyword">const</span> AssertionException&) { <span class="comment">// NOLINT</span></div><div class="line"><a name="l03938"></a><span class="lineno"> 3938</span>  <span class="comment">// This failure was reported already.</span></div><div class="line"><a name="l03939"></a><span class="lineno"> 3939</span>  } <span class="keywordflow">catch</span> (<span class="keyword">const</span> internal::GoogleTestFailureException&) { <span class="comment">// NOLINT</span></div><div class="line"><a name="l03940"></a><span class="lineno"> 3940</span>  <span class="comment">// This exception type can only be thrown by a failed Google</span></div><div class="line"><a name="l03941"></a><span class="lineno"> 3941</span>  <span class="comment">// Test assertion with the intention of letting another testing</span></div><div class="line"><a name="l03942"></a><span class="lineno"> 3942</span>  <span class="comment">// framework catch it. Therefore we just re-throw it.</span></div><div class="line"><a name="l03943"></a><span class="lineno"> 3943</span>  <span class="keywordflow">throw</span>;</div><div class="line"><a name="l03944"></a><span class="lineno"> 3944</span>  } <span class="keywordflow">catch</span> (<span class="keyword">const</span> std::exception& e) { <span class="comment">// NOLINT</span></div><div class="line"><a name="l03945"></a><span class="lineno"> 3945</span>  internal::ReportFailureInUnknownLocation(</div><div class="line"><a name="l03946"></a><span class="lineno"> 3946</span>  TestPartResult::kFatalFailure,</div><div class="line"><a name="l03947"></a><span class="lineno"> 3947</span>  FormatCxxExceptionMessage(e.what(), location));</div><div class="line"><a name="l03948"></a><span class="lineno"> 3948</span>  } <span class="keywordflow">catch</span> (...) { <span class="comment">// NOLINT</span></div><div class="line"><a name="l03949"></a><span class="lineno"> 3949</span>  internal::ReportFailureInUnknownLocation(</div><div class="line"><a name="l03950"></a><span class="lineno"> 3950</span>  TestPartResult::kFatalFailure,</div><div class="line"><a name="l03951"></a><span class="lineno"> 3951</span>  FormatCxxExceptionMessage(<span class="keyword">nullptr</span>, location));</div><div class="line"><a name="l03952"></a><span class="lineno"> 3952</span>  }</div><div class="line"><a name="l03953"></a><span class="lineno"> 3953</span>  <span class="keywordflow">return</span> <span class="keyword">static_cast<</span>Result<span class="keyword">></span>(0);</div><div class="line"><a name="l03954"></a><span class="lineno"> 3954</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l03955"></a><span class="lineno"> 3955</span>  <span class="keywordflow">return</span> HandleSehExceptionsInMethodIfSupported(<span class="keywordtype">object</span>, method, location);</div><div class="line"><a name="l03956"></a><span class="lineno"> 3956</span> <span class="preprocessor">#endif // GTEST_HAS_EXCEPTIONS</span></div><div class="line"><a name="l03957"></a><span class="lineno"> 3957</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l03958"></a><span class="lineno"> 3958</span>  <span class="keywordflow">return</span> (object->*method)();</div><div class="line"><a name="l03959"></a><span class="lineno"> 3959</span>  }</div><div class="line"><a name="l03960"></a><span class="lineno"> 3960</span> }</div><div class="line"><a name="l03961"></a><span class="lineno"> 3961</span> </div><div class="line"><a name="l03962"></a><span class="lineno"> 3962</span> } <span class="comment">// namespace internal</span></div><div class="line"><a name="l03963"></a><span class="lineno"> 3963</span> </div><div class="line"><a name="l03964"></a><span class="lineno"> 3964</span> <span class="comment">// Runs the test and updates the test result.</span></div><div class="line"><a name="l03965"></a><span class="lineno"> 3965</span> <span class="keywordtype">void</span> Test::Run() {</div><div class="line"><a name="l03966"></a><span class="lineno"> 3966</span>  <span class="keywordflow">if</span> (!HasSameFixtureClass()) <span class="keywordflow">return</span>;</div><div class="line"><a name="l03967"></a><span class="lineno"> 3967</span> </div><div class="line"><a name="l03968"></a><span class="lineno"> 3968</span>  internal::UnitTestImpl* <span class="keyword">const</span> impl = internal::GetUnitTestImpl();</div><div class="line"><a name="l03969"></a><span class="lineno"> 3969</span>  impl->os_stack_trace_getter()->UponLeavingGTest();</div><div class="line"><a name="l03970"></a><span class="lineno"> 3970</span>  internal::HandleExceptionsInMethodIfSupported(<span class="keyword">this</span>, &Test::SetUp, <span class="stringliteral">"SetUp()"</span>);</div><div class="line"><a name="l03971"></a><span class="lineno"> 3971</span>  <span class="comment">// We will run the test only if SetUp() was successful and didn't call</span></div><div class="line"><a name="l03972"></a><span class="lineno"> 3972</span>  <span class="comment">// GTEST_SKIP().</span></div><div class="line"><a name="l03973"></a><span class="lineno"> 3973</span>  <span class="keywordflow">if</span> (!HasFatalFailure() && !IsSkipped()) {</div><div class="line"><a name="l03974"></a><span class="lineno"> 3974</span>  impl->os_stack_trace_getter()->UponLeavingGTest();</div><div class="line"><a name="l03975"></a><span class="lineno"> 3975</span>  internal::HandleExceptionsInMethodIfSupported(</div><div class="line"><a name="l03976"></a><span class="lineno"> 3976</span>  <span class="keyword">this</span>, &Test::TestBody, <span class="stringliteral">"the test body"</span>);</div><div class="line"><a name="l03977"></a><span class="lineno"> 3977</span>  }</div><div class="line"><a name="l03978"></a><span class="lineno"> 3978</span> </div><div class="line"><a name="l03979"></a><span class="lineno"> 3979</span>  <span class="comment">// However, we want to clean up as much as possible. Hence we will</span></div><div class="line"><a name="l03980"></a><span class="lineno"> 3980</span>  <span class="comment">// always call TearDown(), even if SetUp() or the test body has</span></div><div class="line"><a name="l03981"></a><span class="lineno"> 3981</span>  <span class="comment">// failed.</span></div><div class="line"><a name="l03982"></a><span class="lineno"> 3982</span>  impl->os_stack_trace_getter()->UponLeavingGTest();</div><div class="line"><a name="l03983"></a><span class="lineno"> 3983</span>  internal::HandleExceptionsInMethodIfSupported(</div><div class="line"><a name="l03984"></a><span class="lineno"> 3984</span>  <span class="keyword">this</span>, &Test::TearDown, <span class="stringliteral">"TearDown()"</span>);</div><div class="line"><a name="l03985"></a><span class="lineno"> 3985</span> }</div><div class="line"><a name="l03986"></a><span class="lineno"> 3986</span> </div><div class="line"><a name="l03987"></a><span class="lineno"> 3987</span> <span class="comment">// Returns true iff the current test has a fatal failure.</span></div><div class="line"><a name="l03988"></a><span class="lineno"> 3988</span> <span class="keywordtype">bool</span> Test::HasFatalFailure() {</div><div class="line"><a name="l03989"></a><span class="lineno"> 3989</span>  <span class="keywordflow">return</span> internal::GetUnitTestImpl()->current_test_result()->HasFatalFailure();</div><div class="line"><a name="l03990"></a><span class="lineno"> 3990</span> }</div><div class="line"><a name="l03991"></a><span class="lineno"> 3991</span> </div><div class="line"><a name="l03992"></a><span class="lineno"> 3992</span> <span class="comment">// Returns true iff the current test has a non-fatal failure.</span></div><div class="line"><a name="l03993"></a><span class="lineno"> 3993</span> <span class="keywordtype">bool</span> Test::HasNonfatalFailure() {</div><div class="line"><a name="l03994"></a><span class="lineno"> 3994</span>  <span class="keywordflow">return</span> internal::GetUnitTestImpl()->current_test_result()-></div><div class="line"><a name="l03995"></a><span class="lineno"> 3995</span>  HasNonfatalFailure();</div><div class="line"><a name="l03996"></a><span class="lineno"> 3996</span> }</div><div class="line"><a name="l03997"></a><span class="lineno"> 3997</span> </div><div class="line"><a name="l03998"></a><span class="lineno"> 3998</span> <span class="comment">// Returns true iff the current test was skipped.</span></div><div class="line"><a name="l03999"></a><span class="lineno"> 3999</span> <span class="keywordtype">bool</span> Test::IsSkipped() {</div><div class="line"><a name="l04000"></a><span class="lineno"> 4000</span>  <span class="keywordflow">return</span> internal::GetUnitTestImpl()->current_test_result()->Skipped();</div><div class="line"><a name="l04001"></a><span class="lineno"> 4001</span> }</div><div class="line"><a name="l04002"></a><span class="lineno"> 4002</span> </div><div class="line"><a name="l04003"></a><span class="lineno"> 4003</span> <span class="comment">// class TestInfo</span></div><div class="line"><a name="l04004"></a><span class="lineno"> 4004</span> </div><div class="line"><a name="l04005"></a><span class="lineno"> 4005</span> <span class="comment">// Constructs a TestInfo object. It assumes ownership of the test factory</span></div><div class="line"><a name="l04006"></a><span class="lineno"> 4006</span> <span class="comment">// object.</span></div><div class="line"><a name="l04007"></a><span class="lineno"> 4007</span> TestInfo::TestInfo(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& a_test_suite_name,</div><div class="line"><a name="l04008"></a><span class="lineno"> 4008</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& a_name, <span class="keyword">const</span> <span class="keywordtype">char</span>* a_type_param,</div><div class="line"><a name="l04009"></a><span class="lineno"> 4009</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* a_value_param,</div><div class="line"><a name="l04010"></a><span class="lineno"> 4010</span>  internal::CodeLocation a_code_location,</div><div class="line"><a name="l04011"></a><span class="lineno"> 4011</span>  <a class="code" href="namespacetesting_1_1internal.html#ab1114197d3c657d8b7f8e0c5caa12d00">internal::TypeId</a> fixture_class_id,</div><div class="line"><a name="l04012"></a><span class="lineno"> 4012</span>  internal::TestFactoryBase* factory)</div><div class="line"><a name="l04013"></a><span class="lineno"> 4013</span>  : test_suite_name_(a_test_suite_name),</div><div class="line"><a name="l04014"></a><span class="lineno"> 4014</span>  name_(a_name),</div><div class="line"><a name="l04015"></a><span class="lineno"> 4015</span>  type_param_(a_type_param ? new std::<a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">string</a>(a_type_param) : nullptr),</div><div class="line"><a name="l04016"></a><span class="lineno"> 4016</span>  value_param_(a_value_param ? new std::<a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">string</a>(a_value_param) : nullptr),</div><div class="line"><a name="l04017"></a><span class="lineno"> 4017</span>  location_(a_code_location),</div><div class="line"><a name="l04018"></a><span class="lineno"> 4018</span>  fixture_class_id_(fixture_class_id),</div><div class="line"><a name="l04019"></a><span class="lineno"> 4019</span>  should_run_(false),</div><div class="line"><a name="l04020"></a><span class="lineno"> 4020</span>  is_disabled_(false),</div><div class="line"><a name="l04021"></a><span class="lineno"> 4021</span>  matches_filter_(false),</div><div class="line"><a name="l04022"></a><span class="lineno"> 4022</span>  factory_(factory),</div><div class="line"><a name="l04023"></a><span class="lineno"> 4023</span>  result_() {}</div><div class="line"><a name="l04024"></a><span class="lineno"> 4024</span> </div><div class="line"><a name="l04025"></a><span class="lineno"> 4025</span> <span class="comment">// Destructs a TestInfo object.</span></div><div class="line"><a name="l04026"></a><span class="lineno"> 4026</span> TestInfo::~TestInfo() { <span class="keyword">delete</span> factory_; }</div><div class="line"><a name="l04027"></a><span class="lineno"> 4027</span> </div><div class="line"><a name="l04028"></a><span class="lineno"> 4028</span> <span class="keyword">namespace </span>internal {</div><div class="line"><a name="l04029"></a><span class="lineno"> 4029</span> </div><div class="line"><a name="l04030"></a><span class="lineno"> 4030</span> <span class="comment">// Creates a new TestInfo object and registers it with Google Test;</span></div><div class="line"><a name="l04031"></a><span class="lineno"> 4031</span> <span class="comment">// returns the created object.</span></div><div class="line"><a name="l04032"></a><span class="lineno"> 4032</span> <span class="comment">//</span></div><div class="line"><a name="l04033"></a><span class="lineno"> 4033</span> <span class="comment">// Arguments:</span></div><div class="line"><a name="l04034"></a><span class="lineno"> 4034</span> <span class="comment">//</span></div><div class="line"><a name="l04035"></a><span class="lineno"> 4035</span> <span class="comment">// test_suite_name: name of the test suite</span></div><div class="line"><a name="l04036"></a><span class="lineno"> 4036</span> <span class="comment">// name: name of the test</span></div><div class="line"><a name="l04037"></a><span class="lineno"> 4037</span> <span class="comment">// type_param: the name of the test's type parameter, or NULL if</span></div><div class="line"><a name="l04038"></a><span class="lineno"> 4038</span> <span class="comment">// this is not a typed or a type-parameterized test.</span></div><div class="line"><a name="l04039"></a><span class="lineno"> 4039</span> <span class="comment">// value_param: text representation of the test's value parameter,</span></div><div class="line"><a name="l04040"></a><span class="lineno"> 4040</span> <span class="comment">// or NULL if this is not a value-parameterized test.</span></div><div class="line"><a name="l04041"></a><span class="lineno"> 4041</span> <span class="comment">// code_location: code location where the test is defined</span></div><div class="line"><a name="l04042"></a><span class="lineno"> 4042</span> <span class="comment">// fixture_class_id: ID of the test fixture class</span></div><div class="line"><a name="l04043"></a><span class="lineno"> 4043</span> <span class="comment">// set_up_tc: pointer to the function that sets up the test suite</span></div><div class="line"><a name="l04044"></a><span class="lineno"> 4044</span> <span class="comment">// tear_down_tc: pointer to the function that tears down the test suite</span></div><div class="line"><a name="l04045"></a><span class="lineno"> 4045</span> <span class="comment">// factory: pointer to the factory that creates a test object.</span></div><div class="line"><a name="l04046"></a><span class="lineno"> 4046</span> <span class="comment">// The newly created TestInfo instance will assume</span></div><div class="line"><a name="l04047"></a><span class="lineno"> 4047</span> <span class="comment">// ownership of the factory object.</span></div><div class="line"><a name="l04048"></a><span class="lineno"> 4048</span> TestInfo* <a class="code" href="namespacetesting_1_1internal.html#a7ab4072540184e26119ad853f45059f7">MakeAndRegisterTestInfo</a>(</div><div class="line"><a name="l04049"></a><span class="lineno"> 4049</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* test_suite_name, <span class="keyword">const</span> <span class="keywordtype">char</span>* name, <span class="keyword">const</span> <span class="keywordtype">char</span>* type_param,</div><div class="line"><a name="l04050"></a><span class="lineno"> 4050</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* value_param, CodeLocation code_location,</div><div class="line"><a name="l04051"></a><span class="lineno"> 4051</span>  <a class="code" href="namespacetesting_1_1internal.html#ab1114197d3c657d8b7f8e0c5caa12d00">TypeId</a> fixture_class_id, <a class="code" href="namespacetesting_1_1internal.html#a83e4e0732ac6a9dcfe6ee299dc1b9fa2">SetUpTestSuiteFunc</a> set_up_tc,</div><div class="line"><a name="l04052"></a><span class="lineno"> 4052</span>  <a class="code" href="namespacetesting_1_1internal.html#a8257a87aa42cebaa54b0c48a6ae657a5">TearDownTestSuiteFunc</a> tear_down_tc, TestFactoryBase* factory) {</div><div class="line"><a name="l04053"></a><span class="lineno"> 4053</span>  TestInfo* <span class="keyword">const</span> test_info =</div><div class="line"><a name="l04054"></a><span class="lineno"> 4054</span>  <span class="keyword">new</span> TestInfo(test_suite_name, name, type_param, value_param,</div><div class="line"><a name="l04055"></a><span class="lineno"> 4055</span>  code_location, fixture_class_id, factory);</div><div class="line"><a name="l04056"></a><span class="lineno"> 4056</span>  GetUnitTestImpl()->AddTestInfo(set_up_tc, tear_down_tc, test_info);</div><div class="line"><a name="l04057"></a><span class="lineno"> 4057</span>  <span class="keywordflow">return</span> test_info;</div><div class="line"><a name="l04058"></a><span class="lineno"> 4058</span> }</div><div class="line"><a name="l04059"></a><span class="lineno"> 4059</span> </div><div class="line"><a name="l04060"></a><span class="lineno"> 4060</span> <span class="keywordtype">void</span> <a class="code" href="namespacetesting_1_1internal.html#a5d3e97443d23bf1824f87feb172efd39">ReportInvalidTestSuiteType</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* test_suite_name,</div><div class="line"><a name="l04061"></a><span class="lineno"> 4061</span>  CodeLocation code_location) {</div><div class="line"><a name="l04062"></a><span class="lineno"> 4062</span>  Message errors;</div><div class="line"><a name="l04063"></a><span class="lineno"> 4063</span>  errors</div><div class="line"><a name="l04064"></a><span class="lineno"> 4064</span>  << <span class="stringliteral">"Attempted redefinition of test suite "</span> << test_suite_name << <span class="stringliteral">".\n"</span></div><div class="line"><a name="l04065"></a><span class="lineno"> 4065</span>  << <span class="stringliteral">"All tests in the same test suite must use the same test fixture\n"</span></div><div class="line"><a name="l04066"></a><span class="lineno"> 4066</span>  << <span class="stringliteral">"class. However, in test suite "</span> << test_suite_name << <span class="stringliteral">", you tried\n"</span></div><div class="line"><a name="l04067"></a><span class="lineno"> 4067</span>  << <span class="stringliteral">"to define a test using a fixture class different from the one\n"</span></div><div class="line"><a name="l04068"></a><span class="lineno"> 4068</span>  << <span class="stringliteral">"used earlier. This can happen if the two fixture classes are\n"</span></div><div class="line"><a name="l04069"></a><span class="lineno"> 4069</span>  << <span class="stringliteral">"from different namespaces and have the same name. You should\n"</span></div><div class="line"><a name="l04070"></a><span class="lineno"> 4070</span>  << <span class="stringliteral">"probably rename one of the classes to put the tests into different\n"</span></div><div class="line"><a name="l04071"></a><span class="lineno"> 4071</span>  << <span class="stringliteral">"test suites."</span>;</div><div class="line"><a name="l04072"></a><span class="lineno"> 4072</span> </div><div class="line"><a name="l04073"></a><span class="lineno"> 4073</span>  <a class="code" href="gtest_8h.html#a8ef4cb4c465db8c15464aecc6d9510ef">GTEST_LOG_</a>(ERROR) << <a class="code" href="namespacetesting_1_1internal.html#a31b7c3abed4a7c395f42c61e993989f4">FormatFileLocation</a>(code_location.file.c_str(),</div><div class="line"><a name="l04074"></a><span class="lineno"> 4074</span>  code_location.line)</div><div class="line"><a name="l04075"></a><span class="lineno"> 4075</span>  << <span class="stringliteral">" "</span> << errors.GetString();</div><div class="line"><a name="l04076"></a><span class="lineno"> 4076</span> }</div><div class="line"><a name="l04077"></a><span class="lineno"> 4077</span> } <span class="comment">// namespace internal</span></div><div class="line"><a name="l04078"></a><span class="lineno"> 4078</span> </div><div class="line"><a name="l04079"></a><span class="lineno"> 4079</span> <span class="keyword">namespace </span>{</div><div class="line"><a name="l04080"></a><span class="lineno"> 4080</span> </div><div class="line"><a name="l04081"></a><span class="lineno"> 4081</span> <span class="comment">// A predicate that checks the test name of a TestInfo against a known</span></div><div class="line"><a name="l04082"></a><span class="lineno"> 4082</span> <span class="comment">// value.</span></div><div class="line"><a name="l04083"></a><span class="lineno"> 4083</span> <span class="comment">//</span></div><div class="line"><a name="l04084"></a><span class="lineno"> 4084</span> <span class="comment">// This is used for implementation of the TestSuite class only. We put</span></div><div class="line"><a name="l04085"></a><span class="lineno"> 4085</span> <span class="comment">// it in the anonymous namespace to prevent polluting the outer</span></div><div class="line"><a name="l04086"></a><span class="lineno"> 4086</span> <span class="comment">// namespace.</span></div><div class="line"><a name="l04087"></a><span class="lineno"> 4087</span> <span class="comment">//</span></div><div class="line"><a name="l04088"></a><span class="lineno"> 4088</span> <span class="comment">// TestNameIs is copyable.</span></div><div class="line"><a name="l04089"></a><span class="lineno"> 4089</span> <span class="keyword">class </span>TestNameIs {</div><div class="line"><a name="l04090"></a><span class="lineno"> 4090</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l04091"></a><span class="lineno"> 4091</span>  <span class="comment">// Constructor.</span></div><div class="line"><a name="l04092"></a><span class="lineno"> 4092</span>  <span class="comment">//</span></div><div class="line"><a name="l04093"></a><span class="lineno"> 4093</span>  <span class="comment">// TestNameIs has NO default constructor.</span></div><div class="line"><a name="l04094"></a><span class="lineno"> 4094</span>  <span class="keyword">explicit</span> TestNameIs(<span class="keyword">const</span> <span class="keywordtype">char</span>* name)</div><div class="line"><a name="l04095"></a><span class="lineno"> 4095</span>  : name_(name) {}</div><div class="line"><a name="l04096"></a><span class="lineno"> 4096</span> </div><div class="line"><a name="l04097"></a><span class="lineno"> 4097</span>  <span class="comment">// Returns true iff the test name of test_info matches name_.</span></div><div class="line"><a name="l04098"></a><span class="lineno"> 4098</span>  <span class="keywordtype">bool</span> operator()(<span class="keyword">const</span> TestInfo * test_info)<span class="keyword"> const </span>{</div><div class="line"><a name="l04099"></a><span class="lineno"> 4099</span>  <span class="keywordflow">return</span> test_info && test_info->name() == name_;</div><div class="line"><a name="l04100"></a><span class="lineno"> 4100</span>  }</div><div class="line"><a name="l04101"></a><span class="lineno"> 4101</span> </div><div class="line"><a name="l04102"></a><span class="lineno"> 4102</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l04103"></a><span class="lineno"> 4103</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> name_;</div><div class="line"><a name="l04104"></a><span class="lineno"> 4104</span> };</div><div class="line"><a name="l04105"></a><span class="lineno"> 4105</span> </div><div class="line"><a name="l04106"></a><span class="lineno"> 4106</span> } <span class="comment">// namespace</span></div><div class="line"><a name="l04107"></a><span class="lineno"> 4107</span> </div><div class="line"><a name="l04108"></a><span class="lineno"> 4108</span> <span class="keyword">namespace </span>internal {</div><div class="line"><a name="l04109"></a><span class="lineno"> 4109</span> </div><div class="line"><a name="l04110"></a><span class="lineno"> 4110</span> <span class="comment">// This method expands all parameterized tests registered with macros TEST_P</span></div><div class="line"><a name="l04111"></a><span class="lineno"> 4111</span> <span class="comment">// and INSTANTIATE_TEST_SUITE_P into regular tests and registers those.</span></div><div class="line"><a name="l04112"></a><span class="lineno"> 4112</span> <span class="comment">// This will be done just once during the program runtime.</span></div><div class="line"><a name="l04113"></a><span class="lineno"> 4113</span> <span class="keywordtype">void</span> UnitTestImpl::RegisterParameterizedTests() {</div><div class="line"><a name="l04114"></a><span class="lineno"> 4114</span>  <span class="keywordflow">if</span> (!parameterized_tests_registered_) {</div><div class="line"><a name="l04115"></a><span class="lineno"> 4115</span>  parameterized_test_registry_.RegisterTests();</div><div class="line"><a name="l04116"></a><span class="lineno"> 4116</span>  parameterized_tests_registered_ = <span class="keyword">true</span>;</div><div class="line"><a name="l04117"></a><span class="lineno"> 4117</span>  }</div><div class="line"><a name="l04118"></a><span class="lineno"> 4118</span> }</div><div class="line"><a name="l04119"></a><span class="lineno"> 4119</span> </div><div class="line"><a name="l04120"></a><span class="lineno"> 4120</span> } <span class="comment">// namespace internal</span></div><div class="line"><a name="l04121"></a><span class="lineno"> 4121</span> </div><div class="line"><a name="l04122"></a><span class="lineno"> 4122</span> <span class="comment">// Creates the test object, runs it, records its result, and then</span></div><div class="line"><a name="l04123"></a><span class="lineno"> 4123</span> <span class="comment">// deletes it.</span></div><div class="line"><a name="l04124"></a><span class="lineno"> 4124</span> <span class="keywordtype">void</span> TestInfo::Run() {</div><div class="line"><a name="l04125"></a><span class="lineno"> 4125</span>  <span class="keywordflow">if</span> (!should_run_) <span class="keywordflow">return</span>;</div><div class="line"><a name="l04126"></a><span class="lineno"> 4126</span> </div><div class="line"><a name="l04127"></a><span class="lineno"> 4127</span>  <span class="comment">// Tells UnitTest where to store test result.</span></div><div class="line"><a name="l04128"></a><span class="lineno"> 4128</span>  internal::UnitTestImpl* <span class="keyword">const</span> impl = internal::GetUnitTestImpl();</div><div class="line"><a name="l04129"></a><span class="lineno"> 4129</span>  impl->set_current_test_info(<span class="keyword">this</span>);</div><div class="line"><a name="l04130"></a><span class="lineno"> 4130</span> </div><div class="line"><a name="l04131"></a><span class="lineno"> 4131</span>  TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();</div><div class="line"><a name="l04132"></a><span class="lineno"> 4132</span> </div><div class="line"><a name="l04133"></a><span class="lineno"> 4133</span>  <span class="comment">// Notifies the unit test event listeners that a test is about to start.</span></div><div class="line"><a name="l04134"></a><span class="lineno"> 4134</span>  repeater->OnTestStart(*<span class="keyword">this</span>);</div><div class="line"><a name="l04135"></a><span class="lineno"> 4135</span> </div><div class="line"><a name="l04136"></a><span class="lineno"> 4136</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a66a845df404b38fe85c5e14a069f255a">TimeInMillis</a> start = internal::GetTimeInMillis();</div><div class="line"><a name="l04137"></a><span class="lineno"> 4137</span> </div><div class="line"><a name="l04138"></a><span class="lineno"> 4138</span>  impl->os_stack_trace_getter()->UponLeavingGTest();</div><div class="line"><a name="l04139"></a><span class="lineno"> 4139</span> </div><div class="line"><a name="l04140"></a><span class="lineno"> 4140</span>  <span class="comment">// Creates the test object.</span></div><div class="line"><a name="l04141"></a><span class="lineno"> 4141</span>  Test* <span class="keyword">const</span> test = internal::HandleExceptionsInMethodIfSupported(</div><div class="line"><a name="l04142"></a><span class="lineno"> 4142</span>  factory_, &internal::TestFactoryBase::CreateTest,</div><div class="line"><a name="l04143"></a><span class="lineno"> 4143</span>  <span class="stringliteral">"the test fixture's constructor"</span>);</div><div class="line"><a name="l04144"></a><span class="lineno"> 4144</span> </div><div class="line"><a name="l04145"></a><span class="lineno"> 4145</span>  <span class="comment">// Runs the test if the constructor didn't generate a fatal failure or invoke</span></div><div class="line"><a name="l04146"></a><span class="lineno"> 4146</span>  <span class="comment">// GTEST_SKIP().</span></div><div class="line"><a name="l04147"></a><span class="lineno"> 4147</span>  <span class="comment">// Note that the object will not be null</span></div><div class="line"><a name="l04148"></a><span class="lineno"> 4148</span>  <span class="keywordflow">if</span> (!Test::HasFatalFailure() && !Test::IsSkipped()) {</div><div class="line"><a name="l04149"></a><span class="lineno"> 4149</span>  <span class="comment">// This doesn't throw as all user code that can throw are wrapped into</span></div><div class="line"><a name="l04150"></a><span class="lineno"> 4150</span>  <span class="comment">// exception handling code.</span></div><div class="line"><a name="l04151"></a><span class="lineno"> 4151</span>  test->Run();</div><div class="line"><a name="l04152"></a><span class="lineno"> 4152</span>  }</div><div class="line"><a name="l04153"></a><span class="lineno"> 4153</span> </div><div class="line"><a name="l04154"></a><span class="lineno"> 4154</span>  <span class="comment">// Deletes the test object.</span></div><div class="line"><a name="l04155"></a><span class="lineno"> 4155</span>  impl->os_stack_trace_getter()->UponLeavingGTest();</div><div class="line"><a name="l04156"></a><span class="lineno"> 4156</span>  internal::HandleExceptionsInMethodIfSupported(</div><div class="line"><a name="l04157"></a><span class="lineno"> 4157</span>  test, &Test::DeleteSelf_, <span class="stringliteral">"the test fixture's destructor"</span>);</div><div class="line"><a name="l04158"></a><span class="lineno"> 4158</span> </div><div class="line"><a name="l04159"></a><span class="lineno"> 4159</span>  result_.set_elapsed_time(internal::GetTimeInMillis() - start);</div><div class="line"><a name="l04160"></a><span class="lineno"> 4160</span> </div><div class="line"><a name="l04161"></a><span class="lineno"> 4161</span>  <span class="comment">// Notifies the unit test event listener that a test has just finished.</span></div><div class="line"><a name="l04162"></a><span class="lineno"> 4162</span>  repeater->OnTestEnd(*<span class="keyword">this</span>);</div><div class="line"><a name="l04163"></a><span class="lineno"> 4163</span> </div><div class="line"><a name="l04164"></a><span class="lineno"> 4164</span>  <span class="comment">// Tells UnitTest to stop associating assertion results to this</span></div><div class="line"><a name="l04165"></a><span class="lineno"> 4165</span>  <span class="comment">// test.</span></div><div class="line"><a name="l04166"></a><span class="lineno"> 4166</span>  impl->set_current_test_info(<span class="keyword">nullptr</span>);</div><div class="line"><a name="l04167"></a><span class="lineno"> 4167</span> }</div><div class="line"><a name="l04168"></a><span class="lineno"> 4168</span> </div><div class="line"><a name="l04169"></a><span class="lineno"> 4169</span> <span class="comment">// class TestSuite</span></div><div class="line"><a name="l04170"></a><span class="lineno"> 4170</span> </div><div class="line"><a name="l04171"></a><span class="lineno"> 4171</span> <span class="comment">// Gets the number of successful tests in this test suite.</span></div><div class="line"><a name="l04172"></a><span class="lineno"> 4172</span> <span class="keywordtype">int</span> TestSuite::successful_test_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l04173"></a><span class="lineno"> 4173</span>  <span class="keywordflow">return</span> CountIf(test_info_list_, TestPassed);</div><div class="line"><a name="l04174"></a><span class="lineno"> 4174</span> }</div><div class="line"><a name="l04175"></a><span class="lineno"> 4175</span> </div><div class="line"><a name="l04176"></a><span class="lineno"> 4176</span> <span class="comment">// Gets the number of successful tests in this test suite.</span></div><div class="line"><a name="l04177"></a><span class="lineno"> 4177</span> <span class="keywordtype">int</span> TestSuite::skipped_test_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l04178"></a><span class="lineno"> 4178</span>  <span class="keywordflow">return</span> CountIf(test_info_list_, TestSkipped);</div><div class="line"><a name="l04179"></a><span class="lineno"> 4179</span> }</div><div class="line"><a name="l04180"></a><span class="lineno"> 4180</span> </div><div class="line"><a name="l04181"></a><span class="lineno"> 4181</span> <span class="comment">// Gets the number of failed tests in this test suite.</span></div><div class="line"><a name="l04182"></a><span class="lineno"> 4182</span> <span class="keywordtype">int</span> TestSuite::failed_test_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l04183"></a><span class="lineno"> 4183</span>  <span class="keywordflow">return</span> CountIf(test_info_list_, TestFailed);</div><div class="line"><a name="l04184"></a><span class="lineno"> 4184</span> }</div><div class="line"><a name="l04185"></a><span class="lineno"> 4185</span> </div><div class="line"><a name="l04186"></a><span class="lineno"> 4186</span> <span class="comment">// Gets the number of disabled tests that will be reported in the XML report.</span></div><div class="line"><a name="l04187"></a><span class="lineno"> 4187</span> <span class="keywordtype">int</span> TestSuite::reportable_disabled_test_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l04188"></a><span class="lineno"> 4188</span>  <span class="keywordflow">return</span> CountIf(test_info_list_, TestReportableDisabled);</div><div class="line"><a name="l04189"></a><span class="lineno"> 4189</span> }</div><div class="line"><a name="l04190"></a><span class="lineno"> 4190</span> </div><div class="line"><a name="l04191"></a><span class="lineno"> 4191</span> <span class="comment">// Gets the number of disabled tests in this test suite.</span></div><div class="line"><a name="l04192"></a><span class="lineno"> 4192</span> <span class="keywordtype">int</span> TestSuite::disabled_test_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l04193"></a><span class="lineno"> 4193</span>  <span class="keywordflow">return</span> CountIf(test_info_list_, TestDisabled);</div><div class="line"><a name="l04194"></a><span class="lineno"> 4194</span> }</div><div class="line"><a name="l04195"></a><span class="lineno"> 4195</span> </div><div class="line"><a name="l04196"></a><span class="lineno"> 4196</span> <span class="comment">// Gets the number of tests to be printed in the XML report.</span></div><div class="line"><a name="l04197"></a><span class="lineno"> 4197</span> <span class="keywordtype">int</span> TestSuite::reportable_test_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l04198"></a><span class="lineno"> 4198</span>  <span class="keywordflow">return</span> CountIf(test_info_list_, TestReportable);</div><div class="line"><a name="l04199"></a><span class="lineno"> 4199</span> }</div><div class="line"><a name="l04200"></a><span class="lineno"> 4200</span> </div><div class="line"><a name="l04201"></a><span class="lineno"> 4201</span> <span class="comment">// Get the number of tests in this test suite that should run.</span></div><div class="line"><a name="l04202"></a><span class="lineno"> 4202</span> <span class="keywordtype">int</span> TestSuite::test_to_run_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l04203"></a><span class="lineno"> 4203</span>  <span class="keywordflow">return</span> CountIf(test_info_list_, ShouldRunTest);</div><div class="line"><a name="l04204"></a><span class="lineno"> 4204</span> }</div><div class="line"><a name="l04205"></a><span class="lineno"> 4205</span> </div><div class="line"><a name="l04206"></a><span class="lineno"> 4206</span> <span class="comment">// Gets the number of all tests.</span></div><div class="line"><a name="l04207"></a><span class="lineno"> 4207</span> <span class="keywordtype">int</span> TestSuite::total_test_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l04208"></a><span class="lineno"> 4208</span>  <span class="keywordflow">return</span> <span class="keyword">static_cast<</span><span class="keywordtype">int</span><span class="keyword">></span>(test_info_list_.size());</div><div class="line"><a name="l04209"></a><span class="lineno"> 4209</span> }</div><div class="line"><a name="l04210"></a><span class="lineno"> 4210</span> </div><div class="line"><a name="l04211"></a><span class="lineno"> 4211</span> <span class="comment">// Creates a TestSuite with the given name.</span></div><div class="line"><a name="l04212"></a><span class="lineno"> 4212</span> <span class="comment">//</span></div><div class="line"><a name="l04213"></a><span class="lineno"> 4213</span> <span class="comment">// Arguments:</span></div><div class="line"><a name="l04214"></a><span class="lineno"> 4214</span> <span class="comment">//</span></div><div class="line"><a name="l04215"></a><span class="lineno"> 4215</span> <span class="comment">// name: name of the test suite</span></div><div class="line"><a name="l04216"></a><span class="lineno"> 4216</span> <span class="comment">// a_type_param: the name of the test suite's type parameter, or NULL if</span></div><div class="line"><a name="l04217"></a><span class="lineno"> 4217</span> <span class="comment">// this is not a typed or a type-parameterized test suite.</span></div><div class="line"><a name="l04218"></a><span class="lineno"> 4218</span> <span class="comment">// set_up_tc: pointer to the function that sets up the test suite</span></div><div class="line"><a name="l04219"></a><span class="lineno"> 4219</span> <span class="comment">// tear_down_tc: pointer to the function that tears down the test suite</span></div><div class="line"><a name="l04220"></a><span class="lineno"> 4220</span> TestSuite::TestSuite(<span class="keyword">const</span> <span class="keywordtype">char</span>* a_name, <span class="keyword">const</span> <span class="keywordtype">char</span>* a_type_param,</div><div class="line"><a name="l04221"></a><span class="lineno"> 4221</span>  <a class="code" href="namespacetesting_1_1internal.html#a83e4e0732ac6a9dcfe6ee299dc1b9fa2">internal::SetUpTestSuiteFunc</a> set_up_tc,</div><div class="line"><a name="l04222"></a><span class="lineno"> 4222</span>  <a class="code" href="namespacetesting_1_1internal.html#a8257a87aa42cebaa54b0c48a6ae657a5">internal::TearDownTestSuiteFunc</a> tear_down_tc)</div><div class="line"><a name="l04223"></a><span class="lineno"> 4223</span>  : name_(a_name),</div><div class="line"><a name="l04224"></a><span class="lineno"> 4224</span>  type_param_(a_type_param ? new std::<a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">string</a>(a_type_param) : nullptr),</div><div class="line"><a name="l04225"></a><span class="lineno"> 4225</span>  set_up_tc_(set_up_tc),</div><div class="line"><a name="l04226"></a><span class="lineno"> 4226</span>  tear_down_tc_(tear_down_tc),</div><div class="line"><a name="l04227"></a><span class="lineno"> 4227</span>  should_run_(false),</div><div class="line"><a name="l04228"></a><span class="lineno"> 4228</span>  elapsed_time_(0) {}</div><div class="line"><a name="l04229"></a><span class="lineno"> 4229</span> </div><div class="line"><a name="l04230"></a><span class="lineno"> 4230</span> <span class="comment">// Destructor of TestSuite.</span></div><div class="line"><a name="l04231"></a><span class="lineno"> 4231</span> TestSuite::~TestSuite() {</div><div class="line"><a name="l04232"></a><span class="lineno"> 4232</span>  <span class="comment">// Deletes every Test in the collection.</span></div><div class="line"><a name="l04233"></a><span class="lineno"> 4233</span>  ForEach(test_info_list_, internal::Delete<TestInfo>);</div><div class="line"><a name="l04234"></a><span class="lineno"> 4234</span> }</div><div class="line"><a name="l04235"></a><span class="lineno"> 4235</span> </div><div class="line"><a name="l04236"></a><span class="lineno"> 4236</span> <span class="comment">// Returns the i-th test among all the tests. i can range from 0 to</span></div><div class="line"><a name="l04237"></a><span class="lineno"> 4237</span> <span class="comment">// total_test_count() - 1. If i is not in that range, returns NULL.</span></div><div class="line"><a name="l04238"></a><span class="lineno"> 4238</span> <span class="keyword">const</span> TestInfo* TestSuite::GetTestInfo(<span class="keywordtype">int</span> i)<span class="keyword"> const </span>{</div><div class="line"><a name="l04239"></a><span class="lineno"> 4239</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> index = GetElementOr(test_indices_, i, -1);</div><div class="line"><a name="l04240"></a><span class="lineno"> 4240</span>  <span class="keywordflow">return</span> index < 0 ? nullptr : test_info_list_[index];</div><div class="line"><a name="l04241"></a><span class="lineno"> 4241</span> }</div><div class="line"><a name="l04242"></a><span class="lineno"> 4242</span> </div><div class="line"><a name="l04243"></a><span class="lineno"> 4243</span> <span class="comment">// Returns the i-th test among all the tests. i can range from 0 to</span></div><div class="line"><a name="l04244"></a><span class="lineno"> 4244</span> <span class="comment">// total_test_count() - 1. If i is not in that range, returns NULL.</span></div><div class="line"><a name="l04245"></a><span class="lineno"> 4245</span> TestInfo* TestSuite::GetMutableTestInfo(<span class="keywordtype">int</span> i) {</div><div class="line"><a name="l04246"></a><span class="lineno"> 4246</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> index = GetElementOr(test_indices_, i, -1);</div><div class="line"><a name="l04247"></a><span class="lineno"> 4247</span>  <span class="keywordflow">return</span> index < 0 ? nullptr : test_info_list_[index];</div><div class="line"><a name="l04248"></a><span class="lineno"> 4248</span> }</div><div class="line"><a name="l04249"></a><span class="lineno"> 4249</span> </div><div class="line"><a name="l04250"></a><span class="lineno"> 4250</span> <span class="comment">// Adds a test to this test suite. Will delete the test upon</span></div><div class="line"><a name="l04251"></a><span class="lineno"> 4251</span> <span class="comment">// destruction of the TestSuite object.</span></div><div class="line"><a name="l04252"></a><span class="lineno"> 4252</span> <span class="keywordtype">void</span> TestSuite::AddTestInfo(TestInfo* test_info) {</div><div class="line"><a name="l04253"></a><span class="lineno"> 4253</span>  test_info_list_.push_back(test_info);</div><div class="line"><a name="l04254"></a><span class="lineno"> 4254</span>  test_indices_.push_back(static_cast<int>(test_indices_.size()));</div><div class="line"><a name="l04255"></a><span class="lineno"> 4255</span> }</div><div class="line"><a name="l04256"></a><span class="lineno"> 4256</span> </div><div class="line"><a name="l04257"></a><span class="lineno"> 4257</span> <span class="comment">// Runs every test in this TestSuite.</span></div><div class="line"><a name="l04258"></a><span class="lineno"> 4258</span> <span class="keywordtype">void</span> TestSuite::Run() {</div><div class="line"><a name="l04259"></a><span class="lineno"> 4259</span>  <span class="keywordflow">if</span> (!should_run_) <span class="keywordflow">return</span>;</div><div class="line"><a name="l04260"></a><span class="lineno"> 4260</span> </div><div class="line"><a name="l04261"></a><span class="lineno"> 4261</span>  internal::UnitTestImpl* <span class="keyword">const</span> impl = internal::GetUnitTestImpl();</div><div class="line"><a name="l04262"></a><span class="lineno"> 4262</span>  impl->set_current_test_suite(<span class="keyword">this</span>);</div><div class="line"><a name="l04263"></a><span class="lineno"> 4263</span> </div><div class="line"><a name="l04264"></a><span class="lineno"> 4264</span>  TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();</div><div class="line"><a name="l04265"></a><span class="lineno"> 4265</span> </div><div class="line"><a name="l04266"></a><span class="lineno"> 4266</span>  <span class="comment">// Call both legacy and the new API</span></div><div class="line"><a name="l04267"></a><span class="lineno"> 4267</span>  repeater->OnTestSuiteStart(*<span class="keyword">this</span>);</div><div class="line"><a name="l04268"></a><span class="lineno"> 4268</span> <span class="comment">// Legacy API is deprecated but still available</span></div><div class="line"><a name="l04269"></a><span class="lineno"> 4269</span> <span class="preprocessor">#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI</span></div><div class="line"><a name="l04270"></a><span class="lineno"> 4270</span>  repeater->OnTestCaseStart(*<span class="keyword">this</span>);</div><div class="line"><a name="l04271"></a><span class="lineno"> 4271</span> <span class="preprocessor">#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI</span></div><div class="line"><a name="l04272"></a><span class="lineno"> 4272</span> </div><div class="line"><a name="l04273"></a><span class="lineno"> 4273</span>  impl->os_stack_trace_getter()->UponLeavingGTest();</div><div class="line"><a name="l04274"></a><span class="lineno"> 4274</span>  internal::HandleExceptionsInMethodIfSupported(</div><div class="line"><a name="l04275"></a><span class="lineno"> 4275</span>  <span class="keyword">this</span>, &TestSuite::RunSetUpTestSuite, <span class="stringliteral">"SetUpTestSuite()"</span>);</div><div class="line"><a name="l04276"></a><span class="lineno"> 4276</span> </div><div class="line"><a name="l04277"></a><span class="lineno"> 4277</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a66a845df404b38fe85c5e14a069f255a">internal::TimeInMillis</a> start = internal::GetTimeInMillis();</div><div class="line"><a name="l04278"></a><span class="lineno"> 4278</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < total_test_count(); i++) {</div><div class="line"><a name="l04279"></a><span class="lineno"> 4279</span>  GetMutableTestInfo(i)->Run();</div><div class="line"><a name="l04280"></a><span class="lineno"> 4280</span>  }</div><div class="line"><a name="l04281"></a><span class="lineno"> 4281</span>  elapsed_time_ = internal::GetTimeInMillis() - start;</div><div class="line"><a name="l04282"></a><span class="lineno"> 4282</span> </div><div class="line"><a name="l04283"></a><span class="lineno"> 4283</span>  impl->os_stack_trace_getter()->UponLeavingGTest();</div><div class="line"><a name="l04284"></a><span class="lineno"> 4284</span>  internal::HandleExceptionsInMethodIfSupported(</div><div class="line"><a name="l04285"></a><span class="lineno"> 4285</span>  <span class="keyword">this</span>, &TestSuite::RunTearDownTestSuite, <span class="stringliteral">"TearDownTestSuite()"</span>);</div><div class="line"><a name="l04286"></a><span class="lineno"> 4286</span> </div><div class="line"><a name="l04287"></a><span class="lineno"> 4287</span>  <span class="comment">// Call both legacy and the new API</span></div><div class="line"><a name="l04288"></a><span class="lineno"> 4288</span>  repeater->OnTestSuiteEnd(*<span class="keyword">this</span>);</div><div class="line"><a name="l04289"></a><span class="lineno"> 4289</span> <span class="comment">// Legacy API is deprecated but still available</span></div><div class="line"><a name="l04290"></a><span class="lineno"> 4290</span> <span class="preprocessor">#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI</span></div><div class="line"><a name="l04291"></a><span class="lineno"> 4291</span>  repeater->OnTestCaseEnd(*<span class="keyword">this</span>);</div><div class="line"><a name="l04292"></a><span class="lineno"> 4292</span> <span class="preprocessor">#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI</span></div><div class="line"><a name="l04293"></a><span class="lineno"> 4293</span> </div><div class="line"><a name="l04294"></a><span class="lineno"> 4294</span>  impl->set_current_test_suite(<span class="keyword">nullptr</span>);</div><div class="line"><a name="l04295"></a><span class="lineno"> 4295</span> }</div><div class="line"><a name="l04296"></a><span class="lineno"> 4296</span> </div><div class="line"><a name="l04297"></a><span class="lineno"> 4297</span> <span class="comment">// Clears the results of all tests in this test suite.</span></div><div class="line"><a name="l04298"></a><span class="lineno"> 4298</span> <span class="keywordtype">void</span> TestSuite::ClearResult() {</div><div class="line"><a name="l04299"></a><span class="lineno"> 4299</span>  ad_hoc_test_result_.Clear();</div><div class="line"><a name="l04300"></a><span class="lineno"> 4300</span>  ForEach(test_info_list_, TestInfo::ClearTestResult);</div><div class="line"><a name="l04301"></a><span class="lineno"> 4301</span> }</div><div class="line"><a name="l04302"></a><span class="lineno"> 4302</span> </div><div class="line"><a name="l04303"></a><span class="lineno"> 4303</span> <span class="comment">// Shuffles the tests in this test suite.</span></div><div class="line"><a name="l04304"></a><span class="lineno"> 4304</span> <span class="keywordtype">void</span> TestSuite::ShuffleTests(internal::Random* random) {</div><div class="line"><a name="l04305"></a><span class="lineno"> 4305</span>  Shuffle(random, &test_indices_);</div><div class="line"><a name="l04306"></a><span class="lineno"> 4306</span> }</div><div class="line"><a name="l04307"></a><span class="lineno"> 4307</span> </div><div class="line"><a name="l04308"></a><span class="lineno"> 4308</span> <span class="comment">// Restores the test order to before the first shuffle.</span></div><div class="line"><a name="l04309"></a><span class="lineno"> 4309</span> <span class="keywordtype">void</span> TestSuite::UnshuffleTests() {</div><div class="line"><a name="l04310"></a><span class="lineno"> 4310</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i < test_indices_.size(); i++) {</div><div class="line"><a name="l04311"></a><span class="lineno"> 4311</span>  test_indices_[i] = <span class="keyword">static_cast<</span><span class="keywordtype">int</span><span class="keyword">></span>(i);</div><div class="line"><a name="l04312"></a><span class="lineno"> 4312</span>  }</div><div class="line"><a name="l04313"></a><span class="lineno"> 4313</span> }</div><div class="line"><a name="l04314"></a><span class="lineno"> 4314</span> </div><div class="line"><a name="l04315"></a><span class="lineno"> 4315</span> <span class="comment">// Formats a countable noun. Depending on its quantity, either the</span></div><div class="line"><a name="l04316"></a><span class="lineno"> 4316</span> <span class="comment">// singular form or the plural form is used. e.g.</span></div><div class="line"><a name="l04317"></a><span class="lineno"> 4317</span> <span class="comment">//</span></div><div class="line"><a name="l04318"></a><span class="lineno"> 4318</span> <span class="comment">// FormatCountableNoun(1, "formula", "formuli") returns "1 formula".</span></div><div class="line"><a name="l04319"></a><span class="lineno"> 4319</span> <span class="comment">// FormatCountableNoun(5, "book", "books") returns "5 books".</span></div><div class="line"><a name="l04320"></a><span class="lineno"> 4320</span> <span class="keyword">static</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> FormatCountableNoun(<span class="keywordtype">int</span> <a class="code" href="namespaceutl_1_1meta.html#ab5508236016638fa8e6b97cd17dfc9c2">count</a>,</div><div class="line"><a name="l04321"></a><span class="lineno"> 4321</span>  <span class="keyword">const</span> <span class="keywordtype">char</span> * singular_form,</div><div class="line"><a name="l04322"></a><span class="lineno"> 4322</span>  <span class="keyword">const</span> <span class="keywordtype">char</span> * plural_form) {</div><div class="line"><a name="l04323"></a><span class="lineno"> 4323</span>  <span class="keywordflow">return</span> <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">internal::StreamableToString</a>(<a class="code" href="namespaceutl_1_1meta.html#ab5508236016638fa8e6b97cd17dfc9c2">count</a>) + <span class="stringliteral">" "</span> +</div><div class="line"><a name="l04324"></a><span class="lineno"> 4324</span>  (<a class="code" href="namespaceutl_1_1meta.html#ab5508236016638fa8e6b97cd17dfc9c2">count</a> == 1 ? singular_form : plural_form);</div><div class="line"><a name="l04325"></a><span class="lineno"> 4325</span> }</div><div class="line"><a name="l04326"></a><span class="lineno"> 4326</span> </div><div class="line"><a name="l04327"></a><span class="lineno"> 4327</span> <span class="comment">// Formats the count of tests.</span></div><div class="line"><a name="l04328"></a><span class="lineno"> 4328</span> <span class="keyword">static</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> FormatTestCount(<span class="keywordtype">int</span> test_count) {</div><div class="line"><a name="l04329"></a><span class="lineno"> 4329</span>  <span class="keywordflow">return</span> FormatCountableNoun(test_count, <span class="stringliteral">"test"</span>, <span class="stringliteral">"tests"</span>);</div><div class="line"><a name="l04330"></a><span class="lineno"> 4330</span> }</div><div class="line"><a name="l04331"></a><span class="lineno"> 4331</span> </div><div class="line"><a name="l04332"></a><span class="lineno"> 4332</span> <span class="comment">// Formats the count of test suites.</span></div><div class="line"><a name="l04333"></a><span class="lineno"> 4333</span> <span class="keyword">static</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> FormatTestSuiteCount(<span class="keywordtype">int</span> test_suite_count) {</div><div class="line"><a name="l04334"></a><span class="lineno"> 4334</span>  <span class="keywordflow">return</span> FormatCountableNoun(test_suite_count, <span class="stringliteral">"test suite"</span>, <span class="stringliteral">"test suites"</span>);</div><div class="line"><a name="l04335"></a><span class="lineno"> 4335</span> }</div><div class="line"><a name="l04336"></a><span class="lineno"> 4336</span> </div><div class="line"><a name="l04337"></a><span class="lineno"> 4337</span> <span class="comment">// Converts a TestPartResult::Type enum to human-friendly string</span></div><div class="line"><a name="l04338"></a><span class="lineno"> 4338</span> <span class="comment">// representation. Both kNonFatalFailure and kFatalFailure are translated</span></div><div class="line"><a name="l04339"></a><span class="lineno"> 4339</span> <span class="comment">// to "Failure", as the user usually doesn't care about the difference</span></div><div class="line"><a name="l04340"></a><span class="lineno"> 4340</span> <span class="comment">// between the two when viewing the test result.</span></div><div class="line"><a name="l04341"></a><span class="lineno"> 4341</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> * TestPartResultTypeToString(TestPartResult::Type type) {</div><div class="line"><a name="l04342"></a><span class="lineno"> 4342</span>  <span class="keywordflow">switch</span> (type) {</div><div class="line"><a name="l04343"></a><span class="lineno"> 4343</span>  <span class="keywordflow">case</span> TestPartResult::kSkip:</div><div class="line"><a name="l04344"></a><span class="lineno"> 4344</span>  <span class="keywordflow">return</span> <span class="stringliteral">"Skipped"</span>;</div><div class="line"><a name="l04345"></a><span class="lineno"> 4345</span>  <span class="keywordflow">case</span> TestPartResult::kSuccess:</div><div class="line"><a name="l04346"></a><span class="lineno"> 4346</span>  <span class="keywordflow">return</span> <span class="stringliteral">"Success"</span>;</div><div class="line"><a name="l04347"></a><span class="lineno"> 4347</span> </div><div class="line"><a name="l04348"></a><span class="lineno"> 4348</span>  <span class="keywordflow">case</span> TestPartResult::kNonFatalFailure:</div><div class="line"><a name="l04349"></a><span class="lineno"> 4349</span>  <span class="keywordflow">case</span> TestPartResult::kFatalFailure:</div><div class="line"><a name="l04350"></a><span class="lineno"> 4350</span> <span class="preprocessor">#ifdef _MSC_VER</span></div><div class="line"><a name="l04351"></a><span class="lineno"> 4351</span>  <span class="keywordflow">return</span> <span class="stringliteral">"error: "</span>;</div><div class="line"><a name="l04352"></a><span class="lineno"> 4352</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l04353"></a><span class="lineno"> 4353</span>  <span class="keywordflow">return</span> <span class="stringliteral">"Failure\n"</span>;</div><div class="line"><a name="l04354"></a><span class="lineno"> 4354</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l04355"></a><span class="lineno"> 4355</span>  <span class="keywordflow">default</span>:</div><div class="line"><a name="l04356"></a><span class="lineno"> 4356</span>  <span class="keywordflow">return</span> <span class="stringliteral">"Unknown result type"</span>;</div><div class="line"><a name="l04357"></a><span class="lineno"> 4357</span>  }</div><div class="line"><a name="l04358"></a><span class="lineno"> 4358</span> }</div><div class="line"><a name="l04359"></a><span class="lineno"> 4359</span> </div><div class="line"><a name="l04360"></a><span class="lineno"> 4360</span> <span class="keyword">namespace </span>internal {</div><div class="line"><a name="l04361"></a><span class="lineno"> 4361</span> </div><div class="line"><a name="l04362"></a><span class="lineno"> 4362</span> <span class="comment">// Prints a TestPartResult to an std::string.</span></div><div class="line"><a name="l04363"></a><span class="lineno"> 4363</span> <span class="keyword">static</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> PrintTestPartResultToString(</div><div class="line"><a name="l04364"></a><span class="lineno"> 4364</span>  <span class="keyword">const</span> TestPartResult& test_part_result) {</div><div class="line"><a name="l04365"></a><span class="lineno"> 4365</span>  <span class="keywordflow">return</span> (Message()</div><div class="line"><a name="l04366"></a><span class="lineno"> 4366</span>  << <a class="code" href="namespacetesting_1_1internal.html#a31b7c3abed4a7c395f42c61e993989f4">internal::FormatFileLocation</a>(test_part_result.file_name(),</div><div class="line"><a name="l04367"></a><span class="lineno"> 4367</span>  test_part_result.line_number())</div><div class="line"><a name="l04368"></a><span class="lineno"> 4368</span>  << <span class="stringliteral">" "</span> << TestPartResultTypeToString(test_part_result.type())</div><div class="line"><a name="l04369"></a><span class="lineno"> 4369</span>  << test_part_result.message()).GetString();</div><div class="line"><a name="l04370"></a><span class="lineno"> 4370</span> }</div><div class="line"><a name="l04371"></a><span class="lineno"> 4371</span> </div><div class="line"><a name="l04372"></a><span class="lineno"> 4372</span> <span class="comment">// Prints a TestPartResult.</span></div><div class="line"><a name="l04373"></a><span class="lineno"> 4373</span> <span class="keyword">static</span> <span class="keywordtype">void</span> PrintTestPartResult(<span class="keyword">const</span> TestPartResult& test_part_result) {</div><div class="line"><a name="l04374"></a><span class="lineno"> 4374</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& result =</div><div class="line"><a name="l04375"></a><span class="lineno"> 4375</span>  PrintTestPartResultToString(test_part_result);</div><div class="line"><a name="l04376"></a><span class="lineno"> 4376</span>  printf(<span class="stringliteral">"%s\n"</span>, result.c_str());</div><div class="line"><a name="l04377"></a><span class="lineno"> 4377</span>  fflush(stdout);</div><div class="line"><a name="l04378"></a><span class="lineno"> 4378</span>  <span class="comment">// If the test program runs in Visual Studio or a debugger, the</span></div><div class="line"><a name="l04379"></a><span class="lineno"> 4379</span>  <span class="comment">// following statements add the test part result message to the Output</span></div><div class="line"><a name="l04380"></a><span class="lineno"> 4380</span>  <span class="comment">// window such that the user can double-click on it to jump to the</span></div><div class="line"><a name="l04381"></a><span class="lineno"> 4381</span>  <span class="comment">// corresponding source code location; otherwise they do nothing.</span></div><div class="line"><a name="l04382"></a><span class="lineno"> 4382</span> <span class="preprocessor">#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE</span></div><div class="line"><a name="l04383"></a><span class="lineno"> 4383</span>  <span class="comment">// We don't call OutputDebugString*() on Windows Mobile, as printing</span></div><div class="line"><a name="l04384"></a><span class="lineno"> 4384</span>  <span class="comment">// to stdout is done by OutputDebugString() there already - we don't</span></div><div class="line"><a name="l04385"></a><span class="lineno"> 4385</span>  <span class="comment">// want the same message printed twice.</span></div><div class="line"><a name="l04386"></a><span class="lineno"> 4386</span>  ::OutputDebugStringA(result.c_str());</div><div class="line"><a name="l04387"></a><span class="lineno"> 4387</span>  ::OutputDebugStringA(<span class="stringliteral">"\n"</span>);</div><div class="line"><a name="l04388"></a><span class="lineno"> 4388</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l04389"></a><span class="lineno"> 4389</span> }</div><div class="line"><a name="l04390"></a><span class="lineno"> 4390</span> </div><div class="line"><a name="l04391"></a><span class="lineno"> 4391</span> <span class="comment">// class PrettyUnitTestResultPrinter</span></div><div class="line"><a name="l04392"></a><span class="lineno"> 4392</span> <span class="preprocessor">#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && \</span></div><div class="line"><a name="l04393"></a><span class="lineno"> 4393</span> <span class="preprocessor"> !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT && !GTEST_OS_WINDOWS_MINGW</span></div><div class="line"><a name="l04394"></a><span class="lineno"> 4394</span> </div><div class="line"><a name="l04395"></a><span class="lineno"> 4395</span> <span class="comment">// Returns the character attribute for the given color.</span></div><div class="line"><a name="l04396"></a><span class="lineno"> 4396</span> <span class="keyword">static</span> WORD GetColorAttribute(<a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4e">GTestColor</a> color) {</div><div class="line"><a name="l04397"></a><span class="lineno"> 4397</span>  <span class="keywordflow">switch</span> (color) {</div><div class="line"><a name="l04398"></a><span class="lineno"> 4398</span>  <span class="keywordflow">case</span> <a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea9ebb3ddab9391781f6ee5021e1e443c3">COLOR_RED</a>: <span class="keywordflow">return</span> FOREGROUND_RED;</div><div class="line"><a name="l04399"></a><span class="lineno"> 4399</span>  <span class="keywordflow">case</span> <a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea3b1e81f5b14a17b35a8672d57d166507">COLOR_GREEN</a>: <span class="keywordflow">return</span> FOREGROUND_GREEN;</div><div class="line"><a name="l04400"></a><span class="lineno"> 4400</span>  <span class="keywordflow">case</span> <a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea2cca441161aca75a208ff08d07f5b1a5">COLOR_YELLOW</a>: <span class="keywordflow">return</span> FOREGROUND_RED | FOREGROUND_GREEN;</div><div class="line"><a name="l04401"></a><span class="lineno"> 4401</span>  <span class="keywordflow">default</span>: <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l04402"></a><span class="lineno"> 4402</span>  }</div><div class="line"><a name="l04403"></a><span class="lineno"> 4403</span> }</div><div class="line"><a name="l04404"></a><span class="lineno"> 4404</span> </div><div class="line"><a name="l04405"></a><span class="lineno"> 4405</span> <span class="keyword">static</span> <span class="keywordtype">int</span> GetBitOffset(WORD color_mask) {</div><div class="line"><a name="l04406"></a><span class="lineno"> 4406</span>  <span class="keywordflow">if</span> (color_mask == 0) <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l04407"></a><span class="lineno"> 4407</span> </div><div class="line"><a name="l04408"></a><span class="lineno"> 4408</span>  <span class="keywordtype">int</span> bitOffset = 0;</div><div class="line"><a name="l04409"></a><span class="lineno"> 4409</span>  <span class="keywordflow">while</span> ((color_mask & 1) == 0) {</div><div class="line"><a name="l04410"></a><span class="lineno"> 4410</span>  color_mask >>= 1;</div><div class="line"><a name="l04411"></a><span class="lineno"> 4411</span>  ++bitOffset;</div><div class="line"><a name="l04412"></a><span class="lineno"> 4412</span>  }</div><div class="line"><a name="l04413"></a><span class="lineno"> 4413</span>  <span class="keywordflow">return</span> bitOffset;</div><div class="line"><a name="l04414"></a><span class="lineno"> 4414</span> }</div><div class="line"><a name="l04415"></a><span class="lineno"> 4415</span> </div><div class="line"><a name="l04416"></a><span class="lineno"> 4416</span> <span class="keyword">static</span> WORD GetNewColor(<a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4e">GTestColor</a> color, WORD old_color_attrs) {</div><div class="line"><a name="l04417"></a><span class="lineno"> 4417</span>  <span class="comment">// Let's reuse the BG</span></div><div class="line"><a name="l04418"></a><span class="lineno"> 4418</span>  <span class="keyword">static</span> <span class="keyword">const</span> WORD background_mask = BACKGROUND_BLUE | BACKGROUND_GREEN |</div><div class="line"><a name="l04419"></a><span class="lineno"> 4419</span>  BACKGROUND_RED | BACKGROUND_INTENSITY;</div><div class="line"><a name="l04420"></a><span class="lineno"> 4420</span>  <span class="keyword">static</span> <span class="keyword">const</span> WORD foreground_mask = FOREGROUND_BLUE | FOREGROUND_GREEN |</div><div class="line"><a name="l04421"></a><span class="lineno"> 4421</span>  FOREGROUND_RED | FOREGROUND_INTENSITY;</div><div class="line"><a name="l04422"></a><span class="lineno"> 4422</span>  <span class="keyword">const</span> WORD existing_bg = old_color_attrs & background_mask;</div><div class="line"><a name="l04423"></a><span class="lineno"> 4423</span> </div><div class="line"><a name="l04424"></a><span class="lineno"> 4424</span>  WORD new_color =</div><div class="line"><a name="l04425"></a><span class="lineno"> 4425</span>  GetColorAttribute(color) | existing_bg | FOREGROUND_INTENSITY;</div><div class="line"><a name="l04426"></a><span class="lineno"> 4426</span>  <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> bg_bitOffset = GetBitOffset(background_mask);</div><div class="line"><a name="l04427"></a><span class="lineno"> 4427</span>  <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> fg_bitOffset = GetBitOffset(foreground_mask);</div><div class="line"><a name="l04428"></a><span class="lineno"> 4428</span> </div><div class="line"><a name="l04429"></a><span class="lineno"> 4429</span>  <span class="keywordflow">if</span> (((new_color & background_mask) >> bg_bitOffset) ==</div><div class="line"><a name="l04430"></a><span class="lineno"> 4430</span>  ((new_color & foreground_mask) >> fg_bitOffset)) {</div><div class="line"><a name="l04431"></a><span class="lineno"> 4431</span>  new_color ^= FOREGROUND_INTENSITY; <span class="comment">// invert intensity</span></div><div class="line"><a name="l04432"></a><span class="lineno"> 4432</span>  }</div><div class="line"><a name="l04433"></a><span class="lineno"> 4433</span>  <span class="keywordflow">return</span> new_color;</div><div class="line"><a name="l04434"></a><span class="lineno"> 4434</span> }</div><div class="line"><a name="l04435"></a><span class="lineno"> 4435</span> </div><div class="line"><a name="l04436"></a><span class="lineno"> 4436</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l04437"></a><span class="lineno"> 4437</span> </div><div class="line"><a name="l04438"></a><span class="lineno"> 4438</span> <span class="comment">// Returns the ANSI color code for the given color. COLOR_DEFAULT is</span></div><div class="line"><a name="l04439"></a><span class="lineno"> 4439</span> <span class="comment">// an invalid input.</span></div><div class="line"><a name="l04440"></a><span class="lineno"> 4440</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* GetAnsiColorCode(<a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4e">GTestColor</a> color) {</div><div class="line"><a name="l04441"></a><span class="lineno"> 4441</span>  <span class="keywordflow">switch</span> (color) {</div><div class="line"><a name="l04442"></a><span class="lineno"> 4442</span>  <span class="keywordflow">case</span> <a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea9ebb3ddab9391781f6ee5021e1e443c3">COLOR_RED</a>: <span class="keywordflow">return</span> <span class="stringliteral">"1"</span>;</div><div class="line"><a name="l04443"></a><span class="lineno"> 4443</span>  <span class="keywordflow">case</span> <a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea3b1e81f5b14a17b35a8672d57d166507">COLOR_GREEN</a>: <span class="keywordflow">return</span> <span class="stringliteral">"2"</span>;</div><div class="line"><a name="l04444"></a><span class="lineno"> 4444</span>  <span class="keywordflow">case</span> <a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea2cca441161aca75a208ff08d07f5b1a5">COLOR_YELLOW</a>: <span class="keywordflow">return</span> <span class="stringliteral">"3"</span>;</div><div class="line"><a name="l04445"></a><span class="lineno"> 4445</span>  <span class="keywordflow">default</span>:</div><div class="line"><a name="l04446"></a><span class="lineno"> 4446</span>  <span class="keywordflow">return</span> <span class="keyword">nullptr</span>;</div><div class="line"><a name="l04447"></a><span class="lineno"> 4447</span>  };</div><div class="line"><a name="l04448"></a><span class="lineno"> 4448</span> }</div><div class="line"><a name="l04449"></a><span class="lineno"> 4449</span> </div><div class="line"><a name="l04450"></a><span class="lineno"> 4450</span> <span class="preprocessor">#endif // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE</span></div><div class="line"><a name="l04451"></a><span class="lineno"> 4451</span> </div><div class="line"><a name="l04452"></a><span class="lineno"> 4452</span> <span class="comment">// Returns true iff Google Test should use colors in the output.</span></div><div class="line"><a name="l04453"></a><span class="lineno"> 4453</span> <span class="keywordtype">bool</span> ShouldUseColor(<span class="keywordtype">bool</span> stdout_is_tty) {</div><div class="line"><a name="l04454"></a><span class="lineno"> 4454</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> gtest_color = <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(color).c_str();</div><div class="line"><a name="l04455"></a><span class="lineno"> 4455</span> </div><div class="line"><a name="l04456"></a><span class="lineno"> 4456</span>  <span class="keywordflow">if</span> (String::CaseInsensitiveCStringEquals(gtest_color, <span class="stringliteral">"auto"</span>)) {</div><div class="line"><a name="l04457"></a><span class="lineno"> 4457</span> <span class="preprocessor">#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW</span></div><div class="line"><a name="l04458"></a><span class="lineno"> 4458</span>  <span class="comment">// On Windows the TERM variable is usually not set, but the</span></div><div class="line"><a name="l04459"></a><span class="lineno"> 4459</span>  <span class="comment">// console there does support colors.</span></div><div class="line"><a name="l04460"></a><span class="lineno"> 4460</span>  <span class="keywordflow">return</span> stdout_is_tty;</div><div class="line"><a name="l04461"></a><span class="lineno"> 4461</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l04462"></a><span class="lineno"> 4462</span>  <span class="comment">// On non-Windows platforms, we rely on the TERM variable.</span></div><div class="line"><a name="l04463"></a><span class="lineno"> 4463</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> term = <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a1d5e3da5a27eed25986859fa83cafe95">posix::GetEnv</a>(<span class="stringliteral">"TERM"</span>);</div><div class="line"><a name="l04464"></a><span class="lineno"> 4464</span>  <span class="keyword">const</span> <span class="keywordtype">bool</span> term_supports_color =</div><div class="line"><a name="l04465"></a><span class="lineno"> 4465</span>  String::CStringEquals(term, <span class="stringliteral">"xterm"</span>) ||</div><div class="line"><a name="l04466"></a><span class="lineno"> 4466</span>  String::CStringEquals(term, <span class="stringliteral">"xterm-color"</span>) ||</div><div class="line"><a name="l04467"></a><span class="lineno"> 4467</span>  String::CStringEquals(term, <span class="stringliteral">"xterm-256color"</span>) ||</div><div class="line"><a name="l04468"></a><span class="lineno"> 4468</span>  String::CStringEquals(term, <span class="stringliteral">"screen"</span>) ||</div><div class="line"><a name="l04469"></a><span class="lineno"> 4469</span>  String::CStringEquals(term, <span class="stringliteral">"screen-256color"</span>) ||</div><div class="line"><a name="l04470"></a><span class="lineno"> 4470</span>  String::CStringEquals(term, <span class="stringliteral">"tmux"</span>) ||</div><div class="line"><a name="l04471"></a><span class="lineno"> 4471</span>  String::CStringEquals(term, <span class="stringliteral">"tmux-256color"</span>) ||</div><div class="line"><a name="l04472"></a><span class="lineno"> 4472</span>  String::CStringEquals(term, <span class="stringliteral">"rxvt-unicode"</span>) ||</div><div class="line"><a name="l04473"></a><span class="lineno"> 4473</span>  String::CStringEquals(term, <span class="stringliteral">"rxvt-unicode-256color"</span>) ||</div><div class="line"><a name="l04474"></a><span class="lineno"> 4474</span>  String::CStringEquals(term, <span class="stringliteral">"linux"</span>) ||</div><div class="line"><a name="l04475"></a><span class="lineno"> 4475</span>  String::CStringEquals(term, <span class="stringliteral">"cygwin"</span>);</div><div class="line"><a name="l04476"></a><span class="lineno"> 4476</span>  <span class="keywordflow">return</span> stdout_is_tty && term_supports_color;</div><div class="line"><a name="l04477"></a><span class="lineno"> 4477</span> <span class="preprocessor">#endif // GTEST_OS_WINDOWS</span></div><div class="line"><a name="l04478"></a><span class="lineno"> 4478</span>  }</div><div class="line"><a name="l04479"></a><span class="lineno"> 4479</span> </div><div class="line"><a name="l04480"></a><span class="lineno"> 4480</span>  <span class="keywordflow">return</span> String::CaseInsensitiveCStringEquals(gtest_color, <span class="stringliteral">"yes"</span>) ||</div><div class="line"><a name="l04481"></a><span class="lineno"> 4481</span>  String::CaseInsensitiveCStringEquals(gtest_color, <span class="stringliteral">"true"</span>) ||</div><div class="line"><a name="l04482"></a><span class="lineno"> 4482</span>  String::CaseInsensitiveCStringEquals(gtest_color, <span class="stringliteral">"t"</span>) ||</div><div class="line"><a name="l04483"></a><span class="lineno"> 4483</span>  String::CStringEquals(gtest_color, <span class="stringliteral">"1"</span>);</div><div class="line"><a name="l04484"></a><span class="lineno"> 4484</span>  <span class="comment">// We take "yes", "true", "t", and "1" as meaning "yes". If the</span></div><div class="line"><a name="l04485"></a><span class="lineno"> 4485</span>  <span class="comment">// value is neither one of these nor "auto", we treat it as "no" to</span></div><div class="line"><a name="l04486"></a><span class="lineno"> 4486</span>  <span class="comment">// be conservative.</span></div><div class="line"><a name="l04487"></a><span class="lineno"> 4487</span> }</div><div class="line"><a name="l04488"></a><span class="lineno"> 4488</span> </div><div class="line"><a name="l04489"></a><span class="lineno"> 4489</span> <span class="comment">// Helpers for printing colored strings to stdout. Note that on Windows, we</span></div><div class="line"><a name="l04490"></a><span class="lineno"> 4490</span> <span class="comment">// cannot simply emit special characters and have the terminal change colors.</span></div><div class="line"><a name="l04491"></a><span class="lineno"> 4491</span> <span class="comment">// This routine must actually emit the characters rather than return a string</span></div><div class="line"><a name="l04492"></a><span class="lineno"> 4492</span> <span class="comment">// that would be colored when printed, as can be done on Linux.</span></div><div class="line"><a name="l04493"></a><span class="lineno"> 4493</span> <span class="keywordtype">void</span> ColoredPrintf(<a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4e">GTestColor</a> color, <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="namespacetesting_1_1internal.html#a40b2a93ff318f5975eb8246b01221ce8">fmt</a>, ...) {</div><div class="line"><a name="l04494"></a><span class="lineno"> 4494</span>  va_list args;</div><div class="line"><a name="l04495"></a><span class="lineno"> 4495</span>  va_start(args, <a class="code" href="namespacetesting_1_1internal.html#a40b2a93ff318f5975eb8246b01221ce8">fmt</a>);</div><div class="line"><a name="l04496"></a><span class="lineno"> 4496</span> </div><div class="line"><a name="l04497"></a><span class="lineno"> 4497</span> <span class="preprocessor">#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_ZOS || GTEST_OS_IOS || \</span></div><div class="line"><a name="l04498"></a><span class="lineno"> 4498</span> <span class="preprocessor"> GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT</span></div><div class="line"><a name="l04499"></a><span class="lineno"> 4499</span>  <span class="keyword">const</span> <span class="keywordtype">bool</span> use_color = <a class="code" href="namespacetesting_1_1internal.html#a4b24c851ab13569b1b15b3d259b60d2e">AlwaysFalse</a>();</div><div class="line"><a name="l04500"></a><span class="lineno"> 4500</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l04501"></a><span class="lineno"> 4501</span>  <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">bool</span> in_color_mode =</div><div class="line"><a name="l04502"></a><span class="lineno"> 4502</span>  ShouldUseColor(<a class="code" href="namespacetesting_1_1internal_1_1posix.html#a16ebe936b3a8ea462a94191635aedc27">posix::IsATTY</a>(<a class="code" href="namespacetesting_1_1internal_1_1posix.html#a3117b067e1f942a2031e666953120ccc">posix::FileNo</a>(stdout)) != 0);</div><div class="line"><a name="l04503"></a><span class="lineno"> 4503</span>  <span class="keyword">const</span> <span class="keywordtype">bool</span> use_color = in_color_mode && (color != <a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4eafcd8803dc9e37e374d5a4486afc230b7">COLOR_DEFAULT</a>);</div><div class="line"><a name="l04504"></a><span class="lineno"> 4504</span> <span class="preprocessor">#endif // GTEST_OS_WINDOWS_MOBILE || GTEST_OS_ZOS</span></div><div class="line"><a name="l04505"></a><span class="lineno"> 4505</span> </div><div class="line"><a name="l04506"></a><span class="lineno"> 4506</span>  <span class="keywordflow">if</span> (!use_color) {</div><div class="line"><a name="l04507"></a><span class="lineno"> 4507</span>  vprintf(<a class="code" href="namespacetesting_1_1internal.html#a40b2a93ff318f5975eb8246b01221ce8">fmt</a>, args);</div><div class="line"><a name="l04508"></a><span class="lineno"> 4508</span>  va_end(args);</div><div class="line"><a name="l04509"></a><span class="lineno"> 4509</span>  <span class="keywordflow">return</span>;</div><div class="line"><a name="l04510"></a><span class="lineno"> 4510</span>  }</div><div class="line"><a name="l04511"></a><span class="lineno"> 4511</span> </div><div class="line"><a name="l04512"></a><span class="lineno"> 4512</span> <span class="preprocessor">#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && \</span></div><div class="line"><a name="l04513"></a><span class="lineno"> 4513</span> <span class="preprocessor"> !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT && !GTEST_OS_WINDOWS_MINGW</span></div><div class="line"><a name="l04514"></a><span class="lineno"> 4514</span>  <span class="keyword">const</span> HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);</div><div class="line"><a name="l04515"></a><span class="lineno"> 4515</span> </div><div class="line"><a name="l04516"></a><span class="lineno"> 4516</span>  <span class="comment">// Gets the current text color.</span></div><div class="line"><a name="l04517"></a><span class="lineno"> 4517</span>  CONSOLE_SCREEN_BUFFER_INFO buffer_info;</div><div class="line"><a name="l04518"></a><span class="lineno"> 4518</span>  GetConsoleScreenBufferInfo(stdout_handle, &buffer_info);</div><div class="line"><a name="l04519"></a><span class="lineno"> 4519</span>  <span class="keyword">const</span> WORD old_color_attrs = buffer_info.wAttributes;</div><div class="line"><a name="l04520"></a><span class="lineno"> 4520</span>  <span class="keyword">const</span> WORD new_color = GetNewColor(color, old_color_attrs);</div><div class="line"><a name="l04521"></a><span class="lineno"> 4521</span> </div><div class="line"><a name="l04522"></a><span class="lineno"> 4522</span>  <span class="comment">// We need to flush the stream buffers into the console before each</span></div><div class="line"><a name="l04523"></a><span class="lineno"> 4523</span>  <span class="comment">// SetConsoleTextAttribute call lest it affect the text that is already</span></div><div class="line"><a name="l04524"></a><span class="lineno"> 4524</span>  <span class="comment">// printed but has not yet reached the console.</span></div><div class="line"><a name="l04525"></a><span class="lineno"> 4525</span>  fflush(stdout);</div><div class="line"><a name="l04526"></a><span class="lineno"> 4526</span>  SetConsoleTextAttribute(stdout_handle, new_color);</div><div class="line"><a name="l04527"></a><span class="lineno"> 4527</span> </div><div class="line"><a name="l04528"></a><span class="lineno"> 4528</span>  vprintf(<a class="code" href="namespacetesting_1_1internal.html#a40b2a93ff318f5975eb8246b01221ce8">fmt</a>, args);</div><div class="line"><a name="l04529"></a><span class="lineno"> 4529</span> </div><div class="line"><a name="l04530"></a><span class="lineno"> 4530</span>  fflush(stdout);</div><div class="line"><a name="l04531"></a><span class="lineno"> 4531</span>  <span class="comment">// Restores the text color.</span></div><div class="line"><a name="l04532"></a><span class="lineno"> 4532</span>  SetConsoleTextAttribute(stdout_handle, old_color_attrs);</div><div class="line"><a name="l04533"></a><span class="lineno"> 4533</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l04534"></a><span class="lineno"> 4534</span>  printf(<span class="stringliteral">"\033[0;3%sm"</span>, GetAnsiColorCode(color));</div><div class="line"><a name="l04535"></a><span class="lineno"> 4535</span>  vprintf(<a class="code" href="namespacetesting_1_1internal.html#a40b2a93ff318f5975eb8246b01221ce8">fmt</a>, args);</div><div class="line"><a name="l04536"></a><span class="lineno"> 4536</span>  printf(<span class="stringliteral">"\033[m"</span>); <span class="comment">// Resets the terminal to default.</span></div><div class="line"><a name="l04537"></a><span class="lineno"> 4537</span> <span class="preprocessor">#endif // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE</span></div><div class="line"><a name="l04538"></a><span class="lineno"> 4538</span>  va_end(args);</div><div class="line"><a name="l04539"></a><span class="lineno"> 4539</span> }</div><div class="line"><a name="l04540"></a><span class="lineno"> 4540</span> </div><div class="line"><a name="l04541"></a><span class="lineno"> 4541</span> <span class="comment">// Text printed in Google Test's text output and --gtest_list_tests</span></div><div class="line"><a name="l04542"></a><span class="lineno"> 4542</span> <span class="comment">// output to label the type parameter and value parameter for a test.</span></div><div class="line"><a name="l04543"></a><span class="lineno"> 4543</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kTypeParamLabel[] = <span class="stringliteral">"TypeParam"</span>;</div><div class="line"><a name="l04544"></a><span class="lineno"> 4544</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kValueParamLabel[] = <span class="stringliteral">"GetParam()"</span>;</div><div class="line"><a name="l04545"></a><span class="lineno"> 4545</span> </div><div class="line"><a name="l04546"></a><span class="lineno"> 4546</span> <span class="keyword">static</span> <span class="keywordtype">void</span> PrintFullTestCommentIfPresent(<span class="keyword">const</span> TestInfo& test_info) {</div><div class="line"><a name="l04547"></a><span class="lineno"> 4547</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> type_param = test_info.type_param();</div><div class="line"><a name="l04548"></a><span class="lineno"> 4548</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> value_param = test_info.value_param();</div><div class="line"><a name="l04549"></a><span class="lineno"> 4549</span> </div><div class="line"><a name="l04550"></a><span class="lineno"> 4550</span>  <span class="keywordflow">if</span> (type_param != <span class="keyword">nullptr</span> || value_param != <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l04551"></a><span class="lineno"> 4551</span>  printf(<span class="stringliteral">", where "</span>);</div><div class="line"><a name="l04552"></a><span class="lineno"> 4552</span>  <span class="keywordflow">if</span> (type_param != <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l04553"></a><span class="lineno"> 4553</span>  printf(<span class="stringliteral">"%s = %s"</span>, kTypeParamLabel, type_param);</div><div class="line"><a name="l04554"></a><span class="lineno"> 4554</span>  <span class="keywordflow">if</span> (value_param != <span class="keyword">nullptr</span>) printf(<span class="stringliteral">" and "</span>);</div><div class="line"><a name="l04555"></a><span class="lineno"> 4555</span>  }</div><div class="line"><a name="l04556"></a><span class="lineno"> 4556</span>  <span class="keywordflow">if</span> (value_param != <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l04557"></a><span class="lineno"> 4557</span>  printf(<span class="stringliteral">"%s = %s"</span>, kValueParamLabel, value_param);</div><div class="line"><a name="l04558"></a><span class="lineno"> 4558</span>  }</div><div class="line"><a name="l04559"></a><span class="lineno"> 4559</span>  }</div><div class="line"><a name="l04560"></a><span class="lineno"> 4560</span> }</div><div class="line"><a name="l04561"></a><span class="lineno"> 4561</span> </div><div class="line"><a name="l04562"></a><span class="lineno"> 4562</span> <span class="comment">// This class implements the TestEventListener interface.</span></div><div class="line"><a name="l04563"></a><span class="lineno"> 4563</span> <span class="comment">//</span></div><div class="line"><a name="l04564"></a><span class="lineno"> 4564</span> <span class="comment">// Class PrettyUnitTestResultPrinter is copyable.</span></div><div class="line"><a name="l04565"></a><span class="lineno"> 4565</span> <span class="keyword">class </span>PrettyUnitTestResultPrinter : <span class="keyword">public</span> TestEventListener {</div><div class="line"><a name="l04566"></a><span class="lineno"> 4566</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l04567"></a><span class="lineno"> 4567</span>  PrettyUnitTestResultPrinter() {}</div><div class="line"><a name="l04568"></a><span class="lineno"> 4568</span>  <span class="keyword">static</span> <span class="keywordtype">void</span> PrintTestName(<span class="keyword">const</span> <span class="keywordtype">char</span>* test_suite, <span class="keyword">const</span> <span class="keywordtype">char</span>* test) {</div><div class="line"><a name="l04569"></a><span class="lineno"> 4569</span>  printf(<span class="stringliteral">"%s.%s"</span>, test_suite, test);</div><div class="line"><a name="l04570"></a><span class="lineno"> 4570</span>  }</div><div class="line"><a name="l04571"></a><span class="lineno"> 4571</span> </div><div class="line"><a name="l04572"></a><span class="lineno"> 4572</span>  <span class="comment">// The following methods override what's in the TestEventListener class.</span></div><div class="line"><a name="l04573"></a><span class="lineno"> 4573</span>  <span class="keywordtype">void</span> OnTestProgramStart(<span class="keyword">const</span> UnitTest& <span class="comment">/*unit_test*/</span>)<span class="keyword"> override </span>{}</div><div class="line"><a name="l04574"></a><span class="lineno"> 4574</span>  <span class="keywordtype">void</span> OnTestIterationStart(<span class="keyword">const</span> UnitTest& unit_test, <span class="keywordtype">int</span> iteration) <span class="keyword">override</span>;</div><div class="line"><a name="l04575"></a><span class="lineno"> 4575</span>  <span class="keywordtype">void</span> OnEnvironmentsSetUpStart(<span class="keyword">const</span> UnitTest& unit_test) <span class="keyword">override</span>;</div><div class="line"><a name="l04576"></a><span class="lineno"> 4576</span>  <span class="keywordtype">void</span> OnEnvironmentsSetUpEnd(<span class="keyword">const</span> UnitTest& <span class="comment">/*unit_test*/</span>)<span class="keyword"> override </span>{}</div><div class="line"><a name="l04577"></a><span class="lineno"> 4577</span>  <span class="keywordtype">void</span> OnTestCaseStart(<span class="keyword">const</span> TestSuite& test_suite) <span class="keyword">override</span>;</div><div class="line"><a name="l04578"></a><span class="lineno"> 4578</span>  <span class="keywordtype">void</span> OnTestStart(<span class="keyword">const</span> TestInfo& test_info) <span class="keyword">override</span>;</div><div class="line"><a name="l04579"></a><span class="lineno"> 4579</span>  <span class="keywordtype">void</span> OnTestPartResult(<span class="keyword">const</span> TestPartResult& result) <span class="keyword">override</span>;</div><div class="line"><a name="l04580"></a><span class="lineno"> 4580</span>  <span class="keywordtype">void</span> OnTestEnd(<span class="keyword">const</span> TestInfo& test_info) <span class="keyword">override</span>;</div><div class="line"><a name="l04581"></a><span class="lineno"> 4581</span>  <span class="keywordtype">void</span> OnTestCaseEnd(<span class="keyword">const</span> TestSuite& test_suite) <span class="keyword">override</span>;</div><div class="line"><a name="l04582"></a><span class="lineno"> 4582</span>  <span class="keywordtype">void</span> OnEnvironmentsTearDownStart(<span class="keyword">const</span> UnitTest& unit_test) <span class="keyword">override</span>;</div><div class="line"><a name="l04583"></a><span class="lineno"> 4583</span>  <span class="keywordtype">void</span> OnEnvironmentsTearDownEnd(<span class="keyword">const</span> UnitTest& <span class="comment">/*unit_test*/</span>)<span class="keyword"> override </span>{}</div><div class="line"><a name="l04584"></a><span class="lineno"> 4584</span>  <span class="keywordtype">void</span> OnTestIterationEnd(<span class="keyword">const</span> UnitTest& unit_test, <span class="keywordtype">int</span> iteration) <span class="keyword">override</span>;</div><div class="line"><a name="l04585"></a><span class="lineno"> 4585</span>  <span class="keywordtype">void</span> OnTestProgramEnd(<span class="keyword">const</span> UnitTest& <span class="comment">/*unit_test*/</span>)<span class="keyword"> override </span>{}</div><div class="line"><a name="l04586"></a><span class="lineno"> 4586</span> </div><div class="line"><a name="l04587"></a><span class="lineno"> 4587</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l04588"></a><span class="lineno"> 4588</span>  <span class="keyword">static</span> <span class="keywordtype">void</span> PrintFailedTests(<span class="keyword">const</span> UnitTest& unit_test);</div><div class="line"><a name="l04589"></a><span class="lineno"> 4589</span>  <span class="keyword">static</span> <span class="keywordtype">void</span> PrintSkippedTests(<span class="keyword">const</span> UnitTest& unit_test);</div><div class="line"><a name="l04590"></a><span class="lineno"> 4590</span> };</div><div class="line"><a name="l04591"></a><span class="lineno"> 4591</span> </div><div class="line"><a name="l04592"></a><span class="lineno"> 4592</span>  <span class="comment">// Fired before each iteration of tests starts.</span></div><div class="line"><a name="l04593"></a><span class="lineno"> 4593</span> <span class="keywordtype">void</span> PrettyUnitTestResultPrinter::OnTestIterationStart(</div><div class="line"><a name="l04594"></a><span class="lineno"> 4594</span>  <span class="keyword">const</span> UnitTest& unit_test, <span class="keywordtype">int</span> iteration) {</div><div class="line"><a name="l04595"></a><span class="lineno"> 4595</span>  <span class="keywordflow">if</span> (<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(<a class="code" href="namespaceutl_1_1meta.html#aa013c45afb59b5c132a72be54ba145fb">repeat</a>) != 1)</div><div class="line"><a name="l04596"></a><span class="lineno"> 4596</span>  printf(<span class="stringliteral">"\nRepeating all tests (iteration %d) . . .\n\n"</span>, iteration + 1);</div><div class="line"><a name="l04597"></a><span class="lineno"> 4597</span> </div><div class="line"><a name="l04598"></a><span class="lineno"> 4598</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> <a class="code" href="namespaceutl_1_1meta.html#ac72acc616316c322e750d20a46553ba4">filter</a> = <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(<a class="code" href="namespaceutl_1_1meta.html#ac72acc616316c322e750d20a46553ba4">filter</a>).c_str();</div><div class="line"><a name="l04599"></a><span class="lineno"> 4599</span> </div><div class="line"><a name="l04600"></a><span class="lineno"> 4600</span>  <span class="comment">// Prints the filter if it's not *. This reminds the user that some</span></div><div class="line"><a name="l04601"></a><span class="lineno"> 4601</span>  <span class="comment">// tests may be skipped.</span></div><div class="line"><a name="l04602"></a><span class="lineno"> 4602</span>  <span class="keywordflow">if</span> (!String::CStringEquals(<a class="code" href="namespaceutl_1_1meta.html#ac72acc616316c322e750d20a46553ba4">filter</a>, kUniversalFilter)) {</div><div class="line"><a name="l04603"></a><span class="lineno"> 4603</span>  ColoredPrintf(<a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea2cca441161aca75a208ff08d07f5b1a5">COLOR_YELLOW</a>,</div><div class="line"><a name="l04604"></a><span class="lineno"> 4604</span>  <span class="stringliteral">"Note: %s filter = %s\n"</span>, <a class="code" href="gtest_8h.html#a13d98c217176bd8722c395b9225fc19d">GTEST_NAME_</a>, <a class="code" href="namespaceutl_1_1meta.html#ac72acc616316c322e750d20a46553ba4">filter</a>);</div><div class="line"><a name="l04605"></a><span class="lineno"> 4605</span>  }</div><div class="line"><a name="l04606"></a><span class="lineno"> 4606</span> </div><div class="line"><a name="l04607"></a><span class="lineno"> 4607</span>  <span class="keywordflow">if</span> (internal::ShouldShard(kTestTotalShards, kTestShardIndex, <span class="keyword">false</span>)) {</div><div class="line"><a name="l04608"></a><span class="lineno"> 4608</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8ee38faaf875f133358abaf9bc056cec">Int32</a> shard_index = Int32FromEnvOrDie(kTestShardIndex, -1);</div><div class="line"><a name="l04609"></a><span class="lineno"> 4609</span>  ColoredPrintf(<a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea2cca441161aca75a208ff08d07f5b1a5">COLOR_YELLOW</a>,</div><div class="line"><a name="l04610"></a><span class="lineno"> 4610</span>  <span class="stringliteral">"Note: This is test shard %d of %s.\n"</span>,</div><div class="line"><a name="l04611"></a><span class="lineno"> 4611</span>  static_cast<int>(shard_index) + 1,</div><div class="line"><a name="l04612"></a><span class="lineno"> 4612</span>  <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a1d5e3da5a27eed25986859fa83cafe95">internal::posix::GetEnv</a>(kTestTotalShards));</div><div class="line"><a name="l04613"></a><span class="lineno"> 4613</span>  }</div><div class="line"><a name="l04614"></a><span class="lineno"> 4614</span> </div><div class="line"><a name="l04615"></a><span class="lineno"> 4615</span>  <span class="keywordflow">if</span> (<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(shuffle)) {</div><div class="line"><a name="l04616"></a><span class="lineno"> 4616</span>  ColoredPrintf(<a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea2cca441161aca75a208ff08d07f5b1a5">COLOR_YELLOW</a>,</div><div class="line"><a name="l04617"></a><span class="lineno"> 4617</span>  <span class="stringliteral">"Note: Randomizing tests' orders with a seed of %d .\n"</span>,</div><div class="line"><a name="l04618"></a><span class="lineno"> 4618</span>  unit_test.random_seed());</div><div class="line"><a name="l04619"></a><span class="lineno"> 4619</span>  }</div><div class="line"><a name="l04620"></a><span class="lineno"> 4620</span> </div><div class="line"><a name="l04621"></a><span class="lineno"> 4621</span>  ColoredPrintf(<a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea3b1e81f5b14a17b35a8672d57d166507">COLOR_GREEN</a>, <span class="stringliteral">"[==========] "</span>);</div><div class="line"><a name="l04622"></a><span class="lineno"> 4622</span>  printf(<span class="stringliteral">"Running %s from %s.\n"</span>,</div><div class="line"><a name="l04623"></a><span class="lineno"> 4623</span>  FormatTestCount(unit_test.test_to_run_count()).c_str(),</div><div class="line"><a name="l04624"></a><span class="lineno"> 4624</span>  FormatTestSuiteCount(unit_test.test_suite_to_run_count()).c_str());</div><div class="line"><a name="l04625"></a><span class="lineno"> 4625</span>  fflush(stdout);</div><div class="line"><a name="l04626"></a><span class="lineno"> 4626</span> }</div><div class="line"><a name="l04627"></a><span class="lineno"> 4627</span> </div><div class="line"><a name="l04628"></a><span class="lineno"> 4628</span> <span class="keywordtype">void</span> PrettyUnitTestResultPrinter::OnEnvironmentsSetUpStart(</div><div class="line"><a name="l04629"></a><span class="lineno"> 4629</span>  <span class="keyword">const</span> UnitTest& <span class="comment">/*unit_test*/</span>) {</div><div class="line"><a name="l04630"></a><span class="lineno"> 4630</span>  ColoredPrintf(<a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea3b1e81f5b14a17b35a8672d57d166507">COLOR_GREEN</a>, <span class="stringliteral">"[----------] "</span>);</div><div class="line"><a name="l04631"></a><span class="lineno"> 4631</span>  printf(<span class="stringliteral">"Global test environment set-up.\n"</span>);</div><div class="line"><a name="l04632"></a><span class="lineno"> 4632</span>  fflush(stdout);</div><div class="line"><a name="l04633"></a><span class="lineno"> 4633</span> }</div><div class="line"><a name="l04634"></a><span class="lineno"> 4634</span> </div><div class="line"><a name="l04635"></a><span class="lineno"> 4635</span> <span class="keywordtype">void</span> PrettyUnitTestResultPrinter::OnTestCaseStart(<span class="keyword">const</span> TestSuite& test_suite) {</div><div class="line"><a name="l04636"></a><span class="lineno"> 4636</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> counts =</div><div class="line"><a name="l04637"></a><span class="lineno"> 4637</span>  FormatCountableNoun(test_suite.test_to_run_count(), <span class="stringliteral">"test"</span>, <span class="stringliteral">"tests"</span>);</div><div class="line"><a name="l04638"></a><span class="lineno"> 4638</span>  ColoredPrintf(<a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea3b1e81f5b14a17b35a8672d57d166507">COLOR_GREEN</a>, <span class="stringliteral">"[----------] "</span>);</div><div class="line"><a name="l04639"></a><span class="lineno"> 4639</span>  printf(<span class="stringliteral">"%s from %s"</span>, counts.c_str(), test_suite.name());</div><div class="line"><a name="l04640"></a><span class="lineno"> 4640</span>  <span class="keywordflow">if</span> (test_suite.type_param() == <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l04641"></a><span class="lineno"> 4641</span>  printf(<span class="stringliteral">"\n"</span>);</div><div class="line"><a name="l04642"></a><span class="lineno"> 4642</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l04643"></a><span class="lineno"> 4643</span>  printf(<span class="stringliteral">", where %s = %s\n"</span>, kTypeParamLabel, test_suite.type_param());</div><div class="line"><a name="l04644"></a><span class="lineno"> 4644</span>  }</div><div class="line"><a name="l04645"></a><span class="lineno"> 4645</span>  fflush(stdout);</div><div class="line"><a name="l04646"></a><span class="lineno"> 4646</span> }</div><div class="line"><a name="l04647"></a><span class="lineno"> 4647</span> </div><div class="line"><a name="l04648"></a><span class="lineno"> 4648</span> <span class="keywordtype">void</span> PrettyUnitTestResultPrinter::OnTestStart(<span class="keyword">const</span> TestInfo& test_info) {</div><div class="line"><a name="l04649"></a><span class="lineno"> 4649</span>  ColoredPrintf(<a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea3b1e81f5b14a17b35a8672d57d166507">COLOR_GREEN</a>, <span class="stringliteral">"[ RUN ] "</span>);</div><div class="line"><a name="l04650"></a><span class="lineno"> 4650</span>  PrintTestName(test_info.test_suite_name(), test_info.name());</div><div class="line"><a name="l04651"></a><span class="lineno"> 4651</span>  printf(<span class="stringliteral">"\n"</span>);</div><div class="line"><a name="l04652"></a><span class="lineno"> 4652</span>  fflush(stdout);</div><div class="line"><a name="l04653"></a><span class="lineno"> 4653</span> }</div><div class="line"><a name="l04654"></a><span class="lineno"> 4654</span> </div><div class="line"><a name="l04655"></a><span class="lineno"> 4655</span> <span class="comment">// Called after an assertion failure.</span></div><div class="line"><a name="l04656"></a><span class="lineno"> 4656</span> <span class="keywordtype">void</span> PrettyUnitTestResultPrinter::OnTestPartResult(</div><div class="line"><a name="l04657"></a><span class="lineno"> 4657</span>  <span class="keyword">const</span> TestPartResult& result) {</div><div class="line"><a name="l04658"></a><span class="lineno"> 4658</span>  <span class="keywordflow">switch</span> (result.type()) {</div><div class="line"><a name="l04659"></a><span class="lineno"> 4659</span>  <span class="comment">// If the test part succeeded, or was skipped,</span></div><div class="line"><a name="l04660"></a><span class="lineno"> 4660</span>  <span class="comment">// we don't need to do anything.</span></div><div class="line"><a name="l04661"></a><span class="lineno"> 4661</span>  <span class="keywordflow">case</span> TestPartResult::kSkip:</div><div class="line"><a name="l04662"></a><span class="lineno"> 4662</span>  <span class="keywordflow">case</span> TestPartResult::kSuccess:</div><div class="line"><a name="l04663"></a><span class="lineno"> 4663</span>  <span class="keywordflow">return</span>;</div><div class="line"><a name="l04664"></a><span class="lineno"> 4664</span>  <span class="keywordflow">default</span>:</div><div class="line"><a name="l04665"></a><span class="lineno"> 4665</span>  <span class="comment">// Print failure message from the assertion</span></div><div class="line"><a name="l04666"></a><span class="lineno"> 4666</span>  <span class="comment">// (e.g. expected this and got that).</span></div><div class="line"><a name="l04667"></a><span class="lineno"> 4667</span>  PrintTestPartResult(result);</div><div class="line"><a name="l04668"></a><span class="lineno"> 4668</span>  fflush(stdout);</div><div class="line"><a name="l04669"></a><span class="lineno"> 4669</span>  }</div><div class="line"><a name="l04670"></a><span class="lineno"> 4670</span> }</div><div class="line"><a name="l04671"></a><span class="lineno"> 4671</span> </div><div class="line"><a name="l04672"></a><span class="lineno"> 4672</span> <span class="keywordtype">void</span> PrettyUnitTestResultPrinter::OnTestEnd(<span class="keyword">const</span> TestInfo& test_info) {</div><div class="line"><a name="l04673"></a><span class="lineno"> 4673</span>  <span class="keywordflow">if</span> (test_info.result()->Passed()) {</div><div class="line"><a name="l04674"></a><span class="lineno"> 4674</span>  ColoredPrintf(<a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea3b1e81f5b14a17b35a8672d57d166507">COLOR_GREEN</a>, <span class="stringliteral">"[ OK ] "</span>);</div><div class="line"><a name="l04675"></a><span class="lineno"> 4675</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (test_info.result()->Skipped()) {</div><div class="line"><a name="l04676"></a><span class="lineno"> 4676</span>  ColoredPrintf(<a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea3b1e81f5b14a17b35a8672d57d166507">COLOR_GREEN</a>, <span class="stringliteral">"[ SKIPPED ] "</span>);</div><div class="line"><a name="l04677"></a><span class="lineno"> 4677</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l04678"></a><span class="lineno"> 4678</span>  ColoredPrintf(<a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea9ebb3ddab9391781f6ee5021e1e443c3">COLOR_RED</a>, <span class="stringliteral">"[ FAILED ] "</span>);</div><div class="line"><a name="l04679"></a><span class="lineno"> 4679</span>  }</div><div class="line"><a name="l04680"></a><span class="lineno"> 4680</span>  PrintTestName(test_info.test_suite_name(), test_info.name());</div><div class="line"><a name="l04681"></a><span class="lineno"> 4681</span>  <span class="keywordflow">if</span> (test_info.result()->Failed())</div><div class="line"><a name="l04682"></a><span class="lineno"> 4682</span>  PrintFullTestCommentIfPresent(test_info);</div><div class="line"><a name="l04683"></a><span class="lineno"> 4683</span> </div><div class="line"><a name="l04684"></a><span class="lineno"> 4684</span>  <span class="keywordflow">if</span> (<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(print_time)) {</div><div class="line"><a name="l04685"></a><span class="lineno"> 4685</span>  printf(<span class="stringliteral">" (%s ms)\n"</span>, <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">internal::StreamableToString</a>(</div><div class="line"><a name="l04686"></a><span class="lineno"> 4686</span>  test_info.result()->elapsed_time()).c_str());</div><div class="line"><a name="l04687"></a><span class="lineno"> 4687</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l04688"></a><span class="lineno"> 4688</span>  printf(<span class="stringliteral">"\n"</span>);</div><div class="line"><a name="l04689"></a><span class="lineno"> 4689</span>  }</div><div class="line"><a name="l04690"></a><span class="lineno"> 4690</span>  fflush(stdout);</div><div class="line"><a name="l04691"></a><span class="lineno"> 4691</span> }</div><div class="line"><a name="l04692"></a><span class="lineno"> 4692</span> </div><div class="line"><a name="l04693"></a><span class="lineno"> 4693</span> <span class="keywordtype">void</span> PrettyUnitTestResultPrinter::OnTestCaseEnd(<span class="keyword">const</span> TestSuite& test_suite) {</div><div class="line"><a name="l04694"></a><span class="lineno"> 4694</span>  <span class="keywordflow">if</span> (!<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(print_time)) <span class="keywordflow">return</span>;</div><div class="line"><a name="l04695"></a><span class="lineno"> 4695</span> </div><div class="line"><a name="l04696"></a><span class="lineno"> 4696</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> counts =</div><div class="line"><a name="l04697"></a><span class="lineno"> 4697</span>  FormatCountableNoun(test_suite.test_to_run_count(), <span class="stringliteral">"test"</span>, <span class="stringliteral">"tests"</span>);</div><div class="line"><a name="l04698"></a><span class="lineno"> 4698</span>  ColoredPrintf(<a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea3b1e81f5b14a17b35a8672d57d166507">COLOR_GREEN</a>, <span class="stringliteral">"[----------] "</span>);</div><div class="line"><a name="l04699"></a><span class="lineno"> 4699</span>  printf(<span class="stringliteral">"%s from %s (%s ms total)\n\n"</span>, counts.c_str(), test_suite.name(),</div><div class="line"><a name="l04700"></a><span class="lineno"> 4700</span>  <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">internal::StreamableToString</a>(test_suite.elapsed_time()).c_str());</div><div class="line"><a name="l04701"></a><span class="lineno"> 4701</span>  fflush(stdout);</div><div class="line"><a name="l04702"></a><span class="lineno"> 4702</span> }</div><div class="line"><a name="l04703"></a><span class="lineno"> 4703</span> </div><div class="line"><a name="l04704"></a><span class="lineno"> 4704</span> <span class="keywordtype">void</span> PrettyUnitTestResultPrinter::OnEnvironmentsTearDownStart(</div><div class="line"><a name="l04705"></a><span class="lineno"> 4705</span>  <span class="keyword">const</span> UnitTest& <span class="comment">/*unit_test*/</span>) {</div><div class="line"><a name="l04706"></a><span class="lineno"> 4706</span>  ColoredPrintf(<a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea3b1e81f5b14a17b35a8672d57d166507">COLOR_GREEN</a>, <span class="stringliteral">"[----------] "</span>);</div><div class="line"><a name="l04707"></a><span class="lineno"> 4707</span>  printf(<span class="stringliteral">"Global test environment tear-down\n"</span>);</div><div class="line"><a name="l04708"></a><span class="lineno"> 4708</span>  fflush(stdout);</div><div class="line"><a name="l04709"></a><span class="lineno"> 4709</span> }</div><div class="line"><a name="l04710"></a><span class="lineno"> 4710</span> </div><div class="line"><a name="l04711"></a><span class="lineno"> 4711</span> <span class="comment">// Internal helper for printing the list of failed tests.</span></div><div class="line"><a name="l04712"></a><span class="lineno"> 4712</span> <span class="keywordtype">void</span> PrettyUnitTestResultPrinter::PrintFailedTests(<span class="keyword">const</span> UnitTest& unit_test) {</div><div class="line"><a name="l04713"></a><span class="lineno"> 4713</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> failed_test_count = unit_test.failed_test_count();</div><div class="line"><a name="l04714"></a><span class="lineno"> 4714</span>  <span class="keywordflow">if</span> (failed_test_count == 0) {</div><div class="line"><a name="l04715"></a><span class="lineno"> 4715</span>  <span class="keywordflow">return</span>;</div><div class="line"><a name="l04716"></a><span class="lineno"> 4716</span>  }</div><div class="line"><a name="l04717"></a><span class="lineno"> 4717</span> </div><div class="line"><a name="l04718"></a><span class="lineno"> 4718</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < unit_test.total_test_suite_count(); ++i) {</div><div class="line"><a name="l04719"></a><span class="lineno"> 4719</span>  <span class="keyword">const</span> TestSuite& test_suite = *unit_test.GetTestSuite(i);</div><div class="line"><a name="l04720"></a><span class="lineno"> 4720</span>  <span class="keywordflow">if</span> (!test_suite.should_run() || (test_suite.failed_test_count() == 0)) {</div><div class="line"><a name="l04721"></a><span class="lineno"> 4721</span>  <span class="keywordflow">continue</span>;</div><div class="line"><a name="l04722"></a><span class="lineno"> 4722</span>  }</div><div class="line"><a name="l04723"></a><span class="lineno"> 4723</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j < test_suite.total_test_count(); ++j) {</div><div class="line"><a name="l04724"></a><span class="lineno"> 4724</span>  <span class="keyword">const</span> TestInfo& test_info = *test_suite.GetTestInfo(j);</div><div class="line"><a name="l04725"></a><span class="lineno"> 4725</span>  <span class="keywordflow">if</span> (!test_info.should_run() || !test_info.result()->Failed()) {</div><div class="line"><a name="l04726"></a><span class="lineno"> 4726</span>  <span class="keywordflow">continue</span>;</div><div class="line"><a name="l04727"></a><span class="lineno"> 4727</span>  }</div><div class="line"><a name="l04728"></a><span class="lineno"> 4728</span>  ColoredPrintf(<a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea9ebb3ddab9391781f6ee5021e1e443c3">COLOR_RED</a>, <span class="stringliteral">"[ FAILED ] "</span>);</div><div class="line"><a name="l04729"></a><span class="lineno"> 4729</span>  printf(<span class="stringliteral">"%s.%s"</span>, test_suite.name(), test_info.name());</div><div class="line"><a name="l04730"></a><span class="lineno"> 4730</span>  PrintFullTestCommentIfPresent(test_info);</div><div class="line"><a name="l04731"></a><span class="lineno"> 4731</span>  printf(<span class="stringliteral">"\n"</span>);</div><div class="line"><a name="l04732"></a><span class="lineno"> 4732</span>  }</div><div class="line"><a name="l04733"></a><span class="lineno"> 4733</span>  }</div><div class="line"><a name="l04734"></a><span class="lineno"> 4734</span> }</div><div class="line"><a name="l04735"></a><span class="lineno"> 4735</span> </div><div class="line"><a name="l04736"></a><span class="lineno"> 4736</span> <span class="comment">// Internal helper for printing the list of skipped tests.</span></div><div class="line"><a name="l04737"></a><span class="lineno"> 4737</span> <span class="keywordtype">void</span> PrettyUnitTestResultPrinter::PrintSkippedTests(<span class="keyword">const</span> UnitTest& unit_test) {</div><div class="line"><a name="l04738"></a><span class="lineno"> 4738</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> skipped_test_count = unit_test.skipped_test_count();</div><div class="line"><a name="l04739"></a><span class="lineno"> 4739</span>  <span class="keywordflow">if</span> (skipped_test_count == 0) {</div><div class="line"><a name="l04740"></a><span class="lineno"> 4740</span>  <span class="keywordflow">return</span>;</div><div class="line"><a name="l04741"></a><span class="lineno"> 4741</span>  }</div><div class="line"><a name="l04742"></a><span class="lineno"> 4742</span> </div><div class="line"><a name="l04743"></a><span class="lineno"> 4743</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < unit_test.total_test_suite_count(); ++i) {</div><div class="line"><a name="l04744"></a><span class="lineno"> 4744</span>  <span class="keyword">const</span> TestSuite& test_suite = *unit_test.GetTestSuite(i);</div><div class="line"><a name="l04745"></a><span class="lineno"> 4745</span>  <span class="keywordflow">if</span> (!test_suite.should_run() || (test_suite.skipped_test_count() == 0)) {</div><div class="line"><a name="l04746"></a><span class="lineno"> 4746</span>  <span class="keywordflow">continue</span>;</div><div class="line"><a name="l04747"></a><span class="lineno"> 4747</span>  }</div><div class="line"><a name="l04748"></a><span class="lineno"> 4748</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j < test_suite.total_test_count(); ++j) {</div><div class="line"><a name="l04749"></a><span class="lineno"> 4749</span>  <span class="keyword">const</span> TestInfo& test_info = *test_suite.GetTestInfo(j);</div><div class="line"><a name="l04750"></a><span class="lineno"> 4750</span>  <span class="keywordflow">if</span> (!test_info.should_run() || !test_info.result()->Skipped()) {</div><div class="line"><a name="l04751"></a><span class="lineno"> 4751</span>  <span class="keywordflow">continue</span>;</div><div class="line"><a name="l04752"></a><span class="lineno"> 4752</span>  }</div><div class="line"><a name="l04753"></a><span class="lineno"> 4753</span>  ColoredPrintf(<a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea3b1e81f5b14a17b35a8672d57d166507">COLOR_GREEN</a>, <span class="stringliteral">"[ SKIPPED ] "</span>);</div><div class="line"><a name="l04754"></a><span class="lineno"> 4754</span>  printf(<span class="stringliteral">"%s.%s"</span>, test_suite.name(), test_info.name());</div><div class="line"><a name="l04755"></a><span class="lineno"> 4755</span>  printf(<span class="stringliteral">"\n"</span>);</div><div class="line"><a name="l04756"></a><span class="lineno"> 4756</span>  }</div><div class="line"><a name="l04757"></a><span class="lineno"> 4757</span>  }</div><div class="line"><a name="l04758"></a><span class="lineno"> 4758</span> }</div><div class="line"><a name="l04759"></a><span class="lineno"> 4759</span> </div><div class="line"><a name="l04760"></a><span class="lineno"> 4760</span> <span class="keywordtype">void</span> PrettyUnitTestResultPrinter::OnTestIterationEnd(<span class="keyword">const</span> UnitTest& unit_test,</div><div class="line"><a name="l04761"></a><span class="lineno"> 4761</span>  <span class="keywordtype">int</span> <span class="comment">/*iteration*/</span>) {</div><div class="line"><a name="l04762"></a><span class="lineno"> 4762</span>  ColoredPrintf(<a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea3b1e81f5b14a17b35a8672d57d166507">COLOR_GREEN</a>, <span class="stringliteral">"[==========] "</span>);</div><div class="line"><a name="l04763"></a><span class="lineno"> 4763</span>  printf(<span class="stringliteral">"%s from %s ran."</span>,</div><div class="line"><a name="l04764"></a><span class="lineno"> 4764</span>  FormatTestCount(unit_test.test_to_run_count()).c_str(),</div><div class="line"><a name="l04765"></a><span class="lineno"> 4765</span>  FormatTestSuiteCount(unit_test.test_suite_to_run_count()).c_str());</div><div class="line"><a name="l04766"></a><span class="lineno"> 4766</span>  <span class="keywordflow">if</span> (<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(print_time)) {</div><div class="line"><a name="l04767"></a><span class="lineno"> 4767</span>  printf(<span class="stringliteral">" (%s ms total)"</span>,</div><div class="line"><a name="l04768"></a><span class="lineno"> 4768</span>  <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">internal::StreamableToString</a>(unit_test.elapsed_time()).c_str());</div><div class="line"><a name="l04769"></a><span class="lineno"> 4769</span>  }</div><div class="line"><a name="l04770"></a><span class="lineno"> 4770</span>  printf(<span class="stringliteral">"\n"</span>);</div><div class="line"><a name="l04771"></a><span class="lineno"> 4771</span>  ColoredPrintf(<a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea3b1e81f5b14a17b35a8672d57d166507">COLOR_GREEN</a>, <span class="stringliteral">"[ PASSED ] "</span>);</div><div class="line"><a name="l04772"></a><span class="lineno"> 4772</span>  printf(<span class="stringliteral">"%s.\n"</span>, FormatTestCount(unit_test.successful_test_count()).c_str());</div><div class="line"><a name="l04773"></a><span class="lineno"> 4773</span> </div><div class="line"><a name="l04774"></a><span class="lineno"> 4774</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> skipped_test_count = unit_test.skipped_test_count();</div><div class="line"><a name="l04775"></a><span class="lineno"> 4775</span>  <span class="keywordflow">if</span> (skipped_test_count > 0) {</div><div class="line"><a name="l04776"></a><span class="lineno"> 4776</span>  ColoredPrintf(<a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea3b1e81f5b14a17b35a8672d57d166507">COLOR_GREEN</a>, <span class="stringliteral">"[ SKIPPED ] "</span>);</div><div class="line"><a name="l04777"></a><span class="lineno"> 4777</span>  printf(<span class="stringliteral">"%s, listed below:\n"</span>, FormatTestCount(skipped_test_count).c_str());</div><div class="line"><a name="l04778"></a><span class="lineno"> 4778</span>  PrintSkippedTests(unit_test);</div><div class="line"><a name="l04779"></a><span class="lineno"> 4779</span>  }</div><div class="line"><a name="l04780"></a><span class="lineno"> 4780</span> </div><div class="line"><a name="l04781"></a><span class="lineno"> 4781</span>  <span class="keywordtype">int</span> num_failures = unit_test.failed_test_count();</div><div class="line"><a name="l04782"></a><span class="lineno"> 4782</span>  <span class="keywordflow">if</span> (!unit_test.Passed()) {</div><div class="line"><a name="l04783"></a><span class="lineno"> 4783</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> failed_test_count = unit_test.failed_test_count();</div><div class="line"><a name="l04784"></a><span class="lineno"> 4784</span>  ColoredPrintf(<a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea9ebb3ddab9391781f6ee5021e1e443c3">COLOR_RED</a>, <span class="stringliteral">"[ FAILED ] "</span>);</div><div class="line"><a name="l04785"></a><span class="lineno"> 4785</span>  printf(<span class="stringliteral">"%s, listed below:\n"</span>, FormatTestCount(failed_test_count).c_str());</div><div class="line"><a name="l04786"></a><span class="lineno"> 4786</span>  PrintFailedTests(unit_test);</div><div class="line"><a name="l04787"></a><span class="lineno"> 4787</span>  printf(<span class="stringliteral">"\n%2d FAILED %s\n"</span>, num_failures,</div><div class="line"><a name="l04788"></a><span class="lineno"> 4788</span>  num_failures == 1 ? <span class="stringliteral">"TEST"</span> : <span class="stringliteral">"TESTS"</span>);</div><div class="line"><a name="l04789"></a><span class="lineno"> 4789</span>  }</div><div class="line"><a name="l04790"></a><span class="lineno"> 4790</span> </div><div class="line"><a name="l04791"></a><span class="lineno"> 4791</span>  <span class="keywordtype">int</span> num_disabled = unit_test.reportable_disabled_test_count();</div><div class="line"><a name="l04792"></a><span class="lineno"> 4792</span>  <span class="keywordflow">if</span> (num_disabled && !<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(also_run_disabled_tests)) {</div><div class="line"><a name="l04793"></a><span class="lineno"> 4793</span>  <span class="keywordflow">if</span> (!num_failures) {</div><div class="line"><a name="l04794"></a><span class="lineno"> 4794</span>  printf(<span class="stringliteral">"\n"</span>); <span class="comment">// Add a spacer if no FAILURE banner is displayed.</span></div><div class="line"><a name="l04795"></a><span class="lineno"> 4795</span>  }</div><div class="line"><a name="l04796"></a><span class="lineno"> 4796</span>  ColoredPrintf(<a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea2cca441161aca75a208ff08d07f5b1a5">COLOR_YELLOW</a>,</div><div class="line"><a name="l04797"></a><span class="lineno"> 4797</span>  <span class="stringliteral">" YOU HAVE %d DISABLED %s\n\n"</span>,</div><div class="line"><a name="l04798"></a><span class="lineno"> 4798</span>  num_disabled,</div><div class="line"><a name="l04799"></a><span class="lineno"> 4799</span>  num_disabled == 1 ? <span class="stringliteral">"TEST"</span> : <span class="stringliteral">"TESTS"</span>);</div><div class="line"><a name="l04800"></a><span class="lineno"> 4800</span>  }</div><div class="line"><a name="l04801"></a><span class="lineno"> 4801</span>  <span class="comment">// Ensure that Google Test output is printed before, e.g., heapchecker output.</span></div><div class="line"><a name="l04802"></a><span class="lineno"> 4802</span>  fflush(stdout);</div><div class="line"><a name="l04803"></a><span class="lineno"> 4803</span> }</div><div class="line"><a name="l04804"></a><span class="lineno"> 4804</span> </div><div class="line"><a name="l04805"></a><span class="lineno"> 4805</span> <span class="comment">// End PrettyUnitTestResultPrinter</span></div><div class="line"><a name="l04806"></a><span class="lineno"> 4806</span> </div><div class="line"><a name="l04807"></a><span class="lineno"> 4807</span> <span class="comment">// class TestEventRepeater</span></div><div class="line"><a name="l04808"></a><span class="lineno"> 4808</span> <span class="comment">//</span></div><div class="line"><a name="l04809"></a><span class="lineno"> 4809</span> <span class="comment">// This class forwards events to other event listeners.</span></div><div class="line"><a name="l04810"></a><span class="lineno"> 4810</span> <span class="keyword">class </span>TestEventRepeater : <span class="keyword">public</span> TestEventListener {</div><div class="line"><a name="l04811"></a><span class="lineno"> 4811</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l04812"></a><span class="lineno"> 4812</span>  TestEventRepeater() : forwarding_enabled_(true) {}</div><div class="line"><a name="l04813"></a><span class="lineno"> 4813</span>  ~TestEventRepeater() <span class="keyword">override</span>;</div><div class="line"><a name="l04814"></a><span class="lineno"> 4814</span>  <span class="keywordtype">void</span> Append(TestEventListener *listener);</div><div class="line"><a name="l04815"></a><span class="lineno"> 4815</span>  TestEventListener* Release(TestEventListener* listener);</div><div class="line"><a name="l04816"></a><span class="lineno"> 4816</span> </div><div class="line"><a name="l04817"></a><span class="lineno"> 4817</span>  <span class="comment">// Controls whether events will be forwarded to listeners_. Set to false</span></div><div class="line"><a name="l04818"></a><span class="lineno"> 4818</span>  <span class="comment">// in death test child processes.</span></div><div class="line"><a name="l04819"></a><span class="lineno"> 4819</span>  <span class="keywordtype">bool</span> forwarding_enabled()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> forwarding_enabled_; }</div><div class="line"><a name="l04820"></a><span class="lineno"> 4820</span>  <span class="keywordtype">void</span> set_forwarding_enabled(<span class="keywordtype">bool</span> enable) { forwarding_enabled_ = enable; }</div><div class="line"><a name="l04821"></a><span class="lineno"> 4821</span> </div><div class="line"><a name="l04822"></a><span class="lineno"> 4822</span>  <span class="keywordtype">void</span> OnTestProgramStart(<span class="keyword">const</span> UnitTest& unit_test) <span class="keyword">override</span>;</div><div class="line"><a name="l04823"></a><span class="lineno"> 4823</span>  <span class="keywordtype">void</span> OnTestIterationStart(<span class="keyword">const</span> UnitTest& unit_test, <span class="keywordtype">int</span> iteration) <span class="keyword">override</span>;</div><div class="line"><a name="l04824"></a><span class="lineno"> 4824</span>  <span class="keywordtype">void</span> OnEnvironmentsSetUpStart(<span class="keyword">const</span> UnitTest& unit_test) <span class="keyword">override</span>;</div><div class="line"><a name="l04825"></a><span class="lineno"> 4825</span>  <span class="keywordtype">void</span> OnEnvironmentsSetUpEnd(<span class="keyword">const</span> UnitTest& unit_test) <span class="keyword">override</span>;</div><div class="line"><a name="l04826"></a><span class="lineno"> 4826</span> <span class="comment">// Legacy API is deprecated but still available</span></div><div class="line"><a name="l04827"></a><span class="lineno"> 4827</span> <span class="preprocessor">#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI</span></div><div class="line"><a name="l04828"></a><span class="lineno"> 4828</span>  <span class="keywordtype">void</span> OnTestCaseStart(<span class="keyword">const</span> TestSuite& parameter) <span class="keyword">override</span>;</div><div class="line"><a name="l04829"></a><span class="lineno"> 4829</span> <span class="preprocessor">#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI</span></div><div class="line"><a name="l04830"></a><span class="lineno"> 4830</span>  <span class="keywordtype">void</span> OnTestSuiteStart(<span class="keyword">const</span> TestSuite& parameter) <span class="keyword">override</span>;</div><div class="line"><a name="l04831"></a><span class="lineno"> 4831</span>  <span class="keywordtype">void</span> OnTestStart(<span class="keyword">const</span> TestInfo& test_info) <span class="keyword">override</span>;</div><div class="line"><a name="l04832"></a><span class="lineno"> 4832</span>  <span class="keywordtype">void</span> OnTestPartResult(<span class="keyword">const</span> TestPartResult& result) <span class="keyword">override</span>;</div><div class="line"><a name="l04833"></a><span class="lineno"> 4833</span>  <span class="keywordtype">void</span> OnTestEnd(<span class="keyword">const</span> TestInfo& test_info) <span class="keyword">override</span>;</div><div class="line"><a name="l04834"></a><span class="lineno"> 4834</span> <span class="comment">// Legacy API is deprecated but still available</span></div><div class="line"><a name="l04835"></a><span class="lineno"> 4835</span> <span class="preprocessor">#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI</span></div><div class="line"><a name="l04836"></a><span class="lineno"> 4836</span>  <span class="keywordtype">void</span> OnTestCaseEnd(<span class="keyword">const</span> TestSuite& parameter) <span class="keyword">override</span>;</div><div class="line"><a name="l04837"></a><span class="lineno"> 4837</span> <span class="preprocessor">#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI</span></div><div class="line"><a name="l04838"></a><span class="lineno"> 4838</span>  <span class="keywordtype">void</span> OnTestSuiteEnd(<span class="keyword">const</span> TestSuite& parameter) <span class="keyword">override</span>;</div><div class="line"><a name="l04839"></a><span class="lineno"> 4839</span>  <span class="keywordtype">void</span> OnEnvironmentsTearDownStart(<span class="keyword">const</span> UnitTest& unit_test) <span class="keyword">override</span>;</div><div class="line"><a name="l04840"></a><span class="lineno"> 4840</span>  <span class="keywordtype">void</span> OnEnvironmentsTearDownEnd(<span class="keyword">const</span> UnitTest& unit_test) <span class="keyword">override</span>;</div><div class="line"><a name="l04841"></a><span class="lineno"> 4841</span>  <span class="keywordtype">void</span> OnTestIterationEnd(<span class="keyword">const</span> UnitTest& unit_test, <span class="keywordtype">int</span> iteration) <span class="keyword">override</span>;</div><div class="line"><a name="l04842"></a><span class="lineno"> 4842</span>  <span class="keywordtype">void</span> OnTestProgramEnd(<span class="keyword">const</span> UnitTest& unit_test) <span class="keyword">override</span>;</div><div class="line"><a name="l04843"></a><span class="lineno"> 4843</span> </div><div class="line"><a name="l04844"></a><span class="lineno"> 4844</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l04845"></a><span class="lineno"> 4845</span>  <span class="comment">// Controls whether events will be forwarded to listeners_. Set to false</span></div><div class="line"><a name="l04846"></a><span class="lineno"> 4846</span>  <span class="comment">// in death test child processes.</span></div><div class="line"><a name="l04847"></a><span class="lineno"> 4847</span>  <span class="keywordtype">bool</span> forwarding_enabled_;</div><div class="line"><a name="l04848"></a><span class="lineno"> 4848</span>  <span class="comment">// The list of listeners that receive events.</span></div><div class="line"><a name="l04849"></a><span class="lineno"> 4849</span>  std::vector<TestEventListener*> listeners_;</div><div class="line"><a name="l04850"></a><span class="lineno"> 4850</span> </div><div class="line"><a name="l04851"></a><span class="lineno"> 4851</span>  <a class="code" href="gtest_8h.html#aed8c1888c32b588b0681e88b95031e29">GTEST_DISALLOW_COPY_AND_ASSIGN_</a>(TestEventRepeater);</div><div class="line"><a name="l04852"></a><span class="lineno"> 4852</span> };</div><div class="line"><a name="l04853"></a><span class="lineno"> 4853</span> </div><div class="line"><a name="l04854"></a><span class="lineno"> 4854</span> TestEventRepeater::~TestEventRepeater() {</div><div class="line"><a name="l04855"></a><span class="lineno"> 4855</span>  ForEach(listeners_, Delete<TestEventListener>);</div><div class="line"><a name="l04856"></a><span class="lineno"> 4856</span> }</div><div class="line"><a name="l04857"></a><span class="lineno"> 4857</span> </div><div class="line"><a name="l04858"></a><span class="lineno"> 4858</span> <span class="keywordtype">void</span> TestEventRepeater::Append(TestEventListener *listener) {</div><div class="line"><a name="l04859"></a><span class="lineno"> 4859</span>  listeners_.push_back(listener);</div><div class="line"><a name="l04860"></a><span class="lineno"> 4860</span> }</div><div class="line"><a name="l04861"></a><span class="lineno"> 4861</span> </div><div class="line"><a name="l04862"></a><span class="lineno"> 4862</span> TestEventListener* TestEventRepeater::Release(TestEventListener *listener) {</div><div class="line"><a name="l04863"></a><span class="lineno"> 4863</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i < listeners_.size(); ++i) {</div><div class="line"><a name="l04864"></a><span class="lineno"> 4864</span>  <span class="keywordflow">if</span> (listeners_[i] == listener) {</div><div class="line"><a name="l04865"></a><span class="lineno"> 4865</span>  listeners_.erase(listeners_.begin() + i);</div><div class="line"><a name="l04866"></a><span class="lineno"> 4866</span>  <span class="keywordflow">return</span> listener;</div><div class="line"><a name="l04867"></a><span class="lineno"> 4867</span>  }</div><div class="line"><a name="l04868"></a><span class="lineno"> 4868</span>  }</div><div class="line"><a name="l04869"></a><span class="lineno"> 4869</span> </div><div class="line"><a name="l04870"></a><span class="lineno"> 4870</span>  <span class="keywordflow">return</span> <span class="keyword">nullptr</span>;</div><div class="line"><a name="l04871"></a><span class="lineno"> 4871</span> }</div><div class="line"><a name="l04872"></a><span class="lineno"> 4872</span> </div><div class="line"><a name="l04873"></a><span class="lineno"> 4873</span> <span class="comment">// Since most methods are very similar, use macros to reduce boilerplate.</span></div><div class="line"><a name="l04874"></a><span class="lineno"> 4874</span> <span class="comment">// This defines a member that forwards the call to all listeners.</span></div><div class="line"><a name="l04875"></a><span class="lineno"> 4875</span> <span class="preprocessor">#define GTEST_REPEATER_METHOD_(Name, Type) \</span></div><div class="line"><a name="l04876"></a><span class="lineno"> 4876</span> <span class="preprocessor">void TestEventRepeater::Name(const Type& parameter) { \</span></div><div class="line"><a name="l04877"></a><span class="lineno"> 4877</span> <span class="preprocessor"> if (forwarding_enabled_) { \</span></div><div class="line"><a name="l04878"></a><span class="lineno"> 4878</span> <span class="preprocessor"> for (size_t i = 0; i < listeners_.size(); i++) { \</span></div><div class="line"><a name="l04879"></a><span class="lineno"> 4879</span> <span class="preprocessor"> listeners_[i]->Name(parameter); \</span></div><div class="line"><a name="l04880"></a><span class="lineno"> 4880</span> <span class="preprocessor"> } \</span></div><div class="line"><a name="l04881"></a><span class="lineno"> 4881</span> <span class="preprocessor"> } \</span></div><div class="line"><a name="l04882"></a><span class="lineno"> 4882</span> <span class="preprocessor">}</span></div><div class="line"><a name="l04883"></a><span class="lineno"> 4883</span> <span class="comment">// This defines a member that forwards the call to all listeners in reverse</span></div><div class="line"><a name="l04884"></a><span class="lineno"> 4884</span> <span class="comment">// order.</span></div><div class="line"><a name="l04885"></a><span class="lineno"> 4885</span> <span class="preprocessor">#define GTEST_REVERSE_REPEATER_METHOD_(Name, Type) \</span></div><div class="line"><a name="l04886"></a><span class="lineno"> 4886</span> <span class="preprocessor">void TestEventRepeater::Name(const Type& parameter) { \</span></div><div class="line"><a name="l04887"></a><span class="lineno"> 4887</span> <span class="preprocessor"> if (forwarding_enabled_) { \</span></div><div class="line"><a name="l04888"></a><span class="lineno"> 4888</span> <span class="preprocessor"> for (int i = static_cast<int>(listeners_.size()) - 1; i >= 0; i--) { \</span></div><div class="line"><a name="l04889"></a><span class="lineno"> 4889</span> <span class="preprocessor"> listeners_[i]->Name(parameter); \</span></div><div class="line"><a name="l04890"></a><span class="lineno"> 4890</span> <span class="preprocessor"> } \</span></div><div class="line"><a name="l04891"></a><span class="lineno"> 4891</span> <span class="preprocessor"> } \</span></div><div class="line"><a name="l04892"></a><span class="lineno"> 4892</span> <span class="preprocessor">}</span></div><div class="line"><a name="l04893"></a><span class="lineno"> 4893</span> </div><div class="line"><a name="l04894"></a><span class="lineno"> 4894</span> <a class="code" href="gtest-all_8cc.html#a87a475ab9e81de8b49525787665b9229">GTEST_REPEATER_METHOD_</a>(OnTestProgramStart, UnitTest)</div><div class="line"><a name="l04895"></a><span class="lineno"> 4895</span> <a class="code" href="gtest-all_8cc.html#a87a475ab9e81de8b49525787665b9229">GTEST_REPEATER_METHOD_</a>(OnEnvironmentsSetUpStart, UnitTest)</div><div class="line"><a name="l04896"></a><span class="lineno"> 4896</span> <span class="comment">// Legacy API is deprecated but still available</span></div><div class="line"><a name="l04897"></a><span class="lineno"> 4897</span> <span class="preprocessor">#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_</span></div><div class="line"><a name="l04898"></a><span class="lineno"> 4898</span> <a class="code" href="gtest-all_8cc.html#a87a475ab9e81de8b49525787665b9229">GTEST_REPEATER_METHOD_</a>(OnTestCaseStart, TestSuite)</div><div class="line"><a name="l04899"></a><span class="lineno"> 4899</span> <span class="preprocessor">#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_</span></div><div class="line"><a name="l04900"></a><span class="lineno"> 4900</span> <a class="code" href="gtest-all_8cc.html#a87a475ab9e81de8b49525787665b9229">GTEST_REPEATER_METHOD_</a>(OnTestSuiteStart, TestSuite)</div><div class="line"><a name="l04901"></a><span class="lineno"> 4901</span> <a class="code" href="gtest-all_8cc.html#a87a475ab9e81de8b49525787665b9229">GTEST_REPEATER_METHOD_</a>(OnTestStart, TestInfo)</div><div class="line"><a name="l04902"></a><span class="lineno"> 4902</span> <a class="code" href="gtest-all_8cc.html#a87a475ab9e81de8b49525787665b9229">GTEST_REPEATER_METHOD_</a>(OnTestPartResult, TestPartResult)</div><div class="line"><a name="l04903"></a><span class="lineno"> 4903</span> <a class="code" href="gtest-all_8cc.html#a87a475ab9e81de8b49525787665b9229">GTEST_REPEATER_METHOD_</a>(OnEnvironmentsTearDownStart, UnitTest)</div><div class="line"><a name="l04904"></a><span class="lineno"> 4904</span> <a class="code" href="gtest-all_8cc.html#aa7da32fd7da6a8cceeed6b448cb7b5f2">GTEST_REVERSE_REPEATER_METHOD_</a>(OnEnvironmentsSetUpEnd, UnitTest)</div><div class="line"><a name="l04905"></a><span class="lineno"> 4905</span> <a class="code" href="gtest-all_8cc.html#aa7da32fd7da6a8cceeed6b448cb7b5f2">GTEST_REVERSE_REPEATER_METHOD_</a>(OnEnvironmentsTearDownEnd, UnitTest)</div><div class="line"><a name="l04906"></a><span class="lineno"> 4906</span> <a class="code" href="gtest-all_8cc.html#aa7da32fd7da6a8cceeed6b448cb7b5f2">GTEST_REVERSE_REPEATER_METHOD_</a>(OnTestEnd, TestInfo)</div><div class="line"><a name="l04907"></a><span class="lineno"> 4907</span> <span class="comment">// Legacy API is deprecated but still available</span></div><div class="line"><a name="l04908"></a><span class="lineno"> 4908</span> <span class="preprocessor">#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_</span></div><div class="line"><a name="l04909"></a><span class="lineno"> 4909</span> <a class="code" href="gtest-all_8cc.html#aa7da32fd7da6a8cceeed6b448cb7b5f2">GTEST_REVERSE_REPEATER_METHOD_</a>(OnTestCaseEnd, TestSuite)</div><div class="line"><a name="l04910"></a><span class="lineno"> 4910</span> <span class="preprocessor">#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_</span></div><div class="line"><a name="l04911"></a><span class="lineno"> 4911</span> <a class="code" href="gtest-all_8cc.html#aa7da32fd7da6a8cceeed6b448cb7b5f2">GTEST_REVERSE_REPEATER_METHOD_</a>(OnTestSuiteEnd, TestSuite)</div><div class="line"><a name="l04912"></a><span class="lineno"> 4912</span> <a class="code" href="gtest-all_8cc.html#aa7da32fd7da6a8cceeed6b448cb7b5f2">GTEST_REVERSE_REPEATER_METHOD_</a>(OnTestProgramEnd, UnitTest)</div><div class="line"><a name="l04913"></a><span class="lineno"> 4913</span> </div><div class="line"><a name="l04914"></a><span class="lineno"> 4914</span> <span class="preprocessor">#undef GTEST_REPEATER_METHOD_</span></div><div class="line"><a name="l04915"></a><span class="lineno"> 4915</span> <span class="preprocessor">#undef GTEST_REVERSE_REPEATER_METHOD_</span></div><div class="line"><a name="l04916"></a><span class="lineno"> 4916</span> </div><div class="line"><a name="l04917"></a><span class="lineno"> 4917</span> <span class="keywordtype">void</span> TestEventRepeater::OnTestIterationStart(<span class="keyword">const</span> UnitTest& unit_test,</div><div class="line"><a name="l04918"></a><span class="lineno"> 4918</span>  <span class="keywordtype">int</span> iteration) {</div><div class="line"><a name="l04919"></a><span class="lineno"> 4919</span>  <span class="keywordflow">if</span> (forwarding_enabled_) {</div><div class="line"><a name="l04920"></a><span class="lineno"> 4920</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i < listeners_.size(); i++) {</div><div class="line"><a name="l04921"></a><span class="lineno"> 4921</span>  listeners_[i]->OnTestIterationStart(unit_test, iteration);</div><div class="line"><a name="l04922"></a><span class="lineno"> 4922</span>  }</div><div class="line"><a name="l04923"></a><span class="lineno"> 4923</span>  }</div><div class="line"><a name="l04924"></a><span class="lineno"> 4924</span> }</div><div class="line"><a name="l04925"></a><span class="lineno"> 4925</span> </div><div class="line"><a name="l04926"></a><span class="lineno"> 4926</span> <span class="keywordtype">void</span> TestEventRepeater::OnTestIterationEnd(<span class="keyword">const</span> UnitTest& unit_test,</div><div class="line"><a name="l04927"></a><span class="lineno"> 4927</span>  <span class="keywordtype">int</span> iteration) {</div><div class="line"><a name="l04928"></a><span class="lineno"> 4928</span>  <span class="keywordflow">if</span> (forwarding_enabled_) {</div><div class="line"><a name="l04929"></a><span class="lineno"> 4929</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = static_cast<int>(listeners_.size()) - 1; i >= 0; i--) {</div><div class="line"><a name="l04930"></a><span class="lineno"> 4930</span>  listeners_[i]->OnTestIterationEnd(unit_test, iteration);</div><div class="line"><a name="l04931"></a><span class="lineno"> 4931</span>  }</div><div class="line"><a name="l04932"></a><span class="lineno"> 4932</span>  }</div><div class="line"><a name="l04933"></a><span class="lineno"> 4933</span> }</div><div class="line"><a name="l04934"></a><span class="lineno"> 4934</span> </div><div class="line"><a name="l04935"></a><span class="lineno"> 4935</span> <span class="comment">// End TestEventRepeater</span></div><div class="line"><a name="l04936"></a><span class="lineno"> 4936</span> </div><div class="line"><a name="l04937"></a><span class="lineno"> 4937</span> <span class="comment">// This class generates an XML output file.</span></div><div class="line"><a name="l04938"></a><span class="lineno"> 4938</span> <span class="keyword">class </span>XmlUnitTestResultPrinter : <span class="keyword">public</span> EmptyTestEventListener {</div><div class="line"><a name="l04939"></a><span class="lineno"> 4939</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l04940"></a><span class="lineno"> 4940</span>  <span class="keyword">explicit</span> XmlUnitTestResultPrinter(<span class="keyword">const</span> <span class="keywordtype">char</span>* output_file);</div><div class="line"><a name="l04941"></a><span class="lineno"> 4941</span> </div><div class="line"><a name="l04942"></a><span class="lineno"> 4942</span>  <span class="keywordtype">void</span> OnTestIterationEnd(<span class="keyword">const</span> UnitTest& unit_test, <span class="keywordtype">int</span> iteration) <span class="keyword">override</span>;</div><div class="line"><a name="l04943"></a><span class="lineno"> 4943</span>  <span class="keywordtype">void</span> ListTestsMatchingFilter(<span class="keyword">const</span> std::vector<TestSuite*>& test_suites);</div><div class="line"><a name="l04944"></a><span class="lineno"> 4944</span> </div><div class="line"><a name="l04945"></a><span class="lineno"> 4945</span>  <span class="comment">// Prints an XML summary of all unit tests.</span></div><div class="line"><a name="l04946"></a><span class="lineno"> 4946</span>  <span class="keyword">static</span> <span class="keywordtype">void</span> PrintXmlTestsList(std::ostream* stream,</div><div class="line"><a name="l04947"></a><span class="lineno"> 4947</span>  <span class="keyword">const</span> std::vector<TestSuite*>& test_suites);</div><div class="line"><a name="l04948"></a><span class="lineno"> 4948</span> </div><div class="line"><a name="l04949"></a><span class="lineno"> 4949</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l04950"></a><span class="lineno"> 4950</span>  <span class="comment">// Is c a whitespace character that is normalized to a space character</span></div><div class="line"><a name="l04951"></a><span class="lineno"> 4951</span>  <span class="comment">// when it appears in an XML attribute value?</span></div><div class="line"><a name="l04952"></a><span class="lineno"> 4952</span>  <span class="keyword">static</span> <span class="keywordtype">bool</span> IsNormalizableWhitespace(<span class="keywordtype">char</span> c) {</div><div class="line"><a name="l04953"></a><span class="lineno"> 4953</span>  <span class="keywordflow">return</span> c == 0x9 || c == 0xA || c == 0xD;</div><div class="line"><a name="l04954"></a><span class="lineno"> 4954</span>  }</div><div class="line"><a name="l04955"></a><span class="lineno"> 4955</span> </div><div class="line"><a name="l04956"></a><span class="lineno"> 4956</span>  <span class="comment">// May c appear in a well-formed XML document?</span></div><div class="line"><a name="l04957"></a><span class="lineno"> 4957</span>  <span class="keyword">static</span> <span class="keywordtype">bool</span> IsValidXmlCharacter(<span class="keywordtype">char</span> c) {</div><div class="line"><a name="l04958"></a><span class="lineno"> 4958</span>  <span class="keywordflow">return</span> IsNormalizableWhitespace(c) || c >= 0x20;</div><div class="line"><a name="l04959"></a><span class="lineno"> 4959</span>  }</div><div class="line"><a name="l04960"></a><span class="lineno"> 4960</span> </div><div class="line"><a name="l04961"></a><span class="lineno"> 4961</span>  <span class="comment">// Returns an XML-escaped copy of the input string str. If</span></div><div class="line"><a name="l04962"></a><span class="lineno"> 4962</span>  <span class="comment">// is_attribute is true, the text is meant to appear as an attribute</span></div><div class="line"><a name="l04963"></a><span class="lineno"> 4963</span>  <span class="comment">// value, and normalizable whitespace is preserved by replacing it</span></div><div class="line"><a name="l04964"></a><span class="lineno"> 4964</span>  <span class="comment">// with character references.</span></div><div class="line"><a name="l04965"></a><span class="lineno"> 4965</span>  <span class="keyword">static</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> EscapeXml(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& str, <span class="keywordtype">bool</span> is_attribute);</div><div class="line"><a name="l04966"></a><span class="lineno"> 4966</span> </div><div class="line"><a name="l04967"></a><span class="lineno"> 4967</span>  <span class="comment">// Returns the given string with all characters invalid in XML removed.</span></div><div class="line"><a name="l04968"></a><span class="lineno"> 4968</span>  <span class="keyword">static</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> RemoveInvalidXmlCharacters(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& str);</div><div class="line"><a name="l04969"></a><span class="lineno"> 4969</span> </div><div class="line"><a name="l04970"></a><span class="lineno"> 4970</span>  <span class="comment">// Convenience wrapper around EscapeXml when str is an attribute value.</span></div><div class="line"><a name="l04971"></a><span class="lineno"> 4971</span>  <span class="keyword">static</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> EscapeXmlAttribute(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& str) {</div><div class="line"><a name="l04972"></a><span class="lineno"> 4972</span>  <span class="keywordflow">return</span> EscapeXml(str, <span class="keyword">true</span>);</div><div class="line"><a name="l04973"></a><span class="lineno"> 4973</span>  }</div><div class="line"><a name="l04974"></a><span class="lineno"> 4974</span> </div><div class="line"><a name="l04975"></a><span class="lineno"> 4975</span>  <span class="comment">// Convenience wrapper around EscapeXml when str is not an attribute value.</span></div><div class="line"><a name="l04976"></a><span class="lineno"> 4976</span>  <span class="keyword">static</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> EscapeXmlText(<span class="keyword">const</span> <span class="keywordtype">char</span>* str) {</div><div class="line"><a name="l04977"></a><span class="lineno"> 4977</span>  <span class="keywordflow">return</span> EscapeXml(str, <span class="keyword">false</span>);</div><div class="line"><a name="l04978"></a><span class="lineno"> 4978</span>  }</div><div class="line"><a name="l04979"></a><span class="lineno"> 4979</span> </div><div class="line"><a name="l04980"></a><span class="lineno"> 4980</span>  <span class="comment">// Verifies that the given attribute belongs to the given element and</span></div><div class="line"><a name="l04981"></a><span class="lineno"> 4981</span>  <span class="comment">// streams the attribute as XML.</span></div><div class="line"><a name="l04982"></a><span class="lineno"> 4982</span>  <span class="keyword">static</span> <span class="keywordtype">void</span> OutputXmlAttribute(std::ostream* stream,</div><div class="line"><a name="l04983"></a><span class="lineno"> 4983</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& element_name,</div><div class="line"><a name="l04984"></a><span class="lineno"> 4984</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& name,</div><div class="line"><a name="l04985"></a><span class="lineno"> 4985</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& value);</div><div class="line"><a name="l04986"></a><span class="lineno"> 4986</span> </div><div class="line"><a name="l04987"></a><span class="lineno"> 4987</span>  <span class="comment">// Streams an XML CDATA section, escaping invalid CDATA sequences as needed.</span></div><div class="line"><a name="l04988"></a><span class="lineno"> 4988</span>  <span class="keyword">static</span> <span class="keywordtype">void</span> OutputXmlCDataSection(::std::ostream* stream, <span class="keyword">const</span> <span class="keywordtype">char</span>* data);</div><div class="line"><a name="l04989"></a><span class="lineno"> 4989</span> </div><div class="line"><a name="l04990"></a><span class="lineno"> 4990</span>  <span class="comment">// Streams an XML representation of a TestInfo object.</span></div><div class="line"><a name="l04991"></a><span class="lineno"> 4991</span>  <span class="keyword">static</span> <span class="keywordtype">void</span> OutputXmlTestInfo(::std::ostream* stream,</div><div class="line"><a name="l04992"></a><span class="lineno"> 4992</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* test_suite_name,</div><div class="line"><a name="l04993"></a><span class="lineno"> 4993</span>  <span class="keyword">const</span> TestInfo& test_info);</div><div class="line"><a name="l04994"></a><span class="lineno"> 4994</span> </div><div class="line"><a name="l04995"></a><span class="lineno"> 4995</span>  <span class="comment">// Prints an XML representation of a TestSuite object</span></div><div class="line"><a name="l04996"></a><span class="lineno"> 4996</span>  <span class="keyword">static</span> <span class="keywordtype">void</span> PrintXmlTestSuite(::std::ostream* stream,</div><div class="line"><a name="l04997"></a><span class="lineno"> 4997</span>  <span class="keyword">const</span> TestSuite& test_suite);</div><div class="line"><a name="l04998"></a><span class="lineno"> 4998</span> </div><div class="line"><a name="l04999"></a><span class="lineno"> 4999</span>  <span class="comment">// Prints an XML summary of unit_test to output stream out.</span></div><div class="line"><a name="l05000"></a><span class="lineno"> 5000</span>  <span class="keyword">static</span> <span class="keywordtype">void</span> PrintXmlUnitTest(::std::ostream* stream,</div><div class="line"><a name="l05001"></a><span class="lineno"> 5001</span>  <span class="keyword">const</span> UnitTest& unit_test);</div><div class="line"><a name="l05002"></a><span class="lineno"> 5002</span> </div><div class="line"><a name="l05003"></a><span class="lineno"> 5003</span>  <span class="comment">// Produces a string representing the test properties in a result as space</span></div><div class="line"><a name="l05004"></a><span class="lineno"> 5004</span>  <span class="comment">// delimited XML attributes based on the property key="value" pairs.</span></div><div class="line"><a name="l05005"></a><span class="lineno"> 5005</span>  <span class="comment">// When the std::string is not empty, it includes a space at the beginning,</span></div><div class="line"><a name="l05006"></a><span class="lineno"> 5006</span>  <span class="comment">// to delimit this attribute from prior attributes.</span></div><div class="line"><a name="l05007"></a><span class="lineno"> 5007</span>  <span class="keyword">static</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> TestPropertiesAsXmlAttributes(<span class="keyword">const</span> TestResult& result);</div><div class="line"><a name="l05008"></a><span class="lineno"> 5008</span> </div><div class="line"><a name="l05009"></a><span class="lineno"> 5009</span>  <span class="comment">// Streams an XML representation of the test properties of a TestResult</span></div><div class="line"><a name="l05010"></a><span class="lineno"> 5010</span>  <span class="comment">// object.</span></div><div class="line"><a name="l05011"></a><span class="lineno"> 5011</span>  <span class="keyword">static</span> <span class="keywordtype">void</span> OutputXmlTestProperties(std::ostream* stream,</div><div class="line"><a name="l05012"></a><span class="lineno"> 5012</span>  <span class="keyword">const</span> TestResult& result);</div><div class="line"><a name="l05013"></a><span class="lineno"> 5013</span> </div><div class="line"><a name="l05014"></a><span class="lineno"> 5014</span>  <span class="comment">// The output file.</span></div><div class="line"><a name="l05015"></a><span class="lineno"> 5015</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> output_file_;</div><div class="line"><a name="l05016"></a><span class="lineno"> 5016</span> </div><div class="line"><a name="l05017"></a><span class="lineno"> 5017</span>  <a class="code" href="gtest_8h.html#aed8c1888c32b588b0681e88b95031e29">GTEST_DISALLOW_COPY_AND_ASSIGN_</a>(XmlUnitTestResultPrinter);</div><div class="line"><a name="l05018"></a><span class="lineno"> 5018</span> };</div><div class="line"><a name="l05019"></a><span class="lineno"> 5019</span> </div><div class="line"><a name="l05020"></a><span class="lineno"> 5020</span> <span class="comment">// Creates a new XmlUnitTestResultPrinter.</span></div><div class="line"><a name="l05021"></a><span class="lineno"> 5021</span> XmlUnitTestResultPrinter::XmlUnitTestResultPrinter(<span class="keyword">const</span> <span class="keywordtype">char</span>* output_file)</div><div class="line"><a name="l05022"></a><span class="lineno"> 5022</span>  : output_file_(output_file) {</div><div class="line"><a name="l05023"></a><span class="lineno"> 5023</span>  <span class="keywordflow">if</span> (output_file_.empty()) {</div><div class="line"><a name="l05024"></a><span class="lineno"> 5024</span>  <a class="code" href="gtest_8h.html#a8ef4cb4c465db8c15464aecc6d9510ef">GTEST_LOG_</a>(FATAL) << <span class="stringliteral">"XML output file may not be null"</span>;</div><div class="line"><a name="l05025"></a><span class="lineno"> 5025</span>  }</div><div class="line"><a name="l05026"></a><span class="lineno"> 5026</span> }</div><div class="line"><a name="l05027"></a><span class="lineno"> 5027</span> </div><div class="line"><a name="l05028"></a><span class="lineno"> 5028</span> <span class="comment">// Called after the unit test ends.</span></div><div class="line"><a name="l05029"></a><span class="lineno"> 5029</span> <span class="keywordtype">void</span> XmlUnitTestResultPrinter::OnTestIterationEnd(<span class="keyword">const</span> UnitTest& unit_test,</div><div class="line"><a name="l05030"></a><span class="lineno"> 5030</span>  <span class="keywordtype">int</span> <span class="comment">/*iteration*/</span>) {</div><div class="line"><a name="l05031"></a><span class="lineno"> 5031</span>  FILE* xmlout = OpenFileForWriting(output_file_);</div><div class="line"><a name="l05032"></a><span class="lineno"> 5032</span>  std::stringstream stream;</div><div class="line"><a name="l05033"></a><span class="lineno"> 5033</span>  PrintXmlUnitTest(&stream, unit_test);</div><div class="line"><a name="l05034"></a><span class="lineno"> 5034</span>  fprintf(xmlout, <span class="stringliteral">"%s"</span>, StringStreamToString(&stream).c_str());</div><div class="line"><a name="l05035"></a><span class="lineno"> 5035</span>  fclose(xmlout);</div><div class="line"><a name="l05036"></a><span class="lineno"> 5036</span> }</div><div class="line"><a name="l05037"></a><span class="lineno"> 5037</span> </div><div class="line"><a name="l05038"></a><span class="lineno"> 5038</span> <span class="keywordtype">void</span> XmlUnitTestResultPrinter::ListTestsMatchingFilter(</div><div class="line"><a name="l05039"></a><span class="lineno"> 5039</span>  <span class="keyword">const</span> std::vector<TestSuite*>& test_suites) {</div><div class="line"><a name="l05040"></a><span class="lineno"> 5040</span>  FILE* xmlout = OpenFileForWriting(output_file_);</div><div class="line"><a name="l05041"></a><span class="lineno"> 5041</span>  std::stringstream stream;</div><div class="line"><a name="l05042"></a><span class="lineno"> 5042</span>  PrintXmlTestsList(&stream, test_suites);</div><div class="line"><a name="l05043"></a><span class="lineno"> 5043</span>  fprintf(xmlout, <span class="stringliteral">"%s"</span>, StringStreamToString(&stream).c_str());</div><div class="line"><a name="l05044"></a><span class="lineno"> 5044</span>  fclose(xmlout);</div><div class="line"><a name="l05045"></a><span class="lineno"> 5045</span> }</div><div class="line"><a name="l05046"></a><span class="lineno"> 5046</span> </div><div class="line"><a name="l05047"></a><span class="lineno"> 5047</span> <span class="comment">// Returns an XML-escaped copy of the input string str. If is_attribute</span></div><div class="line"><a name="l05048"></a><span class="lineno"> 5048</span> <span class="comment">// is true, the text is meant to appear as an attribute value, and</span></div><div class="line"><a name="l05049"></a><span class="lineno"> 5049</span> <span class="comment">// normalizable whitespace is preserved by replacing it with character</span></div><div class="line"><a name="l05050"></a><span class="lineno"> 5050</span> <span class="comment">// references.</span></div><div class="line"><a name="l05051"></a><span class="lineno"> 5051</span> <span class="comment">//</span></div><div class="line"><a name="l05052"></a><span class="lineno"> 5052</span> <span class="comment">// Invalid XML characters in str, if any, are stripped from the output.</span></div><div class="line"><a name="l05053"></a><span class="lineno"> 5053</span> <span class="comment">// It is expected that most, if not all, of the text processed by this</span></div><div class="line"><a name="l05054"></a><span class="lineno"> 5054</span> <span class="comment">// module will consist of ordinary English text.</span></div><div class="line"><a name="l05055"></a><span class="lineno"> 5055</span> <span class="comment">// If this module is ever modified to produce version 1.1 XML output,</span></div><div class="line"><a name="l05056"></a><span class="lineno"> 5056</span> <span class="comment">// most invalid characters can be retained using character references.</span></div><div class="line"><a name="l05057"></a><span class="lineno"> 5057</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> XmlUnitTestResultPrinter::EscapeXml(</div><div class="line"><a name="l05058"></a><span class="lineno"> 5058</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& str, <span class="keywordtype">bool</span> is_attribute) {</div><div class="line"><a name="l05059"></a><span class="lineno"> 5059</span>  Message m;</div><div class="line"><a name="l05060"></a><span class="lineno"> 5060</span> </div><div class="line"><a name="l05061"></a><span class="lineno"> 5061</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i < str.size(); ++i) {</div><div class="line"><a name="l05062"></a><span class="lineno"> 5062</span>  <span class="keyword">const</span> <span class="keywordtype">char</span> ch = str[i];</div><div class="line"><a name="l05063"></a><span class="lineno"> 5063</span>  <span class="keywordflow">switch</span> (ch) {</div><div class="line"><a name="l05064"></a><span class="lineno"> 5064</span>  <span class="keywordflow">case</span> <span class="charliteral">'<'</span>:</div><div class="line"><a name="l05065"></a><span class="lineno"> 5065</span>  m << <span class="stringliteral">"&lt;"</span>;</div><div class="line"><a name="l05066"></a><span class="lineno"> 5066</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l05067"></a><span class="lineno"> 5067</span>  <span class="keywordflow">case</span> <span class="charliteral">'>'</span>:</div><div class="line"><a name="l05068"></a><span class="lineno"> 5068</span>  m << <span class="stringliteral">"&gt;"</span>;</div><div class="line"><a name="l05069"></a><span class="lineno"> 5069</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l05070"></a><span class="lineno"> 5070</span>  <span class="keywordflow">case</span> <span class="charliteral">'&'</span>:</div><div class="line"><a name="l05071"></a><span class="lineno"> 5071</span>  m << <span class="stringliteral">"&amp;"</span>;</div><div class="line"><a name="l05072"></a><span class="lineno"> 5072</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l05073"></a><span class="lineno"> 5073</span>  <span class="keywordflow">case</span> <span class="charliteral">'\''</span>:</div><div class="line"><a name="l05074"></a><span class="lineno"> 5074</span>  <span class="keywordflow">if</span> (is_attribute)</div><div class="line"><a name="l05075"></a><span class="lineno"> 5075</span>  m << <span class="stringliteral">"&apos;"</span>;</div><div class="line"><a name="l05076"></a><span class="lineno"> 5076</span>  <span class="keywordflow">else</span></div><div class="line"><a name="l05077"></a><span class="lineno"> 5077</span>  m << <span class="charliteral">'\''</span>;</div><div class="line"><a name="l05078"></a><span class="lineno"> 5078</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l05079"></a><span class="lineno"> 5079</span>  <span class="keywordflow">case</span> <span class="charliteral">'"'</span>:</div><div class="line"><a name="l05080"></a><span class="lineno"> 5080</span>  <span class="keywordflow">if</span> (is_attribute)</div><div class="line"><a name="l05081"></a><span class="lineno"> 5081</span>  m << <span class="stringliteral">"&quot;"</span>;</div><div class="line"><a name="l05082"></a><span class="lineno"> 5082</span>  <span class="keywordflow">else</span></div><div class="line"><a name="l05083"></a><span class="lineno"> 5083</span>  m << <span class="charliteral">'"'</span>;</div><div class="line"><a name="l05084"></a><span class="lineno"> 5084</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l05085"></a><span class="lineno"> 5085</span>  <span class="keywordflow">default</span>:</div><div class="line"><a name="l05086"></a><span class="lineno"> 5086</span>  <span class="keywordflow">if</span> (IsValidXmlCharacter(ch)) {</div><div class="line"><a name="l05087"></a><span class="lineno"> 5087</span>  <span class="keywordflow">if</span> (is_attribute && IsNormalizableWhitespace(ch))</div><div class="line"><a name="l05088"></a><span class="lineno"> 5088</span>  m << <span class="stringliteral">"&#x"</span> << String::FormatByte(static_cast<unsigned char>(ch))</div><div class="line"><a name="l05089"></a><span class="lineno"> 5089</span>  << <span class="stringliteral">";"</span>;</div><div class="line"><a name="l05090"></a><span class="lineno"> 5090</span>  <span class="keywordflow">else</span></div><div class="line"><a name="l05091"></a><span class="lineno"> 5091</span>  m << ch;</div><div class="line"><a name="l05092"></a><span class="lineno"> 5092</span>  }</div><div class="line"><a name="l05093"></a><span class="lineno"> 5093</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l05094"></a><span class="lineno"> 5094</span>  }</div><div class="line"><a name="l05095"></a><span class="lineno"> 5095</span>  }</div><div class="line"><a name="l05096"></a><span class="lineno"> 5096</span> </div><div class="line"><a name="l05097"></a><span class="lineno"> 5097</span>  <span class="keywordflow">return</span> m.GetString();</div><div class="line"><a name="l05098"></a><span class="lineno"> 5098</span> }</div><div class="line"><a name="l05099"></a><span class="lineno"> 5099</span> </div><div class="line"><a name="l05100"></a><span class="lineno"> 5100</span> <span class="comment">// Returns the given string with all characters invalid in XML removed.</span></div><div class="line"><a name="l05101"></a><span class="lineno"> 5101</span> <span class="comment">// Currently invalid characters are dropped from the string. An</span></div><div class="line"><a name="l05102"></a><span class="lineno"> 5102</span> <span class="comment">// alternative is to replace them with certain characters such as . or ?.</span></div><div class="line"><a name="l05103"></a><span class="lineno"> 5103</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> XmlUnitTestResultPrinter::RemoveInvalidXmlCharacters(</div><div class="line"><a name="l05104"></a><span class="lineno"> 5104</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& str) {</div><div class="line"><a name="l05105"></a><span class="lineno"> 5105</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> output;</div><div class="line"><a name="l05106"></a><span class="lineno"> 5106</span>  output.reserve(str.size());</div><div class="line"><a name="l05107"></a><span class="lineno"> 5107</span>  <span class="keywordflow">for</span> (std::string::const_iterator it = str.begin(); it != str.end(); ++it)</div><div class="line"><a name="l05108"></a><span class="lineno"> 5108</span>  <span class="keywordflow">if</span> (IsValidXmlCharacter(*it))</div><div class="line"><a name="l05109"></a><span class="lineno"> 5109</span>  output.push_back(*it);</div><div class="line"><a name="l05110"></a><span class="lineno"> 5110</span> </div><div class="line"><a name="l05111"></a><span class="lineno"> 5111</span>  <span class="keywordflow">return</span> output;</div><div class="line"><a name="l05112"></a><span class="lineno"> 5112</span> }</div><div class="line"><a name="l05113"></a><span class="lineno"> 5113</span> </div><div class="line"><a name="l05114"></a><span class="lineno"> 5114</span> <span class="comment">// The following routines generate an XML representation of a UnitTest</span></div><div class="line"><a name="l05115"></a><span class="lineno"> 5115</span> <span class="comment">// object.</span></div><div class="line"><a name="l05116"></a><span class="lineno"> 5116</span> <span class="comment">// GOOGLETEST_CM0009 DO NOT DELETE</span></div><div class="line"><a name="l05117"></a><span class="lineno"> 5117</span> <span class="comment">//</span></div><div class="line"><a name="l05118"></a><span class="lineno"> 5118</span> <span class="comment">// This is how Google Test concepts map to the DTD:</span></div><div class="line"><a name="l05119"></a><span class="lineno"> 5119</span> <span class="comment">//</span></div><div class="line"><a name="l05120"></a><span class="lineno"> 5120</span> <span class="comment">// <testsuites name="AllTests"> <-- corresponds to a UnitTest object</span></div><div class="line"><a name="l05121"></a><span class="lineno"> 5121</span> <span class="comment">// <testsuite name="testcase-name"> <-- corresponds to a TestSuite object</span></div><div class="line"><a name="l05122"></a><span class="lineno"> 5122</span> <span class="comment">// <testcase name="test-name"> <-- corresponds to a TestInfo object</span></div><div class="line"><a name="l05123"></a><span class="lineno"> 5123</span> <span class="comment">// <failure message="...">...</failure></span></div><div class="line"><a name="l05124"></a><span class="lineno"> 5124</span> <span class="comment">// <failure message="...">...</failure></span></div><div class="line"><a name="l05125"></a><span class="lineno"> 5125</span> <span class="comment">// <failure message="...">...</failure></span></div><div class="line"><a name="l05126"></a><span class="lineno"> 5126</span> <span class="comment">// <-- individual assertion failures</span></div><div class="line"><a name="l05127"></a><span class="lineno"> 5127</span> <span class="comment">// </testcase></span></div><div class="line"><a name="l05128"></a><span class="lineno"> 5128</span> <span class="comment">// </testsuite></span></div><div class="line"><a name="l05129"></a><span class="lineno"> 5129</span> <span class="comment">// </testsuites></span></div><div class="line"><a name="l05130"></a><span class="lineno"> 5130</span> </div><div class="line"><a name="l05131"></a><span class="lineno"> 5131</span> <span class="comment">// Formats the given time in milliseconds as seconds.</span></div><div class="line"><a name="l05132"></a><span class="lineno"> 5132</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> FormatTimeInMillisAsSeconds(<a class="code" href="namespacetesting_1_1internal.html#a66a845df404b38fe85c5e14a069f255a">TimeInMillis</a> ms) {</div><div class="line"><a name="l05133"></a><span class="lineno"> 5133</span>  ::std::stringstream ss;</div><div class="line"><a name="l05134"></a><span class="lineno"> 5134</span>  ss << (static_cast<double>(ms) * 1e-3);</div><div class="line"><a name="l05135"></a><span class="lineno"> 5135</span>  <span class="keywordflow">return</span> ss.str();</div><div class="line"><a name="l05136"></a><span class="lineno"> 5136</span> }</div><div class="line"><a name="l05137"></a><span class="lineno"> 5137</span> </div><div class="line"><a name="l05138"></a><span class="lineno"> 5138</span> <span class="keyword">static</span> <span class="keywordtype">bool</span> PortableLocaltime(time_t seconds, <span class="keyword">struct</span> tm* out) {</div><div class="line"><a name="l05139"></a><span class="lineno"> 5139</span> <span class="preprocessor">#if defined(_MSC_VER)</span></div><div class="line"><a name="l05140"></a><span class="lineno"> 5140</span>  <span class="keywordflow">return</span> localtime_s(out, &seconds) == 0;</div><div class="line"><a name="l05141"></a><span class="lineno"> 5141</span> <span class="preprocessor">#elif defined(__MINGW32__) || defined(__MINGW64__)</span></div><div class="line"><a name="l05142"></a><span class="lineno"> 5142</span>  <span class="comment">// MINGW <time.h> provides neither localtime_r nor localtime_s, but uses</span></div><div class="line"><a name="l05143"></a><span class="lineno"> 5143</span>  <span class="comment">// Windows' localtime(), which has a thread-local tm buffer.</span></div><div class="line"><a name="l05144"></a><span class="lineno"> 5144</span>  <span class="keyword">struct </span>tm* tm_ptr = localtime(&seconds); <span class="comment">// NOLINT</span></div><div class="line"><a name="l05145"></a><span class="lineno"> 5145</span>  <span class="keywordflow">if</span> (tm_ptr == <span class="keyword">nullptr</span>) <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l05146"></a><span class="lineno"> 5146</span>  *out = *tm_ptr;</div><div class="line"><a name="l05147"></a><span class="lineno"> 5147</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l05148"></a><span class="lineno"> 5148</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l05149"></a><span class="lineno"> 5149</span>  <span class="keywordflow">return</span> localtime_r(&seconds, out) != <span class="keyword">nullptr</span>;</div><div class="line"><a name="l05150"></a><span class="lineno"> 5150</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l05151"></a><span class="lineno"> 5151</span> }</div><div class="line"><a name="l05152"></a><span class="lineno"> 5152</span> </div><div class="line"><a name="l05153"></a><span class="lineno"> 5153</span> <span class="comment">// Converts the given epoch time in milliseconds to a date string in the ISO</span></div><div class="line"><a name="l05154"></a><span class="lineno"> 5154</span> <span class="comment">// 8601 format, without the timezone information.</span></div><div class="line"><a name="l05155"></a><span class="lineno"> 5155</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> FormatEpochTimeInMillisAsIso8601(<a class="code" href="namespacetesting_1_1internal.html#a66a845df404b38fe85c5e14a069f255a">TimeInMillis</a> ms) {</div><div class="line"><a name="l05156"></a><span class="lineno"> 5156</span>  <span class="keyword">struct </span>tm time_struct;</div><div class="line"><a name="l05157"></a><span class="lineno"> 5157</span>  <span class="keywordflow">if</span> (!PortableLocaltime(static_cast<time_t>(ms / 1000), &time_struct))</div><div class="line"><a name="l05158"></a><span class="lineno"> 5158</span>  <span class="keywordflow">return</span> <span class="stringliteral">""</span>;</div><div class="line"><a name="l05159"></a><span class="lineno"> 5159</span>  <span class="comment">// YYYY-MM-DDThh:mm:ss</span></div><div class="line"><a name="l05160"></a><span class="lineno"> 5160</span>  <span class="keywordflow">return</span> <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(time_struct.tm_year + 1900) + <span class="stringliteral">"-"</span> +</div><div class="line"><a name="l05161"></a><span class="lineno"> 5161</span>  String::FormatIntWidth2(time_struct.tm_mon + 1) + <span class="stringliteral">"-"</span> +</div><div class="line"><a name="l05162"></a><span class="lineno"> 5162</span>  String::FormatIntWidth2(time_struct.tm_mday) + <span class="stringliteral">"T"</span> +</div><div class="line"><a name="l05163"></a><span class="lineno"> 5163</span>  String::FormatIntWidth2(time_struct.tm_hour) + <span class="stringliteral">":"</span> +</div><div class="line"><a name="l05164"></a><span class="lineno"> 5164</span>  String::FormatIntWidth2(time_struct.tm_min) + <span class="stringliteral">":"</span> +</div><div class="line"><a name="l05165"></a><span class="lineno"> 5165</span>  String::FormatIntWidth2(time_struct.tm_sec);</div><div class="line"><a name="l05166"></a><span class="lineno"> 5166</span> }</div><div class="line"><a name="l05167"></a><span class="lineno"> 5167</span> </div><div class="line"><a name="l05168"></a><span class="lineno"> 5168</span> <span class="comment">// Streams an XML CDATA section, escaping invalid CDATA sequences as needed.</span></div><div class="line"><a name="l05169"></a><span class="lineno"> 5169</span> <span class="keywordtype">void</span> XmlUnitTestResultPrinter::OutputXmlCDataSection(::std::ostream* stream,</div><div class="line"><a name="l05170"></a><span class="lineno"> 5170</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* data) {</div><div class="line"><a name="l05171"></a><span class="lineno"> 5171</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* segment = data;</div><div class="line"><a name="l05172"></a><span class="lineno"> 5172</span>  *stream << <span class="stringliteral">"<![CDATA["</span>;</div><div class="line"><a name="l05173"></a><span class="lineno"> 5173</span>  <span class="keywordflow">for</span> (;;) {</div><div class="line"><a name="l05174"></a><span class="lineno"> 5174</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> next_segment = strstr(segment, <span class="stringliteral">"]]>"</span>);</div><div class="line"><a name="l05175"></a><span class="lineno"> 5175</span>  <span class="keywordflow">if</span> (next_segment != <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l05176"></a><span class="lineno"> 5176</span>  stream->write(</div><div class="line"><a name="l05177"></a><span class="lineno"> 5177</span>  segment, static_cast<std::streamsize>(next_segment - segment));</div><div class="line"><a name="l05178"></a><span class="lineno"> 5178</span>  *stream << <span class="stringliteral">"]]>]]&gt;<![CDATA["</span>;</div><div class="line"><a name="l05179"></a><span class="lineno"> 5179</span>  segment = next_segment + strlen(<span class="stringliteral">"]]>"</span>);</div><div class="line"><a name="l05180"></a><span class="lineno"> 5180</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l05181"></a><span class="lineno"> 5181</span>  *stream << segment;</div><div class="line"><a name="l05182"></a><span class="lineno"> 5182</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l05183"></a><span class="lineno"> 5183</span>  }</div><div class="line"><a name="l05184"></a><span class="lineno"> 5184</span>  }</div><div class="line"><a name="l05185"></a><span class="lineno"> 5185</span>  *stream << <span class="stringliteral">"]]>"</span>;</div><div class="line"><a name="l05186"></a><span class="lineno"> 5186</span> }</div><div class="line"><a name="l05187"></a><span class="lineno"> 5187</span> </div><div class="line"><a name="l05188"></a><span class="lineno"> 5188</span> <span class="keywordtype">void</span> XmlUnitTestResultPrinter::OutputXmlAttribute(</div><div class="line"><a name="l05189"></a><span class="lineno"> 5189</span>  std::ostream* stream,</div><div class="line"><a name="l05190"></a><span class="lineno"> 5190</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& element_name,</div><div class="line"><a name="l05191"></a><span class="lineno"> 5191</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& name,</div><div class="line"><a name="l05192"></a><span class="lineno"> 5192</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& value) {</div><div class="line"><a name="l05193"></a><span class="lineno"> 5193</span>  <span class="keyword">const</span> std::vector<std::string>& allowed_names =</div><div class="line"><a name="l05194"></a><span class="lineno"> 5194</span>  GetReservedAttributesForElement(element_name);</div><div class="line"><a name="l05195"></a><span class="lineno"> 5195</span> </div><div class="line"><a name="l05196"></a><span class="lineno"> 5196</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(<a class="code" href="namespaceutl_1_1meta.html#af4c9b6350bba98cc0dd73e87cb4ce413">std::find</a>(allowed_names.begin(), allowed_names.end(), name) !=</div><div class="line"><a name="l05197"></a><span class="lineno"> 5197</span>  allowed_names.end())</div><div class="line"><a name="l05198"></a><span class="lineno"> 5198</span>  << <span class="stringliteral">"Attribute "</span> << name << <span class="stringliteral">" is not allowed for element <"</span> << element_name</div><div class="line"><a name="l05199"></a><span class="lineno"> 5199</span>  << <span class="stringliteral">">."</span>;</div><div class="line"><a name="l05200"></a><span class="lineno"> 5200</span> </div><div class="line"><a name="l05201"></a><span class="lineno"> 5201</span>  *stream << <span class="stringliteral">" "</span> << name << <span class="stringliteral">"=\""</span> << EscapeXmlAttribute(value) << <span class="stringliteral">"\""</span>;</div><div class="line"><a name="l05202"></a><span class="lineno"> 5202</span> }</div><div class="line"><a name="l05203"></a><span class="lineno"> 5203</span> </div><div class="line"><a name="l05204"></a><span class="lineno"> 5204</span> <span class="comment">// Prints an XML representation of a TestInfo object.</span></div><div class="line"><a name="l05205"></a><span class="lineno"> 5205</span> <span class="keywordtype">void</span> XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,</div><div class="line"><a name="l05206"></a><span class="lineno"> 5206</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* test_suite_name,</div><div class="line"><a name="l05207"></a><span class="lineno"> 5207</span>  <span class="keyword">const</span> TestInfo& test_info) {</div><div class="line"><a name="l05208"></a><span class="lineno"> 5208</span>  <span class="keyword">const</span> TestResult& result = *test_info.result();</div><div class="line"><a name="l05209"></a><span class="lineno"> 5209</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> kTestsuite = <span class="stringliteral">"testcase"</span>;</div><div class="line"><a name="l05210"></a><span class="lineno"> 5210</span> </div><div class="line"><a name="l05211"></a><span class="lineno"> 5211</span>  <span class="keywordflow">if</span> (test_info.is_in_another_shard()) {</div><div class="line"><a name="l05212"></a><span class="lineno"> 5212</span>  <span class="keywordflow">return</span>;</div><div class="line"><a name="l05213"></a><span class="lineno"> 5213</span>  }</div><div class="line"><a name="l05214"></a><span class="lineno"> 5214</span> </div><div class="line"><a name="l05215"></a><span class="lineno"> 5215</span>  *stream << <span class="stringliteral">" <testcase"</span>;</div><div class="line"><a name="l05216"></a><span class="lineno"> 5216</span>  OutputXmlAttribute(stream, kTestsuite, <span class="stringliteral">"name"</span>, test_info.name());</div><div class="line"><a name="l05217"></a><span class="lineno"> 5217</span> </div><div class="line"><a name="l05218"></a><span class="lineno"> 5218</span>  <span class="keywordflow">if</span> (test_info.value_param() != <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l05219"></a><span class="lineno"> 5219</span>  OutputXmlAttribute(stream, kTestsuite, <span class="stringliteral">"value_param"</span>,</div><div class="line"><a name="l05220"></a><span class="lineno"> 5220</span>  test_info.value_param());</div><div class="line"><a name="l05221"></a><span class="lineno"> 5221</span>  }</div><div class="line"><a name="l05222"></a><span class="lineno"> 5222</span>  <span class="keywordflow">if</span> (test_info.type_param() != <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l05223"></a><span class="lineno"> 5223</span>  OutputXmlAttribute(stream, kTestsuite, <span class="stringliteral">"type_param"</span>,</div><div class="line"><a name="l05224"></a><span class="lineno"> 5224</span>  test_info.type_param());</div><div class="line"><a name="l05225"></a><span class="lineno"> 5225</span>  }</div><div class="line"><a name="l05226"></a><span class="lineno"> 5226</span>  <span class="keywordflow">if</span> (<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(list_tests)) {</div><div class="line"><a name="l05227"></a><span class="lineno"> 5227</span>  OutputXmlAttribute(stream, kTestsuite, <span class="stringliteral">"file"</span>, test_info.file());</div><div class="line"><a name="l05228"></a><span class="lineno"> 5228</span>  OutputXmlAttribute(stream, kTestsuite, <span class="stringliteral">"line"</span>,</div><div class="line"><a name="l05229"></a><span class="lineno"> 5229</span>  <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(test_info.line()));</div><div class="line"><a name="l05230"></a><span class="lineno"> 5230</span>  *stream << <span class="stringliteral">" />\n"</span>;</div><div class="line"><a name="l05231"></a><span class="lineno"> 5231</span>  <span class="keywordflow">return</span>;</div><div class="line"><a name="l05232"></a><span class="lineno"> 5232</span>  }</div><div class="line"><a name="l05233"></a><span class="lineno"> 5233</span> </div><div class="line"><a name="l05234"></a><span class="lineno"> 5234</span>  OutputXmlAttribute(</div><div class="line"><a name="l05235"></a><span class="lineno"> 5235</span>  stream, kTestsuite, <span class="stringliteral">"status"</span>,</div><div class="line"><a name="l05236"></a><span class="lineno"> 5236</span>  result.Skipped() ? <span class="stringliteral">"skipped"</span> : test_info.should_run() ? <span class="stringliteral">"run"</span> : <span class="stringliteral">"notrun"</span>);</div><div class="line"><a name="l05237"></a><span class="lineno"> 5237</span>  OutputXmlAttribute(stream, kTestsuite, <span class="stringliteral">"time"</span>,</div><div class="line"><a name="l05238"></a><span class="lineno"> 5238</span>  FormatTimeInMillisAsSeconds(result.elapsed_time()));</div><div class="line"><a name="l05239"></a><span class="lineno"> 5239</span>  OutputXmlAttribute(stream, kTestsuite, <span class="stringliteral">"classname"</span>, test_suite_name);</div><div class="line"><a name="l05240"></a><span class="lineno"> 5240</span> </div><div class="line"><a name="l05241"></a><span class="lineno"> 5241</span>  <span class="keywordtype">int</span> failures = 0;</div><div class="line"><a name="l05242"></a><span class="lineno"> 5242</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < result.total_part_count(); ++i) {</div><div class="line"><a name="l05243"></a><span class="lineno"> 5243</span>  <span class="keyword">const</span> TestPartResult& part = result.GetTestPartResult(i);</div><div class="line"><a name="l05244"></a><span class="lineno"> 5244</span>  <span class="keywordflow">if</span> (part.failed()) {</div><div class="line"><a name="l05245"></a><span class="lineno"> 5245</span>  <span class="keywordflow">if</span> (++failures == 1) {</div><div class="line"><a name="l05246"></a><span class="lineno"> 5246</span>  *stream << <span class="stringliteral">">\n"</span>;</div><div class="line"><a name="l05247"></a><span class="lineno"> 5247</span>  }</div><div class="line"><a name="l05248"></a><span class="lineno"> 5248</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> location =</div><div class="line"><a name="l05249"></a><span class="lineno"> 5249</span>  <a class="code" href="namespacetesting_1_1internal.html#a1ee4cde97868c53e442d3182496a9f3c">internal::FormatCompilerIndependentFileLocation</a>(part.file_name(),</div><div class="line"><a name="l05250"></a><span class="lineno"> 5250</span>  part.line_number());</div><div class="line"><a name="l05251"></a><span class="lineno"> 5251</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> summary = location + <span class="stringliteral">"\n"</span> + part.summary();</div><div class="line"><a name="l05252"></a><span class="lineno"> 5252</span>  *stream << <span class="stringliteral">" <failure message=\""</span></div><div class="line"><a name="l05253"></a><span class="lineno"> 5253</span>  << EscapeXmlAttribute(summary.c_str())</div><div class="line"><a name="l05254"></a><span class="lineno"> 5254</span>  << <span class="stringliteral">"\" type=\"\">"</span>;</div><div class="line"><a name="l05255"></a><span class="lineno"> 5255</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> detail = location + <span class="stringliteral">"\n"</span> + part.message();</div><div class="line"><a name="l05256"></a><span class="lineno"> 5256</span>  OutputXmlCDataSection(stream, RemoveInvalidXmlCharacters(detail).c_str());</div><div class="line"><a name="l05257"></a><span class="lineno"> 5257</span>  *stream << <span class="stringliteral">"</failure>\n"</span>;</div><div class="line"><a name="l05258"></a><span class="lineno"> 5258</span>  }</div><div class="line"><a name="l05259"></a><span class="lineno"> 5259</span>  }</div><div class="line"><a name="l05260"></a><span class="lineno"> 5260</span> </div><div class="line"><a name="l05261"></a><span class="lineno"> 5261</span>  <span class="keywordflow">if</span> (failures == 0 && result.test_property_count() == 0) {</div><div class="line"><a name="l05262"></a><span class="lineno"> 5262</span>  *stream << <span class="stringliteral">" />\n"</span>;</div><div class="line"><a name="l05263"></a><span class="lineno"> 5263</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l05264"></a><span class="lineno"> 5264</span>  <span class="keywordflow">if</span> (failures == 0) {</div><div class="line"><a name="l05265"></a><span class="lineno"> 5265</span>  *stream << <span class="stringliteral">">\n"</span>;</div><div class="line"><a name="l05266"></a><span class="lineno"> 5266</span>  }</div><div class="line"><a name="l05267"></a><span class="lineno"> 5267</span>  OutputXmlTestProperties(stream, result);</div><div class="line"><a name="l05268"></a><span class="lineno"> 5268</span>  *stream << <span class="stringliteral">" </testcase>\n"</span>;</div><div class="line"><a name="l05269"></a><span class="lineno"> 5269</span>  }</div><div class="line"><a name="l05270"></a><span class="lineno"> 5270</span> }</div><div class="line"><a name="l05271"></a><span class="lineno"> 5271</span> </div><div class="line"><a name="l05272"></a><span class="lineno"> 5272</span> <span class="comment">// Prints an XML representation of a TestSuite object</span></div><div class="line"><a name="l05273"></a><span class="lineno"> 5273</span> <span class="keywordtype">void</span> XmlUnitTestResultPrinter::PrintXmlTestSuite(std::ostream* stream,</div><div class="line"><a name="l05274"></a><span class="lineno"> 5274</span>  <span class="keyword">const</span> TestSuite& test_suite) {</div><div class="line"><a name="l05275"></a><span class="lineno"> 5275</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> kTestsuite = <span class="stringliteral">"testsuite"</span>;</div><div class="line"><a name="l05276"></a><span class="lineno"> 5276</span>  *stream << <span class="stringliteral">" <"</span> << kTestsuite;</div><div class="line"><a name="l05277"></a><span class="lineno"> 5277</span>  OutputXmlAttribute(stream, kTestsuite, <span class="stringliteral">"name"</span>, test_suite.name());</div><div class="line"><a name="l05278"></a><span class="lineno"> 5278</span>  OutputXmlAttribute(stream, kTestsuite, <span class="stringliteral">"tests"</span>,</div><div class="line"><a name="l05279"></a><span class="lineno"> 5279</span>  <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(test_suite.reportable_test_count()));</div><div class="line"><a name="l05280"></a><span class="lineno"> 5280</span>  <span class="keywordflow">if</span> (!<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(list_tests)) {</div><div class="line"><a name="l05281"></a><span class="lineno"> 5281</span>  OutputXmlAttribute(stream, kTestsuite, <span class="stringliteral">"failures"</span>,</div><div class="line"><a name="l05282"></a><span class="lineno"> 5282</span>  <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(test_suite.failed_test_count()));</div><div class="line"><a name="l05283"></a><span class="lineno"> 5283</span>  OutputXmlAttribute(</div><div class="line"><a name="l05284"></a><span class="lineno"> 5284</span>  stream, kTestsuite, <span class="stringliteral">"disabled"</span>,</div><div class="line"><a name="l05285"></a><span class="lineno"> 5285</span>  <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(test_suite.reportable_disabled_test_count()));</div><div class="line"><a name="l05286"></a><span class="lineno"> 5286</span>  OutputXmlAttribute(stream, kTestsuite, <span class="stringliteral">"errors"</span>, <span class="stringliteral">"0"</span>);</div><div class="line"><a name="l05287"></a><span class="lineno"> 5287</span>  OutputXmlAttribute(stream, kTestsuite, <span class="stringliteral">"time"</span>,</div><div class="line"><a name="l05288"></a><span class="lineno"> 5288</span>  FormatTimeInMillisAsSeconds(test_suite.elapsed_time()));</div><div class="line"><a name="l05289"></a><span class="lineno"> 5289</span>  *stream << TestPropertiesAsXmlAttributes(test_suite.ad_hoc_test_result());</div><div class="line"><a name="l05290"></a><span class="lineno"> 5290</span>  }</div><div class="line"><a name="l05291"></a><span class="lineno"> 5291</span>  *stream << <span class="stringliteral">">\n"</span>;</div><div class="line"><a name="l05292"></a><span class="lineno"> 5292</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < test_suite.total_test_count(); ++i) {</div><div class="line"><a name="l05293"></a><span class="lineno"> 5293</span>  <span class="keywordflow">if</span> (test_suite.GetTestInfo(i)->is_reportable())</div><div class="line"><a name="l05294"></a><span class="lineno"> 5294</span>  OutputXmlTestInfo(stream, test_suite.name(), *test_suite.GetTestInfo(i));</div><div class="line"><a name="l05295"></a><span class="lineno"> 5295</span>  }</div><div class="line"><a name="l05296"></a><span class="lineno"> 5296</span>  *stream << <span class="stringliteral">" </"</span> << kTestsuite << <span class="stringliteral">">\n"</span>;</div><div class="line"><a name="l05297"></a><span class="lineno"> 5297</span> }</div><div class="line"><a name="l05298"></a><span class="lineno"> 5298</span> </div><div class="line"><a name="l05299"></a><span class="lineno"> 5299</span> <span class="comment">// Prints an XML summary of unit_test to output stream out.</span></div><div class="line"><a name="l05300"></a><span class="lineno"> 5300</span> <span class="keywordtype">void</span> XmlUnitTestResultPrinter::PrintXmlUnitTest(std::ostream* stream,</div><div class="line"><a name="l05301"></a><span class="lineno"> 5301</span>  <span class="keyword">const</span> UnitTest& unit_test) {</div><div class="line"><a name="l05302"></a><span class="lineno"> 5302</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> kTestsuites = <span class="stringliteral">"testsuites"</span>;</div><div class="line"><a name="l05303"></a><span class="lineno"> 5303</span> </div><div class="line"><a name="l05304"></a><span class="lineno"> 5304</span>  *stream << <span class="stringliteral">"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"</span>;</div><div class="line"><a name="l05305"></a><span class="lineno"> 5305</span>  *stream << <span class="stringliteral">"<"</span> << kTestsuites;</div><div class="line"><a name="l05306"></a><span class="lineno"> 5306</span> </div><div class="line"><a name="l05307"></a><span class="lineno"> 5307</span>  OutputXmlAttribute(stream, kTestsuites, <span class="stringliteral">"tests"</span>,</div><div class="line"><a name="l05308"></a><span class="lineno"> 5308</span>  <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(unit_test.reportable_test_count()));</div><div class="line"><a name="l05309"></a><span class="lineno"> 5309</span>  OutputXmlAttribute(stream, kTestsuites, <span class="stringliteral">"failures"</span>,</div><div class="line"><a name="l05310"></a><span class="lineno"> 5310</span>  <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(unit_test.failed_test_count()));</div><div class="line"><a name="l05311"></a><span class="lineno"> 5311</span>  OutputXmlAttribute(</div><div class="line"><a name="l05312"></a><span class="lineno"> 5312</span>  stream, kTestsuites, <span class="stringliteral">"disabled"</span>,</div><div class="line"><a name="l05313"></a><span class="lineno"> 5313</span>  <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(unit_test.reportable_disabled_test_count()));</div><div class="line"><a name="l05314"></a><span class="lineno"> 5314</span>  OutputXmlAttribute(stream, kTestsuites, <span class="stringliteral">"errors"</span>, <span class="stringliteral">"0"</span>);</div><div class="line"><a name="l05315"></a><span class="lineno"> 5315</span>  OutputXmlAttribute(</div><div class="line"><a name="l05316"></a><span class="lineno"> 5316</span>  stream, kTestsuites, <span class="stringliteral">"timestamp"</span>,</div><div class="line"><a name="l05317"></a><span class="lineno"> 5317</span>  FormatEpochTimeInMillisAsIso8601(unit_test.start_timestamp()));</div><div class="line"><a name="l05318"></a><span class="lineno"> 5318</span>  OutputXmlAttribute(stream, kTestsuites, <span class="stringliteral">"time"</span>,</div><div class="line"><a name="l05319"></a><span class="lineno"> 5319</span>  FormatTimeInMillisAsSeconds(unit_test.elapsed_time()));</div><div class="line"><a name="l05320"></a><span class="lineno"> 5320</span> </div><div class="line"><a name="l05321"></a><span class="lineno"> 5321</span>  <span class="keywordflow">if</span> (<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(shuffle)) {</div><div class="line"><a name="l05322"></a><span class="lineno"> 5322</span>  OutputXmlAttribute(stream, kTestsuites, <span class="stringliteral">"random_seed"</span>,</div><div class="line"><a name="l05323"></a><span class="lineno"> 5323</span>  <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(unit_test.random_seed()));</div><div class="line"><a name="l05324"></a><span class="lineno"> 5324</span>  }</div><div class="line"><a name="l05325"></a><span class="lineno"> 5325</span>  *stream << TestPropertiesAsXmlAttributes(unit_test.ad_hoc_test_result());</div><div class="line"><a name="l05326"></a><span class="lineno"> 5326</span> </div><div class="line"><a name="l05327"></a><span class="lineno"> 5327</span>  OutputXmlAttribute(stream, kTestsuites, <span class="stringliteral">"name"</span>, <span class="stringliteral">"AllTests"</span>);</div><div class="line"><a name="l05328"></a><span class="lineno"> 5328</span>  *stream << <span class="stringliteral">">\n"</span>;</div><div class="line"><a name="l05329"></a><span class="lineno"> 5329</span> </div><div class="line"><a name="l05330"></a><span class="lineno"> 5330</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < unit_test.total_test_suite_count(); ++i) {</div><div class="line"><a name="l05331"></a><span class="lineno"> 5331</span>  <span class="keywordflow">if</span> (unit_test.GetTestSuite(i)->reportable_test_count() > 0)</div><div class="line"><a name="l05332"></a><span class="lineno"> 5332</span>  PrintXmlTestSuite(stream, *unit_test.GetTestSuite(i));</div><div class="line"><a name="l05333"></a><span class="lineno"> 5333</span>  }</div><div class="line"><a name="l05334"></a><span class="lineno"> 5334</span>  *stream << <span class="stringliteral">"</"</span> << kTestsuites << <span class="stringliteral">">\n"</span>;</div><div class="line"><a name="l05335"></a><span class="lineno"> 5335</span> }</div><div class="line"><a name="l05336"></a><span class="lineno"> 5336</span> </div><div class="line"><a name="l05337"></a><span class="lineno"> 5337</span> <span class="keywordtype">void</span> XmlUnitTestResultPrinter::PrintXmlTestsList(</div><div class="line"><a name="l05338"></a><span class="lineno"> 5338</span>  std::ostream* stream, <span class="keyword">const</span> std::vector<TestSuite*>& test_suites) {</div><div class="line"><a name="l05339"></a><span class="lineno"> 5339</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> kTestsuites = <span class="stringliteral">"testsuites"</span>;</div><div class="line"><a name="l05340"></a><span class="lineno"> 5340</span> </div><div class="line"><a name="l05341"></a><span class="lineno"> 5341</span>  *stream << <span class="stringliteral">"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"</span>;</div><div class="line"><a name="l05342"></a><span class="lineno"> 5342</span>  *stream << <span class="stringliteral">"<"</span> << kTestsuites;</div><div class="line"><a name="l05343"></a><span class="lineno"> 5343</span> </div><div class="line"><a name="l05344"></a><span class="lineno"> 5344</span>  <span class="keywordtype">int</span> total_tests = 0;</div><div class="line"><a name="l05345"></a><span class="lineno"> 5345</span>  <span class="keywordflow">for</span> (<span class="keyword">auto</span> test_suite : test_suites) {</div><div class="line"><a name="l05346"></a><span class="lineno"> 5346</span>  total_tests += test_suite->total_test_count();</div><div class="line"><a name="l05347"></a><span class="lineno"> 5347</span>  }</div><div class="line"><a name="l05348"></a><span class="lineno"> 5348</span>  OutputXmlAttribute(stream, kTestsuites, <span class="stringliteral">"tests"</span>,</div><div class="line"><a name="l05349"></a><span class="lineno"> 5349</span>  <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(total_tests));</div><div class="line"><a name="l05350"></a><span class="lineno"> 5350</span>  OutputXmlAttribute(stream, kTestsuites, <span class="stringliteral">"name"</span>, <span class="stringliteral">"AllTests"</span>);</div><div class="line"><a name="l05351"></a><span class="lineno"> 5351</span>  *stream << <span class="stringliteral">">\n"</span>;</div><div class="line"><a name="l05352"></a><span class="lineno"> 5352</span> </div><div class="line"><a name="l05353"></a><span class="lineno"> 5353</span>  <span class="keywordflow">for</span> (<span class="keyword">auto</span> test_suite : test_suites) {</div><div class="line"><a name="l05354"></a><span class="lineno"> 5354</span>  PrintXmlTestSuite(stream, *test_suite);</div><div class="line"><a name="l05355"></a><span class="lineno"> 5355</span>  }</div><div class="line"><a name="l05356"></a><span class="lineno"> 5356</span>  *stream << <span class="stringliteral">"</"</span> << kTestsuites << <span class="stringliteral">">\n"</span>;</div><div class="line"><a name="l05357"></a><span class="lineno"> 5357</span> }</div><div class="line"><a name="l05358"></a><span class="lineno"> 5358</span> </div><div class="line"><a name="l05359"></a><span class="lineno"> 5359</span> <span class="comment">// Produces a string representing the test properties in a result as space</span></div><div class="line"><a name="l05360"></a><span class="lineno"> 5360</span> <span class="comment">// delimited XML attributes based on the property key="value" pairs.</span></div><div class="line"><a name="l05361"></a><span class="lineno"> 5361</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> XmlUnitTestResultPrinter::TestPropertiesAsXmlAttributes(</div><div class="line"><a name="l05362"></a><span class="lineno"> 5362</span>  <span class="keyword">const</span> TestResult& result) {</div><div class="line"><a name="l05363"></a><span class="lineno"> 5363</span>  Message attributes;</div><div class="line"><a name="l05364"></a><span class="lineno"> 5364</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < result.test_property_count(); ++i) {</div><div class="line"><a name="l05365"></a><span class="lineno"> 5365</span>  <span class="keyword">const</span> TestProperty& <span class="keyword">property</span> = result.GetTestProperty(i);</div><div class="line"><a name="l05366"></a><span class="lineno"> 5366</span>  attributes << <span class="stringliteral">" "</span> << <span class="keyword">property</span>.key() << <span class="stringliteral">"="</span></div><div class="line"><a name="l05367"></a><span class="lineno"> 5367</span>  << <span class="stringliteral">"\""</span> << EscapeXmlAttribute(property.value()) << <span class="stringliteral">"\""</span>;</div><div class="line"><a name="l05368"></a><span class="lineno"> 5368</span>  }</div><div class="line"><a name="l05369"></a><span class="lineno"> 5369</span>  <span class="keywordflow">return</span> attributes.GetString();</div><div class="line"><a name="l05370"></a><span class="lineno"> 5370</span> }</div><div class="line"><a name="l05371"></a><span class="lineno"> 5371</span> </div><div class="line"><a name="l05372"></a><span class="lineno"> 5372</span> <span class="keywordtype">void</span> XmlUnitTestResultPrinter::OutputXmlTestProperties(</div><div class="line"><a name="l05373"></a><span class="lineno"> 5373</span>  std::ostream* stream, <span class="keyword">const</span> TestResult& result) {</div><div class="line"><a name="l05374"></a><span class="lineno"> 5374</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> kProperties = <span class="stringliteral">"properties"</span>;</div><div class="line"><a name="l05375"></a><span class="lineno"> 5375</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> kProperty = <span class="stringliteral">"property"</span>;</div><div class="line"><a name="l05376"></a><span class="lineno"> 5376</span> </div><div class="line"><a name="l05377"></a><span class="lineno"> 5377</span>  <span class="keywordflow">if</span> (result.test_property_count() <= 0) {</div><div class="line"><a name="l05378"></a><span class="lineno"> 5378</span>  <span class="keywordflow">return</span>;</div><div class="line"><a name="l05379"></a><span class="lineno"> 5379</span>  }</div><div class="line"><a name="l05380"></a><span class="lineno"> 5380</span> </div><div class="line"><a name="l05381"></a><span class="lineno"> 5381</span>  *stream << <span class="stringliteral">"<"</span> << kProperties << <span class="stringliteral">">\n"</span>;</div><div class="line"><a name="l05382"></a><span class="lineno"> 5382</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < result.test_property_count(); ++i) {</div><div class="line"><a name="l05383"></a><span class="lineno"> 5383</span>  <span class="keyword">const</span> TestProperty& <span class="keyword">property</span> = result.GetTestProperty(i);</div><div class="line"><a name="l05384"></a><span class="lineno"> 5384</span>  *stream << <span class="stringliteral">"<"</span> << kProperty;</div><div class="line"><a name="l05385"></a><span class="lineno"> 5385</span>  *stream << <span class="stringliteral">" name=\""</span> << EscapeXmlAttribute(property.key()) << <span class="stringliteral">"\""</span>;</div><div class="line"><a name="l05386"></a><span class="lineno"> 5386</span>  *stream << <span class="stringliteral">" value=\""</span> << EscapeXmlAttribute(property.value()) << <span class="stringliteral">"\""</span>;</div><div class="line"><a name="l05387"></a><span class="lineno"> 5387</span>  *stream << <span class="stringliteral">"/>\n"</span>;</div><div class="line"><a name="l05388"></a><span class="lineno"> 5388</span>  }</div><div class="line"><a name="l05389"></a><span class="lineno"> 5389</span>  *stream << <span class="stringliteral">"</"</span> << kProperties << <span class="stringliteral">">\n"</span>;</div><div class="line"><a name="l05390"></a><span class="lineno"> 5390</span> }</div><div class="line"><a name="l05391"></a><span class="lineno"> 5391</span> </div><div class="line"><a name="l05392"></a><span class="lineno"> 5392</span> <span class="comment">// End XmlUnitTestResultPrinter</span></div><div class="line"><a name="l05393"></a><span class="lineno"> 5393</span> </div><div class="line"><a name="l05394"></a><span class="lineno"> 5394</span> <span class="comment">// This class generates an JSON output file.</span></div><div class="line"><a name="l05395"></a><span class="lineno"> 5395</span> <span class="keyword">class </span>JsonUnitTestResultPrinter : <span class="keyword">public</span> EmptyTestEventListener {</div><div class="line"><a name="l05396"></a><span class="lineno"> 5396</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l05397"></a><span class="lineno"> 5397</span>  <span class="keyword">explicit</span> JsonUnitTestResultPrinter(<span class="keyword">const</span> <span class="keywordtype">char</span>* output_file);</div><div class="line"><a name="l05398"></a><span class="lineno"> 5398</span> </div><div class="line"><a name="l05399"></a><span class="lineno"> 5399</span>  <span class="keywordtype">void</span> OnTestIterationEnd(<span class="keyword">const</span> UnitTest& unit_test, <span class="keywordtype">int</span> iteration) <span class="keyword">override</span>;</div><div class="line"><a name="l05400"></a><span class="lineno"> 5400</span> </div><div class="line"><a name="l05401"></a><span class="lineno"> 5401</span>  <span class="comment">// Prints an JSON summary of all unit tests.</span></div><div class="line"><a name="l05402"></a><span class="lineno"> 5402</span>  <span class="keyword">static</span> <span class="keywordtype">void</span> PrintJsonTestList(::std::ostream* stream,</div><div class="line"><a name="l05403"></a><span class="lineno"> 5403</span>  <span class="keyword">const</span> std::vector<TestSuite*>& test_suites);</div><div class="line"><a name="l05404"></a><span class="lineno"> 5404</span> </div><div class="line"><a name="l05405"></a><span class="lineno"> 5405</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l05406"></a><span class="lineno"> 5406</span>  <span class="comment">// Returns an JSON-escaped copy of the input string str.</span></div><div class="line"><a name="l05407"></a><span class="lineno"> 5407</span>  <span class="keyword">static</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> EscapeJson(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& str);</div><div class="line"><a name="l05408"></a><span class="lineno"> 5408</span> </div><div class="line"><a name="l05411"></a><span class="lineno"> 5411</span>  <span class="keyword">static</span> <span class="keywordtype">void</span> OutputJsonKey(std::ostream* stream,</div><div class="line"><a name="l05412"></a><span class="lineno"> 5412</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& element_name,</div><div class="line"><a name="l05413"></a><span class="lineno"> 5413</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& name,</div><div class="line"><a name="l05414"></a><span class="lineno"> 5414</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& value,</div><div class="line"><a name="l05415"></a><span class="lineno"> 5415</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& indent,</div><div class="line"><a name="l05416"></a><span class="lineno"> 5416</span>  <span class="keywordtype">bool</span> comma = <span class="keyword">true</span>);</div><div class="line"><a name="l05417"></a><span class="lineno"> 5417</span>  <span class="keyword">static</span> <span class="keywordtype">void</span> OutputJsonKey(std::ostream* stream,</div><div class="line"><a name="l05418"></a><span class="lineno"> 5418</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& element_name,</div><div class="line"><a name="l05419"></a><span class="lineno"> 5419</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& name,</div><div class="line"><a name="l05420"></a><span class="lineno"> 5420</span>  <span class="keywordtype">int</span> value,</div><div class="line"><a name="l05421"></a><span class="lineno"> 5421</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& indent,</div><div class="line"><a name="l05422"></a><span class="lineno"> 5422</span>  <span class="keywordtype">bool</span> comma = <span class="keyword">true</span>);</div><div class="line"><a name="l05423"></a><span class="lineno"> 5423</span> </div><div class="line"><a name="l05424"></a><span class="lineno"> 5424</span>  <span class="comment">// Streams a JSON representation of a TestInfo object.</span></div><div class="line"><a name="l05425"></a><span class="lineno"> 5425</span>  <span class="keyword">static</span> <span class="keywordtype">void</span> OutputJsonTestInfo(::std::ostream* stream,</div><div class="line"><a name="l05426"></a><span class="lineno"> 5426</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* test_suite_name,</div><div class="line"><a name="l05427"></a><span class="lineno"> 5427</span>  <span class="keyword">const</span> TestInfo& test_info);</div><div class="line"><a name="l05428"></a><span class="lineno"> 5428</span> </div><div class="line"><a name="l05429"></a><span class="lineno"> 5429</span>  <span class="comment">// Prints a JSON representation of a TestSuite object</span></div><div class="line"><a name="l05430"></a><span class="lineno"> 5430</span>  <span class="keyword">static</span> <span class="keywordtype">void</span> PrintJsonTestSuite(::std::ostream* stream,</div><div class="line"><a name="l05431"></a><span class="lineno"> 5431</span>  <span class="keyword">const</span> TestSuite& test_suite);</div><div class="line"><a name="l05432"></a><span class="lineno"> 5432</span> </div><div class="line"><a name="l05433"></a><span class="lineno"> 5433</span>  <span class="comment">// Prints a JSON summary of unit_test to output stream out.</span></div><div class="line"><a name="l05434"></a><span class="lineno"> 5434</span>  <span class="keyword">static</span> <span class="keywordtype">void</span> PrintJsonUnitTest(::std::ostream* stream,</div><div class="line"><a name="l05435"></a><span class="lineno"> 5435</span>  <span class="keyword">const</span> UnitTest& unit_test);</div><div class="line"><a name="l05436"></a><span class="lineno"> 5436</span> </div><div class="line"><a name="l05437"></a><span class="lineno"> 5437</span>  <span class="comment">// Produces a string representing the test properties in a result as</span></div><div class="line"><a name="l05438"></a><span class="lineno"> 5438</span>  <span class="comment">// a JSON dictionary.</span></div><div class="line"><a name="l05439"></a><span class="lineno"> 5439</span>  <span class="keyword">static</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> TestPropertiesAsJson(<span class="keyword">const</span> TestResult& result,</div><div class="line"><a name="l05440"></a><span class="lineno"> 5440</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& indent);</div><div class="line"><a name="l05441"></a><span class="lineno"> 5441</span> </div><div class="line"><a name="l05442"></a><span class="lineno"> 5442</span>  <span class="comment">// The output file.</span></div><div class="line"><a name="l05443"></a><span class="lineno"> 5443</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> output_file_;</div><div class="line"><a name="l05444"></a><span class="lineno"> 5444</span> </div><div class="line"><a name="l05445"></a><span class="lineno"> 5445</span>  <a class="code" href="gtest_8h.html#aed8c1888c32b588b0681e88b95031e29">GTEST_DISALLOW_COPY_AND_ASSIGN_</a>(JsonUnitTestResultPrinter);</div><div class="line"><a name="l05446"></a><span class="lineno"> 5446</span> };</div><div class="line"><a name="l05447"></a><span class="lineno"> 5447</span> </div><div class="line"><a name="l05448"></a><span class="lineno"> 5448</span> <span class="comment">// Creates a new JsonUnitTestResultPrinter.</span></div><div class="line"><a name="l05449"></a><span class="lineno"> 5449</span> JsonUnitTestResultPrinter::JsonUnitTestResultPrinter(<span class="keyword">const</span> <span class="keywordtype">char</span>* output_file)</div><div class="line"><a name="l05450"></a><span class="lineno"> 5450</span>  : output_file_(output_file) {</div><div class="line"><a name="l05451"></a><span class="lineno"> 5451</span>  <span class="keywordflow">if</span> (output_file_.empty()) {</div><div class="line"><a name="l05452"></a><span class="lineno"> 5452</span>  <a class="code" href="gtest_8h.html#a8ef4cb4c465db8c15464aecc6d9510ef">GTEST_LOG_</a>(FATAL) << <span class="stringliteral">"JSON output file may not be null"</span>;</div><div class="line"><a name="l05453"></a><span class="lineno"> 5453</span>  }</div><div class="line"><a name="l05454"></a><span class="lineno"> 5454</span> }</div><div class="line"><a name="l05455"></a><span class="lineno"> 5455</span> </div><div class="line"><a name="l05456"></a><span class="lineno"> 5456</span> <span class="keywordtype">void</span> JsonUnitTestResultPrinter::OnTestIterationEnd(<span class="keyword">const</span> UnitTest& unit_test,</div><div class="line"><a name="l05457"></a><span class="lineno"> 5457</span>  <span class="keywordtype">int</span> <span class="comment">/*iteration*/</span>) {</div><div class="line"><a name="l05458"></a><span class="lineno"> 5458</span>  FILE* jsonout = OpenFileForWriting(output_file_);</div><div class="line"><a name="l05459"></a><span class="lineno"> 5459</span>  std::stringstream stream;</div><div class="line"><a name="l05460"></a><span class="lineno"> 5460</span>  PrintJsonUnitTest(&stream, unit_test);</div><div class="line"><a name="l05461"></a><span class="lineno"> 5461</span>  fprintf(jsonout, <span class="stringliteral">"%s"</span>, StringStreamToString(&stream).c_str());</div><div class="line"><a name="l05462"></a><span class="lineno"> 5462</span>  fclose(jsonout);</div><div class="line"><a name="l05463"></a><span class="lineno"> 5463</span> }</div><div class="line"><a name="l05464"></a><span class="lineno"> 5464</span> </div><div class="line"><a name="l05465"></a><span class="lineno"> 5465</span> <span class="comment">// Returns an JSON-escaped copy of the input string str.</span></div><div class="line"><a name="l05466"></a><span class="lineno"> 5466</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> JsonUnitTestResultPrinter::EscapeJson(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& str) {</div><div class="line"><a name="l05467"></a><span class="lineno"> 5467</span>  Message m;</div><div class="line"><a name="l05468"></a><span class="lineno"> 5468</span> </div><div class="line"><a name="l05469"></a><span class="lineno"> 5469</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i < str.size(); ++i) {</div><div class="line"><a name="l05470"></a><span class="lineno"> 5470</span>  <span class="keyword">const</span> <span class="keywordtype">char</span> ch = str[i];</div><div class="line"><a name="l05471"></a><span class="lineno"> 5471</span>  <span class="keywordflow">switch</span> (ch) {</div><div class="line"><a name="l05472"></a><span class="lineno"> 5472</span>  <span class="keywordflow">case</span> <span class="charliteral">'\\'</span>:</div><div class="line"><a name="l05473"></a><span class="lineno"> 5473</span>  <span class="keywordflow">case</span> <span class="charliteral">'"'</span>:</div><div class="line"><a name="l05474"></a><span class="lineno"> 5474</span>  <span class="keywordflow">case</span> <span class="charliteral">'/'</span>:</div><div class="line"><a name="l05475"></a><span class="lineno"> 5475</span>  m << <span class="charliteral">'\\'</span> << ch;</div><div class="line"><a name="l05476"></a><span class="lineno"> 5476</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l05477"></a><span class="lineno"> 5477</span>  <span class="keywordflow">case</span> <span class="charliteral">'\b'</span>:</div><div class="line"><a name="l05478"></a><span class="lineno"> 5478</span>  m << <span class="stringliteral">"\\b"</span>;</div><div class="line"><a name="l05479"></a><span class="lineno"> 5479</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l05480"></a><span class="lineno"> 5480</span>  <span class="keywordflow">case</span> <span class="charliteral">'\t'</span>:</div><div class="line"><a name="l05481"></a><span class="lineno"> 5481</span>  m << <span class="stringliteral">"\\t"</span>;</div><div class="line"><a name="l05482"></a><span class="lineno"> 5482</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l05483"></a><span class="lineno"> 5483</span>  <span class="keywordflow">case</span> <span class="charliteral">'\n'</span>:</div><div class="line"><a name="l05484"></a><span class="lineno"> 5484</span>  m << <span class="stringliteral">"\\n"</span>;</div><div class="line"><a name="l05485"></a><span class="lineno"> 5485</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l05486"></a><span class="lineno"> 5486</span>  <span class="keywordflow">case</span> <span class="charliteral">'\f'</span>:</div><div class="line"><a name="l05487"></a><span class="lineno"> 5487</span>  m << <span class="stringliteral">"\\f"</span>;</div><div class="line"><a name="l05488"></a><span class="lineno"> 5488</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l05489"></a><span class="lineno"> 5489</span>  <span class="keywordflow">case</span> <span class="charliteral">'\r'</span>:</div><div class="line"><a name="l05490"></a><span class="lineno"> 5490</span>  m << <span class="stringliteral">"\\r"</span>;</div><div class="line"><a name="l05491"></a><span class="lineno"> 5491</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l05492"></a><span class="lineno"> 5492</span>  <span class="keywordflow">default</span>:</div><div class="line"><a name="l05493"></a><span class="lineno"> 5493</span>  <span class="keywordflow">if</span> (ch < <span class="charliteral">' '</span>) {</div><div class="line"><a name="l05494"></a><span class="lineno"> 5494</span>  m << <span class="stringliteral">"\\u00"</span> << String::FormatByte(static_cast<unsigned char>(ch));</div><div class="line"><a name="l05495"></a><span class="lineno"> 5495</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l05496"></a><span class="lineno"> 5496</span>  m << ch;</div><div class="line"><a name="l05497"></a><span class="lineno"> 5497</span>  }</div><div class="line"><a name="l05498"></a><span class="lineno"> 5498</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l05499"></a><span class="lineno"> 5499</span>  }</div><div class="line"><a name="l05500"></a><span class="lineno"> 5500</span>  }</div><div class="line"><a name="l05501"></a><span class="lineno"> 5501</span> </div><div class="line"><a name="l05502"></a><span class="lineno"> 5502</span>  <span class="keywordflow">return</span> m.GetString();</div><div class="line"><a name="l05503"></a><span class="lineno"> 5503</span> }</div><div class="line"><a name="l05504"></a><span class="lineno"> 5504</span> </div><div class="line"><a name="l05505"></a><span class="lineno"> 5505</span> <span class="comment">// The following routines generate an JSON representation of a UnitTest</span></div><div class="line"><a name="l05506"></a><span class="lineno"> 5506</span> <span class="comment">// object.</span></div><div class="line"><a name="l05507"></a><span class="lineno"> 5507</span> </div><div class="line"><a name="l05508"></a><span class="lineno"> 5508</span> <span class="comment">// Formats the given time in milliseconds as seconds.</span></div><div class="line"><a name="l05509"></a><span class="lineno"> 5509</span> <span class="keyword">static</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> FormatTimeInMillisAsDuration(<a class="code" href="namespacetesting_1_1internal.html#a66a845df404b38fe85c5e14a069f255a">TimeInMillis</a> ms) {</div><div class="line"><a name="l05510"></a><span class="lineno"> 5510</span>  ::std::stringstream ss;</div><div class="line"><a name="l05511"></a><span class="lineno"> 5511</span>  ss << (static_cast<double>(ms) * 1e-3) << <span class="stringliteral">"s"</span>;</div><div class="line"><a name="l05512"></a><span class="lineno"> 5512</span>  <span class="keywordflow">return</span> ss.str();</div><div class="line"><a name="l05513"></a><span class="lineno"> 5513</span> }</div><div class="line"><a name="l05514"></a><span class="lineno"> 5514</span> </div><div class="line"><a name="l05515"></a><span class="lineno"> 5515</span> <span class="comment">// Converts the given epoch time in milliseconds to a date string in the</span></div><div class="line"><a name="l05516"></a><span class="lineno"> 5516</span> <span class="comment">// RFC3339 format, without the timezone information.</span></div><div class="line"><a name="l05517"></a><span class="lineno"> 5517</span> <span class="keyword">static</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> FormatEpochTimeInMillisAsRFC3339(<a class="code" href="namespacetesting_1_1internal.html#a66a845df404b38fe85c5e14a069f255a">TimeInMillis</a> ms) {</div><div class="line"><a name="l05518"></a><span class="lineno"> 5518</span>  <span class="keyword">struct </span>tm time_struct;</div><div class="line"><a name="l05519"></a><span class="lineno"> 5519</span>  <span class="keywordflow">if</span> (!PortableLocaltime(static_cast<time_t>(ms / 1000), &time_struct))</div><div class="line"><a name="l05520"></a><span class="lineno"> 5520</span>  <span class="keywordflow">return</span> <span class="stringliteral">""</span>;</div><div class="line"><a name="l05521"></a><span class="lineno"> 5521</span>  <span class="comment">// YYYY-MM-DDThh:mm:ss</span></div><div class="line"><a name="l05522"></a><span class="lineno"> 5522</span>  <span class="keywordflow">return</span> <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(time_struct.tm_year + 1900) + <span class="stringliteral">"-"</span> +</div><div class="line"><a name="l05523"></a><span class="lineno"> 5523</span>  String::FormatIntWidth2(time_struct.tm_mon + 1) + <span class="stringliteral">"-"</span> +</div><div class="line"><a name="l05524"></a><span class="lineno"> 5524</span>  String::FormatIntWidth2(time_struct.tm_mday) + <span class="stringliteral">"T"</span> +</div><div class="line"><a name="l05525"></a><span class="lineno"> 5525</span>  String::FormatIntWidth2(time_struct.tm_hour) + <span class="stringliteral">":"</span> +</div><div class="line"><a name="l05526"></a><span class="lineno"> 5526</span>  String::FormatIntWidth2(time_struct.tm_min) + <span class="stringliteral">":"</span> +</div><div class="line"><a name="l05527"></a><span class="lineno"> 5527</span>  String::FormatIntWidth2(time_struct.tm_sec) + <span class="stringliteral">"Z"</span>;</div><div class="line"><a name="l05528"></a><span class="lineno"> 5528</span> }</div><div class="line"><a name="l05529"></a><span class="lineno"> 5529</span> </div><div class="line"><a name="l05530"></a><span class="lineno"> 5530</span> <span class="keyword">static</span> <span class="keyword">inline</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> Indent(<span class="keywordtype">int</span> width) {</div><div class="line"><a name="l05531"></a><span class="lineno"> 5531</span>  <span class="keywordflow">return</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(width, <span class="charliteral">' '</span>);</div><div class="line"><a name="l05532"></a><span class="lineno"> 5532</span> }</div><div class="line"><a name="l05533"></a><span class="lineno"> 5533</span> </div><div class="line"><a name="l05534"></a><span class="lineno"> 5534</span> <span class="keywordtype">void</span> JsonUnitTestResultPrinter::OutputJsonKey(</div><div class="line"><a name="l05535"></a><span class="lineno"> 5535</span>  std::ostream* stream,</div><div class="line"><a name="l05536"></a><span class="lineno"> 5536</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& element_name,</div><div class="line"><a name="l05537"></a><span class="lineno"> 5537</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& name,</div><div class="line"><a name="l05538"></a><span class="lineno"> 5538</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& value,</div><div class="line"><a name="l05539"></a><span class="lineno"> 5539</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& indent,</div><div class="line"><a name="l05540"></a><span class="lineno"> 5540</span>  <span class="keywordtype">bool</span> comma) {</div><div class="line"><a name="l05541"></a><span class="lineno"> 5541</span>  <span class="keyword">const</span> std::vector<std::string>& allowed_names =</div><div class="line"><a name="l05542"></a><span class="lineno"> 5542</span>  GetReservedAttributesForElement(element_name);</div><div class="line"><a name="l05543"></a><span class="lineno"> 5543</span> </div><div class="line"><a name="l05544"></a><span class="lineno"> 5544</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(<a class="code" href="namespaceutl_1_1meta.html#af4c9b6350bba98cc0dd73e87cb4ce413">std::find</a>(allowed_names.begin(), allowed_names.end(), name) !=</div><div class="line"><a name="l05545"></a><span class="lineno"> 5545</span>  allowed_names.end())</div><div class="line"><a name="l05546"></a><span class="lineno"> 5546</span>  << <span class="stringliteral">"Key \""</span> << name << <span class="stringliteral">"\" is not allowed for value \""</span> << element_name</div><div class="line"><a name="l05547"></a><span class="lineno"> 5547</span>  << <span class="stringliteral">"\"."</span>;</div><div class="line"><a name="l05548"></a><span class="lineno"> 5548</span> </div><div class="line"><a name="l05549"></a><span class="lineno"> 5549</span>  *stream << indent << <span class="stringliteral">"\""</span> << name << <span class="stringliteral">"\": \""</span> << EscapeJson(value) << <span class="stringliteral">"\""</span>;</div><div class="line"><a name="l05550"></a><span class="lineno"> 5550</span>  <span class="keywordflow">if</span> (comma)</div><div class="line"><a name="l05551"></a><span class="lineno"> 5551</span>  *stream << <span class="stringliteral">",\n"</span>;</div><div class="line"><a name="l05552"></a><span class="lineno"> 5552</span> }</div><div class="line"><a name="l05553"></a><span class="lineno"> 5553</span> </div><div class="line"><a name="l05554"></a><span class="lineno"> 5554</span> <span class="keywordtype">void</span> JsonUnitTestResultPrinter::OutputJsonKey(</div><div class="line"><a name="l05555"></a><span class="lineno"> 5555</span>  std::ostream* stream,</div><div class="line"><a name="l05556"></a><span class="lineno"> 5556</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& element_name,</div><div class="line"><a name="l05557"></a><span class="lineno"> 5557</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& name,</div><div class="line"><a name="l05558"></a><span class="lineno"> 5558</span>  <span class="keywordtype">int</span> value,</div><div class="line"><a name="l05559"></a><span class="lineno"> 5559</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& indent,</div><div class="line"><a name="l05560"></a><span class="lineno"> 5560</span>  <span class="keywordtype">bool</span> comma) {</div><div class="line"><a name="l05561"></a><span class="lineno"> 5561</span>  <span class="keyword">const</span> std::vector<std::string>& allowed_names =</div><div class="line"><a name="l05562"></a><span class="lineno"> 5562</span>  GetReservedAttributesForElement(element_name);</div><div class="line"><a name="l05563"></a><span class="lineno"> 5563</span> </div><div class="line"><a name="l05564"></a><span class="lineno"> 5564</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(<a class="code" href="namespaceutl_1_1meta.html#af4c9b6350bba98cc0dd73e87cb4ce413">std::find</a>(allowed_names.begin(), allowed_names.end(), name) !=</div><div class="line"><a name="l05565"></a><span class="lineno"> 5565</span>  allowed_names.end())</div><div class="line"><a name="l05566"></a><span class="lineno"> 5566</span>  << <span class="stringliteral">"Key \""</span> << name << <span class="stringliteral">"\" is not allowed for value \""</span> << element_name</div><div class="line"><a name="l05567"></a><span class="lineno"> 5567</span>  << <span class="stringliteral">"\"."</span>;</div><div class="line"><a name="l05568"></a><span class="lineno"> 5568</span> </div><div class="line"><a name="l05569"></a><span class="lineno"> 5569</span>  *stream << indent << <span class="stringliteral">"\""</span> << name << <span class="stringliteral">"\": "</span> << <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(value);</div><div class="line"><a name="l05570"></a><span class="lineno"> 5570</span>  <span class="keywordflow">if</span> (comma)</div><div class="line"><a name="l05571"></a><span class="lineno"> 5571</span>  *stream << <span class="stringliteral">",\n"</span>;</div><div class="line"><a name="l05572"></a><span class="lineno"> 5572</span> }</div><div class="line"><a name="l05573"></a><span class="lineno"> 5573</span> </div><div class="line"><a name="l05574"></a><span class="lineno"> 5574</span> <span class="comment">// Prints a JSON representation of a TestInfo object.</span></div><div class="line"><a name="l05575"></a><span class="lineno"> 5575</span> <span class="keywordtype">void</span> JsonUnitTestResultPrinter::OutputJsonTestInfo(::std::ostream* stream,</div><div class="line"><a name="l05576"></a><span class="lineno"> 5576</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* test_suite_name,</div><div class="line"><a name="l05577"></a><span class="lineno"> 5577</span>  <span class="keyword">const</span> TestInfo& test_info) {</div><div class="line"><a name="l05578"></a><span class="lineno"> 5578</span>  <span class="keyword">const</span> TestResult& result = *test_info.result();</div><div class="line"><a name="l05579"></a><span class="lineno"> 5579</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> kTestsuite = <span class="stringliteral">"testcase"</span>;</div><div class="line"><a name="l05580"></a><span class="lineno"> 5580</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> kIndent = Indent(10);</div><div class="line"><a name="l05581"></a><span class="lineno"> 5581</span> </div><div class="line"><a name="l05582"></a><span class="lineno"> 5582</span>  *stream << Indent(8) << <span class="stringliteral">"{\n"</span>;</div><div class="line"><a name="l05583"></a><span class="lineno"> 5583</span>  OutputJsonKey(stream, kTestsuite, <span class="stringliteral">"name"</span>, test_info.name(), kIndent);</div><div class="line"><a name="l05584"></a><span class="lineno"> 5584</span> </div><div class="line"><a name="l05585"></a><span class="lineno"> 5585</span>  <span class="keywordflow">if</span> (test_info.value_param() != <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l05586"></a><span class="lineno"> 5586</span>  OutputJsonKey(stream, kTestsuite, <span class="stringliteral">"value_param"</span>, test_info.value_param(),</div><div class="line"><a name="l05587"></a><span class="lineno"> 5587</span>  kIndent);</div><div class="line"><a name="l05588"></a><span class="lineno"> 5588</span>  }</div><div class="line"><a name="l05589"></a><span class="lineno"> 5589</span>  <span class="keywordflow">if</span> (test_info.type_param() != <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l05590"></a><span class="lineno"> 5590</span>  OutputJsonKey(stream, kTestsuite, <span class="stringliteral">"type_param"</span>, test_info.type_param(),</div><div class="line"><a name="l05591"></a><span class="lineno"> 5591</span>  kIndent);</div><div class="line"><a name="l05592"></a><span class="lineno"> 5592</span>  }</div><div class="line"><a name="l05593"></a><span class="lineno"> 5593</span>  <span class="keywordflow">if</span> (<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(list_tests)) {</div><div class="line"><a name="l05594"></a><span class="lineno"> 5594</span>  OutputJsonKey(stream, kTestsuite, <span class="stringliteral">"file"</span>, test_info.file(), kIndent);</div><div class="line"><a name="l05595"></a><span class="lineno"> 5595</span>  OutputJsonKey(stream, kTestsuite, <span class="stringliteral">"line"</span>, test_info.line(), kIndent, <span class="keyword">false</span>);</div><div class="line"><a name="l05596"></a><span class="lineno"> 5596</span>  *stream << <span class="stringliteral">"\n"</span> << Indent(8) << <span class="stringliteral">"}"</span>;</div><div class="line"><a name="l05597"></a><span class="lineno"> 5597</span>  <span class="keywordflow">return</span>;</div><div class="line"><a name="l05598"></a><span class="lineno"> 5598</span>  }</div><div class="line"><a name="l05599"></a><span class="lineno"> 5599</span> </div><div class="line"><a name="l05600"></a><span class="lineno"> 5600</span>  OutputJsonKey(</div><div class="line"><a name="l05601"></a><span class="lineno"> 5601</span>  stream, kTestsuite, <span class="stringliteral">"status"</span>,</div><div class="line"><a name="l05602"></a><span class="lineno"> 5602</span>  result.Skipped() ? <span class="stringliteral">"SKIPPED"</span> : test_info.should_run() ? <span class="stringliteral">"RUN"</span> : <span class="stringliteral">"NOTRUN"</span>,</div><div class="line"><a name="l05603"></a><span class="lineno"> 5603</span>  kIndent);</div><div class="line"><a name="l05604"></a><span class="lineno"> 5604</span>  OutputJsonKey(stream, kTestsuite, <span class="stringliteral">"time"</span>,</div><div class="line"><a name="l05605"></a><span class="lineno"> 5605</span>  FormatTimeInMillisAsDuration(result.elapsed_time()), kIndent);</div><div class="line"><a name="l05606"></a><span class="lineno"> 5606</span>  OutputJsonKey(stream, kTestsuite, <span class="stringliteral">"classname"</span>, test_suite_name, kIndent,</div><div class="line"><a name="l05607"></a><span class="lineno"> 5607</span>  <span class="keyword">false</span>);</div><div class="line"><a name="l05608"></a><span class="lineno"> 5608</span>  *stream << TestPropertiesAsJson(result, kIndent);</div><div class="line"><a name="l05609"></a><span class="lineno"> 5609</span> </div><div class="line"><a name="l05610"></a><span class="lineno"> 5610</span>  <span class="keywordtype">int</span> failures = 0;</div><div class="line"><a name="l05611"></a><span class="lineno"> 5611</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < result.total_part_count(); ++i) {</div><div class="line"><a name="l05612"></a><span class="lineno"> 5612</span>  <span class="keyword">const</span> TestPartResult& part = result.GetTestPartResult(i);</div><div class="line"><a name="l05613"></a><span class="lineno"> 5613</span>  <span class="keywordflow">if</span> (part.failed()) {</div><div class="line"><a name="l05614"></a><span class="lineno"> 5614</span>  *stream << <span class="stringliteral">",\n"</span>;</div><div class="line"><a name="l05615"></a><span class="lineno"> 5615</span>  <span class="keywordflow">if</span> (++failures == 1) {</div><div class="line"><a name="l05616"></a><span class="lineno"> 5616</span>  *stream << kIndent << <span class="stringliteral">"\""</span> << <span class="stringliteral">"failures"</span> << <span class="stringliteral">"\": [\n"</span>;</div><div class="line"><a name="l05617"></a><span class="lineno"> 5617</span>  }</div><div class="line"><a name="l05618"></a><span class="lineno"> 5618</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> location =</div><div class="line"><a name="l05619"></a><span class="lineno"> 5619</span>  <a class="code" href="namespacetesting_1_1internal.html#a1ee4cde97868c53e442d3182496a9f3c">internal::FormatCompilerIndependentFileLocation</a>(part.file_name(),</div><div class="line"><a name="l05620"></a><span class="lineno"> 5620</span>  part.line_number());</div><div class="line"><a name="l05621"></a><span class="lineno"> 5621</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> message = EscapeJson(location + <span class="stringliteral">"\n"</span> + part.message());</div><div class="line"><a name="l05622"></a><span class="lineno"> 5622</span>  *stream << kIndent << <span class="stringliteral">" {\n"</span></div><div class="line"><a name="l05623"></a><span class="lineno"> 5623</span>  << kIndent << <span class="stringliteral">" \"failure\": \""</span> << message << <span class="stringliteral">"\",\n"</span></div><div class="line"><a name="l05624"></a><span class="lineno"> 5624</span>  << kIndent << <span class="stringliteral">" \"type\": \"\"\n"</span></div><div class="line"><a name="l05625"></a><span class="lineno"> 5625</span>  << kIndent << <span class="stringliteral">" }"</span>;</div><div class="line"><a name="l05626"></a><span class="lineno"> 5626</span>  }</div><div class="line"><a name="l05627"></a><span class="lineno"> 5627</span>  }</div><div class="line"><a name="l05628"></a><span class="lineno"> 5628</span> </div><div class="line"><a name="l05629"></a><span class="lineno"> 5629</span>  <span class="keywordflow">if</span> (failures > 0)</div><div class="line"><a name="l05630"></a><span class="lineno"> 5630</span>  *stream << <span class="stringliteral">"\n"</span> << kIndent << <span class="stringliteral">"]"</span>;</div><div class="line"><a name="l05631"></a><span class="lineno"> 5631</span>  *stream << <span class="stringliteral">"\n"</span> << Indent(8) << <span class="stringliteral">"}"</span>;</div><div class="line"><a name="l05632"></a><span class="lineno"> 5632</span> }</div><div class="line"><a name="l05633"></a><span class="lineno"> 5633</span> </div><div class="line"><a name="l05634"></a><span class="lineno"> 5634</span> <span class="comment">// Prints an JSON representation of a TestSuite object</span></div><div class="line"><a name="l05635"></a><span class="lineno"> 5635</span> <span class="keywordtype">void</span> JsonUnitTestResultPrinter::PrintJsonTestSuite(</div><div class="line"><a name="l05636"></a><span class="lineno"> 5636</span>  std::ostream* stream, <span class="keyword">const</span> TestSuite& test_suite) {</div><div class="line"><a name="l05637"></a><span class="lineno"> 5637</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> kTestsuite = <span class="stringliteral">"testsuite"</span>;</div><div class="line"><a name="l05638"></a><span class="lineno"> 5638</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> kIndent = Indent(6);</div><div class="line"><a name="l05639"></a><span class="lineno"> 5639</span> </div><div class="line"><a name="l05640"></a><span class="lineno"> 5640</span>  *stream << Indent(4) << <span class="stringliteral">"{\n"</span>;</div><div class="line"><a name="l05641"></a><span class="lineno"> 5641</span>  OutputJsonKey(stream, kTestsuite, <span class="stringliteral">"name"</span>, test_suite.name(), kIndent);</div><div class="line"><a name="l05642"></a><span class="lineno"> 5642</span>  OutputJsonKey(stream, kTestsuite, <span class="stringliteral">"tests"</span>, test_suite.reportable_test_count(),</div><div class="line"><a name="l05643"></a><span class="lineno"> 5643</span>  kIndent);</div><div class="line"><a name="l05644"></a><span class="lineno"> 5644</span>  <span class="keywordflow">if</span> (!<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(list_tests)) {</div><div class="line"><a name="l05645"></a><span class="lineno"> 5645</span>  OutputJsonKey(stream, kTestsuite, <span class="stringliteral">"failures"</span>,</div><div class="line"><a name="l05646"></a><span class="lineno"> 5646</span>  test_suite.failed_test_count(), kIndent);</div><div class="line"><a name="l05647"></a><span class="lineno"> 5647</span>  OutputJsonKey(stream, kTestsuite, <span class="stringliteral">"disabled"</span>,</div><div class="line"><a name="l05648"></a><span class="lineno"> 5648</span>  test_suite.reportable_disabled_test_count(), kIndent);</div><div class="line"><a name="l05649"></a><span class="lineno"> 5649</span>  OutputJsonKey(stream, kTestsuite, <span class="stringliteral">"errors"</span>, 0, kIndent);</div><div class="line"><a name="l05650"></a><span class="lineno"> 5650</span>  OutputJsonKey(stream, kTestsuite, <span class="stringliteral">"time"</span>,</div><div class="line"><a name="l05651"></a><span class="lineno"> 5651</span>  FormatTimeInMillisAsDuration(test_suite.elapsed_time()),</div><div class="line"><a name="l05652"></a><span class="lineno"> 5652</span>  kIndent, <span class="keyword">false</span>);</div><div class="line"><a name="l05653"></a><span class="lineno"> 5653</span>  *stream << TestPropertiesAsJson(test_suite.ad_hoc_test_result(), kIndent)</div><div class="line"><a name="l05654"></a><span class="lineno"> 5654</span>  << <span class="stringliteral">",\n"</span>;</div><div class="line"><a name="l05655"></a><span class="lineno"> 5655</span>  }</div><div class="line"><a name="l05656"></a><span class="lineno"> 5656</span> </div><div class="line"><a name="l05657"></a><span class="lineno"> 5657</span>  *stream << kIndent << <span class="stringliteral">"\""</span> << kTestsuite << <span class="stringliteral">"\": [\n"</span>;</div><div class="line"><a name="l05658"></a><span class="lineno"> 5658</span> </div><div class="line"><a name="l05659"></a><span class="lineno"> 5659</span>  <span class="keywordtype">bool</span> comma = <span class="keyword">false</span>;</div><div class="line"><a name="l05660"></a><span class="lineno"> 5660</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < test_suite.total_test_count(); ++i) {</div><div class="line"><a name="l05661"></a><span class="lineno"> 5661</span>  <span class="keywordflow">if</span> (test_suite.GetTestInfo(i)->is_reportable()) {</div><div class="line"><a name="l05662"></a><span class="lineno"> 5662</span>  <span class="keywordflow">if</span> (comma) {</div><div class="line"><a name="l05663"></a><span class="lineno"> 5663</span>  *stream << <span class="stringliteral">",\n"</span>;</div><div class="line"><a name="l05664"></a><span class="lineno"> 5664</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l05665"></a><span class="lineno"> 5665</span>  comma = <span class="keyword">true</span>;</div><div class="line"><a name="l05666"></a><span class="lineno"> 5666</span>  }</div><div class="line"><a name="l05667"></a><span class="lineno"> 5667</span>  OutputJsonTestInfo(stream, test_suite.name(), *test_suite.GetTestInfo(i));</div><div class="line"><a name="l05668"></a><span class="lineno"> 5668</span>  }</div><div class="line"><a name="l05669"></a><span class="lineno"> 5669</span>  }</div><div class="line"><a name="l05670"></a><span class="lineno"> 5670</span>  *stream << <span class="stringliteral">"\n"</span> << kIndent << <span class="stringliteral">"]\n"</span> << Indent(4) << <span class="stringliteral">"}"</span>;</div><div class="line"><a name="l05671"></a><span class="lineno"> 5671</span> }</div><div class="line"><a name="l05672"></a><span class="lineno"> 5672</span> </div><div class="line"><a name="l05673"></a><span class="lineno"> 5673</span> <span class="comment">// Prints a JSON summary of unit_test to output stream out.</span></div><div class="line"><a name="l05674"></a><span class="lineno"> 5674</span> <span class="keywordtype">void</span> JsonUnitTestResultPrinter::PrintJsonUnitTest(std::ostream* stream,</div><div class="line"><a name="l05675"></a><span class="lineno"> 5675</span>  <span class="keyword">const</span> UnitTest& unit_test) {</div><div class="line"><a name="l05676"></a><span class="lineno"> 5676</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> kTestsuites = <span class="stringliteral">"testsuites"</span>;</div><div class="line"><a name="l05677"></a><span class="lineno"> 5677</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> kIndent = Indent(2);</div><div class="line"><a name="l05678"></a><span class="lineno"> 5678</span>  *stream << <span class="stringliteral">"{\n"</span>;</div><div class="line"><a name="l05679"></a><span class="lineno"> 5679</span> </div><div class="line"><a name="l05680"></a><span class="lineno"> 5680</span>  OutputJsonKey(stream, kTestsuites, <span class="stringliteral">"tests"</span>, unit_test.reportable_test_count(),</div><div class="line"><a name="l05681"></a><span class="lineno"> 5681</span>  kIndent);</div><div class="line"><a name="l05682"></a><span class="lineno"> 5682</span>  OutputJsonKey(stream, kTestsuites, <span class="stringliteral">"failures"</span>, unit_test.failed_test_count(),</div><div class="line"><a name="l05683"></a><span class="lineno"> 5683</span>  kIndent);</div><div class="line"><a name="l05684"></a><span class="lineno"> 5684</span>  OutputJsonKey(stream, kTestsuites, <span class="stringliteral">"disabled"</span>,</div><div class="line"><a name="l05685"></a><span class="lineno"> 5685</span>  unit_test.reportable_disabled_test_count(), kIndent);</div><div class="line"><a name="l05686"></a><span class="lineno"> 5686</span>  OutputJsonKey(stream, kTestsuites, <span class="stringliteral">"errors"</span>, 0, kIndent);</div><div class="line"><a name="l05687"></a><span class="lineno"> 5687</span>  <span class="keywordflow">if</span> (<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(shuffle)) {</div><div class="line"><a name="l05688"></a><span class="lineno"> 5688</span>  OutputJsonKey(stream, kTestsuites, <span class="stringliteral">"random_seed"</span>, unit_test.random_seed(),</div><div class="line"><a name="l05689"></a><span class="lineno"> 5689</span>  kIndent);</div><div class="line"><a name="l05690"></a><span class="lineno"> 5690</span>  }</div><div class="line"><a name="l05691"></a><span class="lineno"> 5691</span>  OutputJsonKey(stream, kTestsuites, <span class="stringliteral">"timestamp"</span>,</div><div class="line"><a name="l05692"></a><span class="lineno"> 5692</span>  FormatEpochTimeInMillisAsRFC3339(unit_test.start_timestamp()),</div><div class="line"><a name="l05693"></a><span class="lineno"> 5693</span>  kIndent);</div><div class="line"><a name="l05694"></a><span class="lineno"> 5694</span>  OutputJsonKey(stream, kTestsuites, <span class="stringliteral">"time"</span>,</div><div class="line"><a name="l05695"></a><span class="lineno"> 5695</span>  FormatTimeInMillisAsDuration(unit_test.elapsed_time()), kIndent,</div><div class="line"><a name="l05696"></a><span class="lineno"> 5696</span>  <span class="keyword">false</span>);</div><div class="line"><a name="l05697"></a><span class="lineno"> 5697</span> </div><div class="line"><a name="l05698"></a><span class="lineno"> 5698</span>  *stream << TestPropertiesAsJson(unit_test.ad_hoc_test_result(), kIndent)</div><div class="line"><a name="l05699"></a><span class="lineno"> 5699</span>  << <span class="stringliteral">",\n"</span>;</div><div class="line"><a name="l05700"></a><span class="lineno"> 5700</span> </div><div class="line"><a name="l05701"></a><span class="lineno"> 5701</span>  OutputJsonKey(stream, kTestsuites, <span class="stringliteral">"name"</span>, <span class="stringliteral">"AllTests"</span>, kIndent);</div><div class="line"><a name="l05702"></a><span class="lineno"> 5702</span>  *stream << kIndent << <span class="stringliteral">"\""</span> << kTestsuites << <span class="stringliteral">"\": [\n"</span>;</div><div class="line"><a name="l05703"></a><span class="lineno"> 5703</span> </div><div class="line"><a name="l05704"></a><span class="lineno"> 5704</span>  <span class="keywordtype">bool</span> comma = <span class="keyword">false</span>;</div><div class="line"><a name="l05705"></a><span class="lineno"> 5705</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < unit_test.total_test_suite_count(); ++i) {</div><div class="line"><a name="l05706"></a><span class="lineno"> 5706</span>  <span class="keywordflow">if</span> (unit_test.GetTestSuite(i)->reportable_test_count() > 0) {</div><div class="line"><a name="l05707"></a><span class="lineno"> 5707</span>  <span class="keywordflow">if</span> (comma) {</div><div class="line"><a name="l05708"></a><span class="lineno"> 5708</span>  *stream << <span class="stringliteral">",\n"</span>;</div><div class="line"><a name="l05709"></a><span class="lineno"> 5709</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l05710"></a><span class="lineno"> 5710</span>  comma = <span class="keyword">true</span>;</div><div class="line"><a name="l05711"></a><span class="lineno"> 5711</span>  }</div><div class="line"><a name="l05712"></a><span class="lineno"> 5712</span>  PrintJsonTestSuite(stream, *unit_test.GetTestSuite(i));</div><div class="line"><a name="l05713"></a><span class="lineno"> 5713</span>  }</div><div class="line"><a name="l05714"></a><span class="lineno"> 5714</span>  }</div><div class="line"><a name="l05715"></a><span class="lineno"> 5715</span> </div><div class="line"><a name="l05716"></a><span class="lineno"> 5716</span>  *stream << <span class="stringliteral">"\n"</span> << kIndent << <span class="stringliteral">"]\n"</span> << <span class="stringliteral">"}\n"</span>;</div><div class="line"><a name="l05717"></a><span class="lineno"> 5717</span> }</div><div class="line"><a name="l05718"></a><span class="lineno"> 5718</span> </div><div class="line"><a name="l05719"></a><span class="lineno"> 5719</span> <span class="keywordtype">void</span> JsonUnitTestResultPrinter::PrintJsonTestList(</div><div class="line"><a name="l05720"></a><span class="lineno"> 5720</span>  std::ostream* stream, <span class="keyword">const</span> std::vector<TestSuite*>& test_suites) {</div><div class="line"><a name="l05721"></a><span class="lineno"> 5721</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> kTestsuites = <span class="stringliteral">"testsuites"</span>;</div><div class="line"><a name="l05722"></a><span class="lineno"> 5722</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> kIndent = Indent(2);</div><div class="line"><a name="l05723"></a><span class="lineno"> 5723</span>  *stream << <span class="stringliteral">"{\n"</span>;</div><div class="line"><a name="l05724"></a><span class="lineno"> 5724</span>  <span class="keywordtype">int</span> total_tests = 0;</div><div class="line"><a name="l05725"></a><span class="lineno"> 5725</span>  <span class="keywordflow">for</span> (<span class="keyword">auto</span> test_suite : test_suites) {</div><div class="line"><a name="l05726"></a><span class="lineno"> 5726</span>  total_tests += test_suite->total_test_count();</div><div class="line"><a name="l05727"></a><span class="lineno"> 5727</span>  }</div><div class="line"><a name="l05728"></a><span class="lineno"> 5728</span>  OutputJsonKey(stream, kTestsuites, <span class="stringliteral">"tests"</span>, total_tests, kIndent);</div><div class="line"><a name="l05729"></a><span class="lineno"> 5729</span> </div><div class="line"><a name="l05730"></a><span class="lineno"> 5730</span>  OutputJsonKey(stream, kTestsuites, <span class="stringliteral">"name"</span>, <span class="stringliteral">"AllTests"</span>, kIndent);</div><div class="line"><a name="l05731"></a><span class="lineno"> 5731</span>  *stream << kIndent << <span class="stringliteral">"\""</span> << kTestsuites << <span class="stringliteral">"\": [\n"</span>;</div><div class="line"><a name="l05732"></a><span class="lineno"> 5732</span> </div><div class="line"><a name="l05733"></a><span class="lineno"> 5733</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i < test_suites.size(); ++i) {</div><div class="line"><a name="l05734"></a><span class="lineno"> 5734</span>  <span class="keywordflow">if</span> (i != 0) {</div><div class="line"><a name="l05735"></a><span class="lineno"> 5735</span>  *stream << <span class="stringliteral">",\n"</span>;</div><div class="line"><a name="l05736"></a><span class="lineno"> 5736</span>  }</div><div class="line"><a name="l05737"></a><span class="lineno"> 5737</span>  PrintJsonTestSuite(stream, *test_suites[i]);</div><div class="line"><a name="l05738"></a><span class="lineno"> 5738</span>  }</div><div class="line"><a name="l05739"></a><span class="lineno"> 5739</span> </div><div class="line"><a name="l05740"></a><span class="lineno"> 5740</span>  *stream << <span class="stringliteral">"\n"</span></div><div class="line"><a name="l05741"></a><span class="lineno"> 5741</span>  << kIndent << <span class="stringliteral">"]\n"</span></div><div class="line"><a name="l05742"></a><span class="lineno"> 5742</span>  << <span class="stringliteral">"}\n"</span>;</div><div class="line"><a name="l05743"></a><span class="lineno"> 5743</span> }</div><div class="line"><a name="l05744"></a><span class="lineno"> 5744</span> <span class="comment">// Produces a string representing the test properties in a result as</span></div><div class="line"><a name="l05745"></a><span class="lineno"> 5745</span> <span class="comment">// a JSON dictionary.</span></div><div class="line"><a name="l05746"></a><span class="lineno"> 5746</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> JsonUnitTestResultPrinter::TestPropertiesAsJson(</div><div class="line"><a name="l05747"></a><span class="lineno"> 5747</span>  <span class="keyword">const</span> TestResult& result, <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& indent) {</div><div class="line"><a name="l05748"></a><span class="lineno"> 5748</span>  Message attributes;</div><div class="line"><a name="l05749"></a><span class="lineno"> 5749</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < result.test_property_count(); ++i) {</div><div class="line"><a name="l05750"></a><span class="lineno"> 5750</span>  <span class="keyword">const</span> TestProperty& <span class="keyword">property</span> = result.GetTestProperty(i);</div><div class="line"><a name="l05751"></a><span class="lineno"> 5751</span>  attributes << <span class="stringliteral">",\n"</span> << indent << <span class="stringliteral">"\""</span> << <span class="keyword">property</span>.key() << <span class="stringliteral">"\": "</span></div><div class="line"><a name="l05752"></a><span class="lineno"> 5752</span>  << <span class="stringliteral">"\""</span> << EscapeJson(property.value()) << <span class="stringliteral">"\""</span>;</div><div class="line"><a name="l05753"></a><span class="lineno"> 5753</span>  }</div><div class="line"><a name="l05754"></a><span class="lineno"> 5754</span>  <span class="keywordflow">return</span> attributes.GetString();</div><div class="line"><a name="l05755"></a><span class="lineno"> 5755</span> }</div><div class="line"><a name="l05756"></a><span class="lineno"> 5756</span> </div><div class="line"><a name="l05757"></a><span class="lineno"> 5757</span> <span class="comment">// End JsonUnitTestResultPrinter</span></div><div class="line"><a name="l05758"></a><span class="lineno"> 5758</span> </div><div class="line"><a name="l05759"></a><span class="lineno"> 5759</span> <span class="preprocessor">#if GTEST_CAN_STREAM_RESULTS_</span></div><div class="line"><a name="l05760"></a><span class="lineno"> 5760</span> </div><div class="line"><a name="l05761"></a><span class="lineno"> 5761</span> <span class="comment">// Checks if str contains '=', '&', '%' or '\n' characters. If yes,</span></div><div class="line"><a name="l05762"></a><span class="lineno"> 5762</span> <span class="comment">// replaces them by "%xx" where xx is their hexadecimal value. For</span></div><div class="line"><a name="l05763"></a><span class="lineno"> 5763</span> <span class="comment">// example, replaces "=" with "%3D". This algorithm is O(strlen(str))</span></div><div class="line"><a name="l05764"></a><span class="lineno"> 5764</span> <span class="comment">// in both time and space -- important as the input str may contain an</span></div><div class="line"><a name="l05765"></a><span class="lineno"> 5765</span> <span class="comment">// arbitrarily long test failure message and stack trace.</span></div><div class="line"><a name="l05766"></a><span class="lineno"> 5766</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> StreamingListener::UrlEncode(<span class="keyword">const</span> <span class="keywordtype">char</span>* str) {</div><div class="line"><a name="l05767"></a><span class="lineno"> 5767</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> result;</div><div class="line"><a name="l05768"></a><span class="lineno"> 5768</span>  result.reserve(strlen(str) + 1);</div><div class="line"><a name="l05769"></a><span class="lineno"> 5769</span>  <span class="keywordflow">for</span> (<span class="keywordtype">char</span> ch = *str; ch != <span class="charliteral">'\0'</span>; ch = *++str) {</div><div class="line"><a name="l05770"></a><span class="lineno"> 5770</span>  <span class="keywordflow">switch</span> (ch) {</div><div class="line"><a name="l05771"></a><span class="lineno"> 5771</span>  <span class="keywordflow">case</span> <span class="charliteral">'%'</span>:</div><div class="line"><a name="l05772"></a><span class="lineno"> 5772</span>  <span class="keywordflow">case</span> <span class="charliteral">'='</span>:</div><div class="line"><a name="l05773"></a><span class="lineno"> 5773</span>  <span class="keywordflow">case</span> <span class="charliteral">'&'</span>:</div><div class="line"><a name="l05774"></a><span class="lineno"> 5774</span>  <span class="keywordflow">case</span> <span class="charliteral">'\n'</span>:</div><div class="line"><a name="l05775"></a><span class="lineno"> 5775</span>  result.append(<span class="stringliteral">"%"</span> + String::FormatByte(static_cast<unsigned char>(ch)));</div><div class="line"><a name="l05776"></a><span class="lineno"> 5776</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l05777"></a><span class="lineno"> 5777</span>  <span class="keywordflow">default</span>:</div><div class="line"><a name="l05778"></a><span class="lineno"> 5778</span>  result.push_back(ch);</div><div class="line"><a name="l05779"></a><span class="lineno"> 5779</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l05780"></a><span class="lineno"> 5780</span>  }</div><div class="line"><a name="l05781"></a><span class="lineno"> 5781</span>  }</div><div class="line"><a name="l05782"></a><span class="lineno"> 5782</span>  <span class="keywordflow">return</span> result;</div><div class="line"><a name="l05783"></a><span class="lineno"> 5783</span> }</div><div class="line"><a name="l05784"></a><span class="lineno"> 5784</span> </div><div class="line"><a name="l05785"></a><span class="lineno"> 5785</span> <span class="keywordtype">void</span> StreamingListener::SocketWriter::MakeConnection() {</div><div class="line"><a name="l05786"></a><span class="lineno"> 5786</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(sockfd_ == -1)</div><div class="line"><a name="l05787"></a><span class="lineno"> 5787</span>  << <span class="stringliteral">"MakeConnection() can't be called when there is already a connection."</span>;</div><div class="line"><a name="l05788"></a><span class="lineno"> 5788</span> </div><div class="line"><a name="l05789"></a><span class="lineno"> 5789</span>  addrinfo hints;</div><div class="line"><a name="l05790"></a><span class="lineno"> 5790</span>  memset(&hints, 0, <span class="keyword">sizeof</span>(hints));</div><div class="line"><a name="l05791"></a><span class="lineno"> 5791</span>  hints.ai_family = AF_UNSPEC; <span class="comment">// To allow both IPv4 and IPv6 addresses.</span></div><div class="line"><a name="l05792"></a><span class="lineno"> 5792</span>  hints.ai_socktype = SOCK_STREAM;</div><div class="line"><a name="l05793"></a><span class="lineno"> 5793</span>  addrinfo* servinfo = <span class="keyword">nullptr</span>;</div><div class="line"><a name="l05794"></a><span class="lineno"> 5794</span> </div><div class="line"><a name="l05795"></a><span class="lineno"> 5795</span>  <span class="comment">// Use the getaddrinfo() to get a linked list of IP addresses for</span></div><div class="line"><a name="l05796"></a><span class="lineno"> 5796</span>  <span class="comment">// the given host name.</span></div><div class="line"><a name="l05797"></a><span class="lineno"> 5797</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> error_num = getaddrinfo(</div><div class="line"><a name="l05798"></a><span class="lineno"> 5798</span>  host_name_.c_str(), port_num_.c_str(), &hints, &servinfo);</div><div class="line"><a name="l05799"></a><span class="lineno"> 5799</span>  <span class="keywordflow">if</span> (error_num != 0) {</div><div class="line"><a name="l05800"></a><span class="lineno"> 5800</span>  <a class="code" href="gtest_8h.html#a8ef4cb4c465db8c15464aecc6d9510ef">GTEST_LOG_</a>(WARNING) << <span class="stringliteral">"stream_result_to: getaddrinfo() failed: "</span></div><div class="line"><a name="l05801"></a><span class="lineno"> 5801</span>  << gai_strerror(error_num);</div><div class="line"><a name="l05802"></a><span class="lineno"> 5802</span>  }</div><div class="line"><a name="l05803"></a><span class="lineno"> 5803</span> </div><div class="line"><a name="l05804"></a><span class="lineno"> 5804</span>  <span class="comment">// Loop through all the results and connect to the first we can.</span></div><div class="line"><a name="l05805"></a><span class="lineno"> 5805</span>  <span class="keywordflow">for</span> (addrinfo* cur_addr = servinfo; sockfd_ == -1 && cur_addr != <span class="keyword">nullptr</span>;</div><div class="line"><a name="l05806"></a><span class="lineno"> 5806</span>  cur_addr = cur_addr->ai_next) {</div><div class="line"><a name="l05807"></a><span class="lineno"> 5807</span>  sockfd_ = socket(</div><div class="line"><a name="l05808"></a><span class="lineno"> 5808</span>  cur_addr->ai_family, cur_addr->ai_socktype, cur_addr->ai_protocol);</div><div class="line"><a name="l05809"></a><span class="lineno"> 5809</span>  <span class="keywordflow">if</span> (sockfd_ != -1) {</div><div class="line"><a name="l05810"></a><span class="lineno"> 5810</span>  <span class="comment">// Connect the client socket to the server socket.</span></div><div class="line"><a name="l05811"></a><span class="lineno"> 5811</span>  <span class="keywordflow">if</span> (connect(sockfd_, cur_addr->ai_addr, cur_addr->ai_addrlen) == -1) {</div><div class="line"><a name="l05812"></a><span class="lineno"> 5812</span>  close(sockfd_);</div><div class="line"><a name="l05813"></a><span class="lineno"> 5813</span>  sockfd_ = -1;</div><div class="line"><a name="l05814"></a><span class="lineno"> 5814</span>  }</div><div class="line"><a name="l05815"></a><span class="lineno"> 5815</span>  }</div><div class="line"><a name="l05816"></a><span class="lineno"> 5816</span>  }</div><div class="line"><a name="l05817"></a><span class="lineno"> 5817</span> </div><div class="line"><a name="l05818"></a><span class="lineno"> 5818</span>  freeaddrinfo(servinfo); <span class="comment">// all done with this structure</span></div><div class="line"><a name="l05819"></a><span class="lineno"> 5819</span> </div><div class="line"><a name="l05820"></a><span class="lineno"> 5820</span>  <span class="keywordflow">if</span> (sockfd_ == -1) {</div><div class="line"><a name="l05821"></a><span class="lineno"> 5821</span>  <a class="code" href="gtest_8h.html#a8ef4cb4c465db8c15464aecc6d9510ef">GTEST_LOG_</a>(WARNING) << <span class="stringliteral">"stream_result_to: failed to connect to "</span></div><div class="line"><a name="l05822"></a><span class="lineno"> 5822</span>  << host_name_ << <span class="stringliteral">":"</span> << port_num_;</div><div class="line"><a name="l05823"></a><span class="lineno"> 5823</span>  }</div><div class="line"><a name="l05824"></a><span class="lineno"> 5824</span> }</div><div class="line"><a name="l05825"></a><span class="lineno"> 5825</span> </div><div class="line"><a name="l05826"></a><span class="lineno"> 5826</span> <span class="comment">// End of class Streaming Listener</span></div><div class="line"><a name="l05827"></a><span class="lineno"> 5827</span> <span class="preprocessor">#endif // GTEST_CAN_STREAM_RESULTS__</span></div><div class="line"><a name="l05828"></a><span class="lineno"> 5828</span> </div><div class="line"><a name="l05829"></a><span class="lineno"> 5829</span> <span class="comment">// class OsStackTraceGetter</span></div><div class="line"><a name="l05830"></a><span class="lineno"> 5830</span> </div><div class="line"><a name="l05831"></a><span class="lineno"> 5831</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> OsStackTraceGetterInterface::kElidedFramesMarker =</div><div class="line"><a name="l05832"></a><span class="lineno"> 5832</span>  <span class="stringliteral">"... "</span> <a class="code" href="gtest_8h.html#a13d98c217176bd8722c395b9225fc19d">GTEST_NAME_</a> <span class="stringliteral">" internal frames ..."</span>;</div><div class="line"><a name="l05833"></a><span class="lineno"> 5833</span> </div><div class="line"><a name="l05834"></a><span class="lineno"> 5834</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> OsStackTraceGetter::CurrentStackTrace(<span class="keywordtype">int</span> max_depth, <span class="keywordtype">int</span> skip_count)</div><div class="line"><a name="l05835"></a><span class="lineno"> 5835</span>  <a class="code" href="gtest_8h.html#a69abff5a4efdd07bd5faebe3dd318d06">GTEST_LOCK_EXCLUDED_</a>(mutex_) {</div><div class="line"><a name="l05836"></a><span class="lineno"> 5836</span> <span class="preprocessor">#if GTEST_HAS_ABSL</span></div><div class="line"><a name="l05837"></a><span class="lineno"> 5837</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> result;</div><div class="line"><a name="l05838"></a><span class="lineno"> 5838</span> </div><div class="line"><a name="l05839"></a><span class="lineno"> 5839</span>  <span class="keywordflow">if</span> (max_depth <= 0) {</div><div class="line"><a name="l05840"></a><span class="lineno"> 5840</span>  <span class="keywordflow">return</span> result;</div><div class="line"><a name="l05841"></a><span class="lineno"> 5841</span>  }</div><div class="line"><a name="l05842"></a><span class="lineno"> 5842</span> </div><div class="line"><a name="l05843"></a><span class="lineno"> 5843</span>  max_depth = std::min(max_depth, kMaxStackTraceDepth);</div><div class="line"><a name="l05844"></a><span class="lineno"> 5844</span> </div><div class="line"><a name="l05845"></a><span class="lineno"> 5845</span>  std::vector<void*> raw_stack(max_depth);</div><div class="line"><a name="l05846"></a><span class="lineno"> 5846</span>  <span class="comment">// Skips the frames requested by the caller, plus this function.</span></div><div class="line"><a name="l05847"></a><span class="lineno"> 5847</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> raw_stack_size =</div><div class="line"><a name="l05848"></a><span class="lineno"> 5848</span>  absl::GetStackTrace(&raw_stack[0], max_depth, skip_count + 1);</div><div class="line"><a name="l05849"></a><span class="lineno"> 5849</span> </div><div class="line"><a name="l05850"></a><span class="lineno"> 5850</span>  <span class="keywordtype">void</span>* caller_frame = <span class="keyword">nullptr</span>;</div><div class="line"><a name="l05851"></a><span class="lineno"> 5851</span>  {</div><div class="line"><a name="l05852"></a><span class="lineno"> 5852</span>  <a class="code" href="namespacetesting_1_1internal.html#a08b187c6cc4e28400aadf9a32fccc8de">MutexLock</a> lock(&mutex_);</div><div class="line"><a name="l05853"></a><span class="lineno"> 5853</span>  caller_frame = caller_frame_;</div><div class="line"><a name="l05854"></a><span class="lineno"> 5854</span>  }</div><div class="line"><a name="l05855"></a><span class="lineno"> 5855</span> </div><div class="line"><a name="l05856"></a><span class="lineno"> 5856</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < raw_stack_size; ++i) {</div><div class="line"><a name="l05857"></a><span class="lineno"> 5857</span>  <span class="keywordflow">if</span> (raw_stack[i] == caller_frame &&</div><div class="line"><a name="l05858"></a><span class="lineno"> 5858</span>  !<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(show_internal_stack_frames)) {</div><div class="line"><a name="l05859"></a><span class="lineno"> 5859</span>  <span class="comment">// Add a marker to the trace and stop adding frames.</span></div><div class="line"><a name="l05860"></a><span class="lineno"> 5860</span>  absl::StrAppend(&result, kElidedFramesMarker, <span class="stringliteral">"\n"</span>);</div><div class="line"><a name="l05861"></a><span class="lineno"> 5861</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l05862"></a><span class="lineno"> 5862</span>  }</div><div class="line"><a name="l05863"></a><span class="lineno"> 5863</span> </div><div class="line"><a name="l05864"></a><span class="lineno"> 5864</span>  <span class="keywordtype">char</span> tmp[1024];</div><div class="line"><a name="l05865"></a><span class="lineno"> 5865</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* symbol = <span class="stringliteral">"(unknown)"</span>;</div><div class="line"><a name="l05866"></a><span class="lineno"> 5866</span>  <span class="keywordflow">if</span> (absl::Symbolize(raw_stack[i], tmp, <span class="keyword">sizeof</span>(tmp))) {</div><div class="line"><a name="l05867"></a><span class="lineno"> 5867</span>  symbol = tmp;</div><div class="line"><a name="l05868"></a><span class="lineno"> 5868</span>  }</div><div class="line"><a name="l05869"></a><span class="lineno"> 5869</span> </div><div class="line"><a name="l05870"></a><span class="lineno"> 5870</span>  <span class="keywordtype">char</span> line[1024];</div><div class="line"><a name="l05871"></a><span class="lineno"> 5871</span>  snprintf(line, <span class="keyword">sizeof</span>(line), <span class="stringliteral">" %p: %s\n"</span>, raw_stack[i], symbol);</div><div class="line"><a name="l05872"></a><span class="lineno"> 5872</span>  result += line;</div><div class="line"><a name="l05873"></a><span class="lineno"> 5873</span>  }</div><div class="line"><a name="l05874"></a><span class="lineno"> 5874</span> </div><div class="line"><a name="l05875"></a><span class="lineno"> 5875</span>  <span class="keywordflow">return</span> result;</div><div class="line"><a name="l05876"></a><span class="lineno"> 5876</span> </div><div class="line"><a name="l05877"></a><span class="lineno"> 5877</span> <span class="preprocessor">#else // !GTEST_HAS_ABSL</span></div><div class="line"><a name="l05878"></a><span class="lineno"> 5878</span>  <span class="keyword">static_cast<</span><span class="keywordtype">void</span><span class="keyword">></span>(max_depth);</div><div class="line"><a name="l05879"></a><span class="lineno"> 5879</span>  <span class="keyword">static_cast<</span><span class="keywordtype">void</span><span class="keyword">></span>(skip_count);</div><div class="line"><a name="l05880"></a><span class="lineno"> 5880</span>  <span class="keywordflow">return</span> <span class="stringliteral">""</span>;</div><div class="line"><a name="l05881"></a><span class="lineno"> 5881</span> <span class="preprocessor">#endif // GTEST_HAS_ABSL</span></div><div class="line"><a name="l05882"></a><span class="lineno"> 5882</span> }</div><div class="line"><a name="l05883"></a><span class="lineno"> 5883</span> </div><div class="line"><a name="l05884"></a><span class="lineno"> 5884</span> <span class="keywordtype">void</span> OsStackTraceGetter::UponLeavingGTest() <a class="code" href="gtest_8h.html#a69abff5a4efdd07bd5faebe3dd318d06">GTEST_LOCK_EXCLUDED_</a>(mutex_) {</div><div class="line"><a name="l05885"></a><span class="lineno"> 5885</span> <span class="preprocessor">#if GTEST_HAS_ABSL</span></div><div class="line"><a name="l05886"></a><span class="lineno"> 5886</span>  <span class="keywordtype">void</span>* caller_frame = <span class="keyword">nullptr</span>;</div><div class="line"><a name="l05887"></a><span class="lineno"> 5887</span>  <span class="keywordflow">if</span> (absl::GetStackTrace(&caller_frame, 1, 3) <= 0) {</div><div class="line"><a name="l05888"></a><span class="lineno"> 5888</span>  caller_frame = <span class="keyword">nullptr</span>;</div><div class="line"><a name="l05889"></a><span class="lineno"> 5889</span>  }</div><div class="line"><a name="l05890"></a><span class="lineno"> 5890</span> </div><div class="line"><a name="l05891"></a><span class="lineno"> 5891</span>  <a class="code" href="namespacetesting_1_1internal.html#a08b187c6cc4e28400aadf9a32fccc8de">MutexLock</a> lock(&mutex_);</div><div class="line"><a name="l05892"></a><span class="lineno"> 5892</span>  caller_frame_ = caller_frame;</div><div class="line"><a name="l05893"></a><span class="lineno"> 5893</span> <span class="preprocessor">#endif // GTEST_HAS_ABSL</span></div><div class="line"><a name="l05894"></a><span class="lineno"> 5894</span> }</div><div class="line"><a name="l05895"></a><span class="lineno"> 5895</span> </div><div class="line"><a name="l05896"></a><span class="lineno"> 5896</span> <span class="comment">// A helper class that creates the premature-exit file in its</span></div><div class="line"><a name="l05897"></a><span class="lineno"> 5897</span> <span class="comment">// constructor and deletes the file in its destructor.</span></div><div class="line"><a name="l05898"></a><span class="lineno"> 5898</span> <span class="keyword">class </span>ScopedPrematureExitFile {</div><div class="line"><a name="l05899"></a><span class="lineno"> 5899</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l05900"></a><span class="lineno"> 5900</span>  <span class="keyword">explicit</span> ScopedPrematureExitFile(<span class="keyword">const</span> <span class="keywordtype">char</span>* premature_exit_filepath)</div><div class="line"><a name="l05901"></a><span class="lineno"> 5901</span>  : premature_exit_filepath_(premature_exit_filepath ?</div><div class="line"><a name="l05902"></a><span class="lineno"> 5902</span>  premature_exit_filepath : <span class="stringliteral">""</span>) {</div><div class="line"><a name="l05903"></a><span class="lineno"> 5903</span>  <span class="comment">// If a path to the premature-exit file is specified...</span></div><div class="line"><a name="l05904"></a><span class="lineno"> 5904</span>  <span class="keywordflow">if</span> (!premature_exit_filepath_.empty()) {</div><div class="line"><a name="l05905"></a><span class="lineno"> 5905</span>  <span class="comment">// create the file with a single "0" character in it. I/O</span></div><div class="line"><a name="l05906"></a><span class="lineno"> 5906</span>  <span class="comment">// errors are ignored as there's nothing better we can do and we</span></div><div class="line"><a name="l05907"></a><span class="lineno"> 5907</span>  <span class="comment">// don't want to fail the test because of this.</span></div><div class="line"><a name="l05908"></a><span class="lineno"> 5908</span>  FILE* pfile = <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a4042201dcc4932641d484e7ddf94de7d">posix::FOpen</a>(premature_exit_filepath, <span class="stringliteral">"w"</span>);</div><div class="line"><a name="l05909"></a><span class="lineno"> 5909</span>  fwrite(<span class="stringliteral">"0"</span>, 1, 1, pfile);</div><div class="line"><a name="l05910"></a><span class="lineno"> 5910</span>  fclose(pfile);</div><div class="line"><a name="l05911"></a><span class="lineno"> 5911</span>  }</div><div class="line"><a name="l05912"></a><span class="lineno"> 5912</span>  }</div><div class="line"><a name="l05913"></a><span class="lineno"> 5913</span> </div><div class="line"><a name="l05914"></a><span class="lineno"> 5914</span>  ~ScopedPrematureExitFile() {</div><div class="line"><a name="l05915"></a><span class="lineno"> 5915</span>  <span class="keywordflow">if</span> (!premature_exit_filepath_.empty()) {</div><div class="line"><a name="l05916"></a><span class="lineno"> 5916</span>  <span class="keywordtype">int</span> retval = <span class="keyword">remove</span>(premature_exit_filepath_.c_str());</div><div class="line"><a name="l05917"></a><span class="lineno"> 5917</span>  <span class="keywordflow">if</span> (retval) {</div><div class="line"><a name="l05918"></a><span class="lineno"> 5918</span>  <a class="code" href="gtest_8h.html#a8ef4cb4c465db8c15464aecc6d9510ef">GTEST_LOG_</a>(ERROR) << <span class="stringliteral">"Failed to remove premature exit filepath \""</span></div><div class="line"><a name="l05919"></a><span class="lineno"> 5919</span>  << premature_exit_filepath_ << <span class="stringliteral">"\" with error "</span></div><div class="line"><a name="l05920"></a><span class="lineno"> 5920</span>  << retval;</div><div class="line"><a name="l05921"></a><span class="lineno"> 5921</span>  }</div><div class="line"><a name="l05922"></a><span class="lineno"> 5922</span>  }</div><div class="line"><a name="l05923"></a><span class="lineno"> 5923</span>  }</div><div class="line"><a name="l05924"></a><span class="lineno"> 5924</span> </div><div class="line"><a name="l05925"></a><span class="lineno"> 5925</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l05926"></a><span class="lineno"> 5926</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> premature_exit_filepath_;</div><div class="line"><a name="l05927"></a><span class="lineno"> 5927</span> </div><div class="line"><a name="l05928"></a><span class="lineno"> 5928</span>  <a class="code" href="gtest_8h.html#aed8c1888c32b588b0681e88b95031e29">GTEST_DISALLOW_COPY_AND_ASSIGN_</a>(ScopedPrematureExitFile);</div><div class="line"><a name="l05929"></a><span class="lineno"> 5929</span> };</div><div class="line"><a name="l05930"></a><span class="lineno"> 5930</span> </div><div class="line"><a name="l05931"></a><span class="lineno"> 5931</span> } <span class="comment">// namespace internal</span></div><div class="line"><a name="l05932"></a><span class="lineno"> 5932</span> </div><div class="line"><a name="l05933"></a><span class="lineno"> 5933</span> <span class="comment">// class TestEventListeners</span></div><div class="line"><a name="l05934"></a><span class="lineno"> 5934</span> </div><div class="line"><a name="l05935"></a><span class="lineno"> 5935</span> TestEventListeners::TestEventListeners()</div><div class="line"><a name="l05936"></a><span class="lineno"> 5936</span>  : repeater_(new internal::TestEventRepeater()),</div><div class="line"><a name="l05937"></a><span class="lineno"> 5937</span>  default_result_printer_(nullptr),</div><div class="line"><a name="l05938"></a><span class="lineno"> 5938</span>  default_xml_generator_(nullptr) {}</div><div class="line"><a name="l05939"></a><span class="lineno"> 5939</span> </div><div class="line"><a name="l05940"></a><span class="lineno"> 5940</span> TestEventListeners::~TestEventListeners() { <span class="keyword">delete</span> repeater_; }</div><div class="line"><a name="l05941"></a><span class="lineno"> 5941</span> </div><div class="line"><a name="l05942"></a><span class="lineno"> 5942</span> <span class="comment">// Returns the standard listener responsible for the default console</span></div><div class="line"><a name="l05943"></a><span class="lineno"> 5943</span> <span class="comment">// output. Can be removed from the listeners list to shut down default</span></div><div class="line"><a name="l05944"></a><span class="lineno"> 5944</span> <span class="comment">// console output. Note that removing this object from the listener list</span></div><div class="line"><a name="l05945"></a><span class="lineno"> 5945</span> <span class="comment">// with Release transfers its ownership to the user.</span></div><div class="line"><a name="l05946"></a><span class="lineno"> 5946</span> <span class="keywordtype">void</span> TestEventListeners::Append(TestEventListener* listener) {</div><div class="line"><a name="l05947"></a><span class="lineno"> 5947</span>  repeater_->Append(listener);</div><div class="line"><a name="l05948"></a><span class="lineno"> 5948</span> }</div><div class="line"><a name="l05949"></a><span class="lineno"> 5949</span> </div><div class="line"><a name="l05950"></a><span class="lineno"> 5950</span> <span class="comment">// Removes the given event listener from the list and returns it. It then</span></div><div class="line"><a name="l05951"></a><span class="lineno"> 5951</span> <span class="comment">// becomes the caller's responsibility to delete the listener. Returns</span></div><div class="line"><a name="l05952"></a><span class="lineno"> 5952</span> <span class="comment">// NULL if the listener is not found in the list.</span></div><div class="line"><a name="l05953"></a><span class="lineno"> 5953</span> TestEventListener* TestEventListeners::Release(TestEventListener* listener) {</div><div class="line"><a name="l05954"></a><span class="lineno"> 5954</span>  <span class="keywordflow">if</span> (listener == default_result_printer_)</div><div class="line"><a name="l05955"></a><span class="lineno"> 5955</span>  default_result_printer_ = <span class="keyword">nullptr</span>;</div><div class="line"><a name="l05956"></a><span class="lineno"> 5956</span>  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (listener == default_xml_generator_)</div><div class="line"><a name="l05957"></a><span class="lineno"> 5957</span>  default_xml_generator_ = <span class="keyword">nullptr</span>;</div><div class="line"><a name="l05958"></a><span class="lineno"> 5958</span>  <span class="keywordflow">return</span> repeater_->Release(listener);</div><div class="line"><a name="l05959"></a><span class="lineno"> 5959</span> }</div><div class="line"><a name="l05960"></a><span class="lineno"> 5960</span> </div><div class="line"><a name="l05961"></a><span class="lineno"> 5961</span> <span class="comment">// Returns repeater that broadcasts the TestEventListener events to all</span></div><div class="line"><a name="l05962"></a><span class="lineno"> 5962</span> <span class="comment">// subscribers.</span></div><div class="line"><a name="l05963"></a><span class="lineno"> 5963</span> TestEventListener* TestEventListeners::repeater() { <span class="keywordflow">return</span> repeater_; }</div><div class="line"><a name="l05964"></a><span class="lineno"> 5964</span> </div><div class="line"><a name="l05965"></a><span class="lineno"> 5965</span> <span class="comment">// Sets the default_result_printer attribute to the provided listener.</span></div><div class="line"><a name="l05966"></a><span class="lineno"> 5966</span> <span class="comment">// The listener is also added to the listener list and previous</span></div><div class="line"><a name="l05967"></a><span class="lineno"> 5967</span> <span class="comment">// default_result_printer is removed from it and deleted. The listener can</span></div><div class="line"><a name="l05968"></a><span class="lineno"> 5968</span> <span class="comment">// also be NULL in which case it will not be added to the list. Does</span></div><div class="line"><a name="l05969"></a><span class="lineno"> 5969</span> <span class="comment">// nothing if the previous and the current listener objects are the same.</span></div><div class="line"><a name="l05970"></a><span class="lineno"> 5970</span> <span class="keywordtype">void</span> TestEventListeners::SetDefaultResultPrinter(TestEventListener* listener) {</div><div class="line"><a name="l05971"></a><span class="lineno"> 5971</span>  <span class="keywordflow">if</span> (default_result_printer_ != listener) {</div><div class="line"><a name="l05972"></a><span class="lineno"> 5972</span>  <span class="comment">// It is an error to pass this method a listener that is already in the</span></div><div class="line"><a name="l05973"></a><span class="lineno"> 5973</span>  <span class="comment">// list.</span></div><div class="line"><a name="l05974"></a><span class="lineno"> 5974</span>  <span class="keyword">delete</span> Release(default_result_printer_);</div><div class="line"><a name="l05975"></a><span class="lineno"> 5975</span>  default_result_printer_ = listener;</div><div class="line"><a name="l05976"></a><span class="lineno"> 5976</span>  <span class="keywordflow">if</span> (listener != <span class="keyword">nullptr</span>) Append(listener);</div><div class="line"><a name="l05977"></a><span class="lineno"> 5977</span>  }</div><div class="line"><a name="l05978"></a><span class="lineno"> 5978</span> }</div><div class="line"><a name="l05979"></a><span class="lineno"> 5979</span> </div><div class="line"><a name="l05980"></a><span class="lineno"> 5980</span> <span class="comment">// Sets the default_xml_generator attribute to the provided listener. The</span></div><div class="line"><a name="l05981"></a><span class="lineno"> 5981</span> <span class="comment">// listener is also added to the listener list and previous</span></div><div class="line"><a name="l05982"></a><span class="lineno"> 5982</span> <span class="comment">// default_xml_generator is removed from it and deleted. The listener can</span></div><div class="line"><a name="l05983"></a><span class="lineno"> 5983</span> <span class="comment">// also be NULL in which case it will not be added to the list. Does</span></div><div class="line"><a name="l05984"></a><span class="lineno"> 5984</span> <span class="comment">// nothing if the previous and the current listener objects are the same.</span></div><div class="line"><a name="l05985"></a><span class="lineno"> 5985</span> <span class="keywordtype">void</span> TestEventListeners::SetDefaultXmlGenerator(TestEventListener* listener) {</div><div class="line"><a name="l05986"></a><span class="lineno"> 5986</span>  <span class="keywordflow">if</span> (default_xml_generator_ != listener) {</div><div class="line"><a name="l05987"></a><span class="lineno"> 5987</span>  <span class="comment">// It is an error to pass this method a listener that is already in the</span></div><div class="line"><a name="l05988"></a><span class="lineno"> 5988</span>  <span class="comment">// list.</span></div><div class="line"><a name="l05989"></a><span class="lineno"> 5989</span>  <span class="keyword">delete</span> Release(default_xml_generator_);</div><div class="line"><a name="l05990"></a><span class="lineno"> 5990</span>  default_xml_generator_ = listener;</div><div class="line"><a name="l05991"></a><span class="lineno"> 5991</span>  <span class="keywordflow">if</span> (listener != <span class="keyword">nullptr</span>) Append(listener);</div><div class="line"><a name="l05992"></a><span class="lineno"> 5992</span>  }</div><div class="line"><a name="l05993"></a><span class="lineno"> 5993</span> }</div><div class="line"><a name="l05994"></a><span class="lineno"> 5994</span> </div><div class="line"><a name="l05995"></a><span class="lineno"> 5995</span> <span class="comment">// Controls whether events will be forwarded by the repeater to the</span></div><div class="line"><a name="l05996"></a><span class="lineno"> 5996</span> <span class="comment">// listeners in the list.</span></div><div class="line"><a name="l05997"></a><span class="lineno"> 5997</span> <span class="keywordtype">bool</span> TestEventListeners::EventForwardingEnabled()<span class="keyword"> const </span>{</div><div class="line"><a name="l05998"></a><span class="lineno"> 5998</span>  <span class="keywordflow">return</span> repeater_->forwarding_enabled();</div><div class="line"><a name="l05999"></a><span class="lineno"> 5999</span> }</div><div class="line"><a name="l06000"></a><span class="lineno"> 6000</span> </div><div class="line"><a name="l06001"></a><span class="lineno"> 6001</span> <span class="keywordtype">void</span> TestEventListeners::SuppressEventForwarding() {</div><div class="line"><a name="l06002"></a><span class="lineno"> 6002</span>  repeater_->set_forwarding_enabled(<span class="keyword">false</span>);</div><div class="line"><a name="l06003"></a><span class="lineno"> 6003</span> }</div><div class="line"><a name="l06004"></a><span class="lineno"> 6004</span> </div><div class="line"><a name="l06005"></a><span class="lineno"> 6005</span> <span class="comment">// class UnitTest</span></div><div class="line"><a name="l06006"></a><span class="lineno"> 6006</span> </div><div class="line"><a name="l06007"></a><span class="lineno"> 6007</span> <span class="comment">// Gets the singleton UnitTest object. The first time this method is</span></div><div class="line"><a name="l06008"></a><span class="lineno"> 6008</span> <span class="comment">// called, a UnitTest object is constructed and returned. Consecutive</span></div><div class="line"><a name="l06009"></a><span class="lineno"> 6009</span> <span class="comment">// calls will return the same object.</span></div><div class="line"><a name="l06010"></a><span class="lineno"> 6010</span> <span class="comment">//</span></div><div class="line"><a name="l06011"></a><span class="lineno"> 6011</span> <span class="comment">// We don't protect this under mutex_ as a user is not supposed to</span></div><div class="line"><a name="l06012"></a><span class="lineno"> 6012</span> <span class="comment">// call this before main() starts, from which point on the return</span></div><div class="line"><a name="l06013"></a><span class="lineno"> 6013</span> <span class="comment">// value will never change.</span></div><div class="line"><a name="l06014"></a><span class="lineno"> 6014</span> UnitTest* UnitTest::GetInstance() {</div><div class="line"><a name="l06015"></a><span class="lineno"> 6015</span>  <span class="comment">// CodeGear C++Builder insists on a public destructor for the</span></div><div class="line"><a name="l06016"></a><span class="lineno"> 6016</span>  <span class="comment">// default implementation. Use this implementation to keep good OO</span></div><div class="line"><a name="l06017"></a><span class="lineno"> 6017</span>  <span class="comment">// design with private destructor.</span></div><div class="line"><a name="l06018"></a><span class="lineno"> 6018</span> </div><div class="line"><a name="l06019"></a><span class="lineno"> 6019</span> <span class="preprocessor">#if defined(__BORLANDC__)</span></div><div class="line"><a name="l06020"></a><span class="lineno"> 6020</span>  <span class="keyword">static</span> UnitTest* <span class="keyword">const</span> instance = <span class="keyword">new</span> UnitTest;</div><div class="line"><a name="l06021"></a><span class="lineno"> 6021</span>  <span class="keywordflow">return</span> instance;</div><div class="line"><a name="l06022"></a><span class="lineno"> 6022</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l06023"></a><span class="lineno"> 6023</span>  <span class="keyword">static</span> UnitTest instance;</div><div class="line"><a name="l06024"></a><span class="lineno"> 6024</span>  <span class="keywordflow">return</span> &instance;</div><div class="line"><a name="l06025"></a><span class="lineno"> 6025</span> <span class="preprocessor">#endif // defined(__BORLANDC__)</span></div><div class="line"><a name="l06026"></a><span class="lineno"> 6026</span> }</div><div class="line"><a name="l06027"></a><span class="lineno"> 6027</span> </div><div class="line"><a name="l06028"></a><span class="lineno"> 6028</span> <span class="comment">// Gets the number of successful test suites.</span></div><div class="line"><a name="l06029"></a><span class="lineno"> 6029</span> <span class="keywordtype">int</span> UnitTest::successful_test_suite_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l06030"></a><span class="lineno"> 6030</span>  <span class="keywordflow">return</span> impl()->successful_test_suite_count();</div><div class="line"><a name="l06031"></a><span class="lineno"> 6031</span> }</div><div class="line"><a name="l06032"></a><span class="lineno"> 6032</span> </div><div class="line"><a name="l06033"></a><span class="lineno"> 6033</span> <span class="comment">// Gets the number of failed test suites.</span></div><div class="line"><a name="l06034"></a><span class="lineno"> 6034</span> <span class="keywordtype">int</span> UnitTest::failed_test_suite_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l06035"></a><span class="lineno"> 6035</span>  <span class="keywordflow">return</span> impl()->failed_test_suite_count();</div><div class="line"><a name="l06036"></a><span class="lineno"> 6036</span> }</div><div class="line"><a name="l06037"></a><span class="lineno"> 6037</span> </div><div class="line"><a name="l06038"></a><span class="lineno"> 6038</span> <span class="comment">// Gets the number of all test suites.</span></div><div class="line"><a name="l06039"></a><span class="lineno"> 6039</span> <span class="keywordtype">int</span> UnitTest::total_test_suite_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l06040"></a><span class="lineno"> 6040</span>  <span class="keywordflow">return</span> impl()->total_test_suite_count();</div><div class="line"><a name="l06041"></a><span class="lineno"> 6041</span> }</div><div class="line"><a name="l06042"></a><span class="lineno"> 6042</span> </div><div class="line"><a name="l06043"></a><span class="lineno"> 6043</span> <span class="comment">// Gets the number of all test suites that contain at least one test</span></div><div class="line"><a name="l06044"></a><span class="lineno"> 6044</span> <span class="comment">// that should run.</span></div><div class="line"><a name="l06045"></a><span class="lineno"> 6045</span> <span class="keywordtype">int</span> UnitTest::test_suite_to_run_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l06046"></a><span class="lineno"> 6046</span>  <span class="keywordflow">return</span> impl()->test_suite_to_run_count();</div><div class="line"><a name="l06047"></a><span class="lineno"> 6047</span> }</div><div class="line"><a name="l06048"></a><span class="lineno"> 6048</span> </div><div class="line"><a name="l06049"></a><span class="lineno"> 6049</span> <span class="comment">// Legacy API is deprecated but still available</span></div><div class="line"><a name="l06050"></a><span class="lineno"> 6050</span> <span class="preprocessor">#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_</span></div><div class="line"><a name="l06051"></a><span class="lineno"> 6051</span> <span class="keywordtype">int</span> UnitTest::successful_test_case_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l06052"></a><span class="lineno"> 6052</span>  <span class="keywordflow">return</span> impl()->successful_test_suite_count();</div><div class="line"><a name="l06053"></a><span class="lineno"> 6053</span> }</div><div class="line"><a name="l06054"></a><span class="lineno"> 6054</span> <span class="keywordtype">int</span> UnitTest::failed_test_case_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l06055"></a><span class="lineno"> 6055</span>  <span class="keywordflow">return</span> impl()->failed_test_suite_count();</div><div class="line"><a name="l06056"></a><span class="lineno"> 6056</span> }</div><div class="line"><a name="l06057"></a><span class="lineno"> 6057</span> <span class="keywordtype">int</span> UnitTest::total_test_case_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l06058"></a><span class="lineno"> 6058</span>  <span class="keywordflow">return</span> impl()->total_test_suite_count();</div><div class="line"><a name="l06059"></a><span class="lineno"> 6059</span> }</div><div class="line"><a name="l06060"></a><span class="lineno"> 6060</span> <span class="keywordtype">int</span> UnitTest::test_case_to_run_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l06061"></a><span class="lineno"> 6061</span>  <span class="keywordflow">return</span> impl()->test_suite_to_run_count();</div><div class="line"><a name="l06062"></a><span class="lineno"> 6062</span> }</div><div class="line"><a name="l06063"></a><span class="lineno"> 6063</span> <span class="preprocessor">#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_</span></div><div class="line"><a name="l06064"></a><span class="lineno"> 6064</span> </div><div class="line"><a name="l06065"></a><span class="lineno"> 6065</span> <span class="comment">// Gets the number of successful tests.</span></div><div class="line"><a name="l06066"></a><span class="lineno"> 6066</span> <span class="keywordtype">int</span> UnitTest::successful_test_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l06067"></a><span class="lineno"> 6067</span>  <span class="keywordflow">return</span> impl()->successful_test_count();</div><div class="line"><a name="l06068"></a><span class="lineno"> 6068</span> }</div><div class="line"><a name="l06069"></a><span class="lineno"> 6069</span> </div><div class="line"><a name="l06070"></a><span class="lineno"> 6070</span> <span class="comment">// Gets the number of skipped tests.</span></div><div class="line"><a name="l06071"></a><span class="lineno"> 6071</span> <span class="keywordtype">int</span> UnitTest::skipped_test_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l06072"></a><span class="lineno"> 6072</span>  <span class="keywordflow">return</span> impl()->skipped_test_count();</div><div class="line"><a name="l06073"></a><span class="lineno"> 6073</span> }</div><div class="line"><a name="l06074"></a><span class="lineno"> 6074</span> </div><div class="line"><a name="l06075"></a><span class="lineno"> 6075</span> <span class="comment">// Gets the number of failed tests.</span></div><div class="line"><a name="l06076"></a><span class="lineno"> 6076</span> <span class="keywordtype">int</span> UnitTest::failed_test_count()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> impl()->failed_test_count(); }</div><div class="line"><a name="l06077"></a><span class="lineno"> 6077</span> </div><div class="line"><a name="l06078"></a><span class="lineno"> 6078</span> <span class="comment">// Gets the number of disabled tests that will be reported in the XML report.</span></div><div class="line"><a name="l06079"></a><span class="lineno"> 6079</span> <span class="keywordtype">int</span> UnitTest::reportable_disabled_test_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l06080"></a><span class="lineno"> 6080</span>  <span class="keywordflow">return</span> impl()->reportable_disabled_test_count();</div><div class="line"><a name="l06081"></a><span class="lineno"> 6081</span> }</div><div class="line"><a name="l06082"></a><span class="lineno"> 6082</span> </div><div class="line"><a name="l06083"></a><span class="lineno"> 6083</span> <span class="comment">// Gets the number of disabled tests.</span></div><div class="line"><a name="l06084"></a><span class="lineno"> 6084</span> <span class="keywordtype">int</span> UnitTest::disabled_test_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l06085"></a><span class="lineno"> 6085</span>  <span class="keywordflow">return</span> impl()->disabled_test_count();</div><div class="line"><a name="l06086"></a><span class="lineno"> 6086</span> }</div><div class="line"><a name="l06087"></a><span class="lineno"> 6087</span> </div><div class="line"><a name="l06088"></a><span class="lineno"> 6088</span> <span class="comment">// Gets the number of tests to be printed in the XML report.</span></div><div class="line"><a name="l06089"></a><span class="lineno"> 6089</span> <span class="keywordtype">int</span> UnitTest::reportable_test_count()<span class="keyword"> const </span>{</div><div class="line"><a name="l06090"></a><span class="lineno"> 6090</span>  <span class="keywordflow">return</span> impl()->reportable_test_count();</div><div class="line"><a name="l06091"></a><span class="lineno"> 6091</span> }</div><div class="line"><a name="l06092"></a><span class="lineno"> 6092</span> </div><div class="line"><a name="l06093"></a><span class="lineno"> 6093</span> <span class="comment">// Gets the number of all tests.</span></div><div class="line"><a name="l06094"></a><span class="lineno"> 6094</span> <span class="keywordtype">int</span> UnitTest::total_test_count()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> impl()->total_test_count(); }</div><div class="line"><a name="l06095"></a><span class="lineno"> 6095</span> </div><div class="line"><a name="l06096"></a><span class="lineno"> 6096</span> <span class="comment">// Gets the number of tests that should run.</span></div><div class="line"><a name="l06097"></a><span class="lineno"> 6097</span> <span class="keywordtype">int</span> UnitTest::test_to_run_count()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> impl()->test_to_run_count(); }</div><div class="line"><a name="l06098"></a><span class="lineno"> 6098</span> </div><div class="line"><a name="l06099"></a><span class="lineno"> 6099</span> <span class="comment">// Gets the time of the test program start, in ms from the start of the</span></div><div class="line"><a name="l06100"></a><span class="lineno"> 6100</span> <span class="comment">// UNIX epoch.</span></div><div class="line"><a name="l06101"></a><span class="lineno"> 6101</span> <a class="code" href="namespacetesting_1_1internal.html#a66a845df404b38fe85c5e14a069f255a">internal::TimeInMillis</a> UnitTest::start_timestamp()<span class="keyword"> const </span>{</div><div class="line"><a name="l06102"></a><span class="lineno"> 6102</span>  <span class="keywordflow">return</span> impl()->start_timestamp();</div><div class="line"><a name="l06103"></a><span class="lineno"> 6103</span> }</div><div class="line"><a name="l06104"></a><span class="lineno"> 6104</span> </div><div class="line"><a name="l06105"></a><span class="lineno"> 6105</span> <span class="comment">// Gets the elapsed time, in milliseconds.</span></div><div class="line"><a name="l06106"></a><span class="lineno"> 6106</span> <a class="code" href="namespacetesting_1_1internal.html#a66a845df404b38fe85c5e14a069f255a">internal::TimeInMillis</a> UnitTest::elapsed_time()<span class="keyword"> const </span>{</div><div class="line"><a name="l06107"></a><span class="lineno"> 6107</span>  <span class="keywordflow">return</span> impl()->elapsed_time();</div><div class="line"><a name="l06108"></a><span class="lineno"> 6108</span> }</div><div class="line"><a name="l06109"></a><span class="lineno"> 6109</span> </div><div class="line"><a name="l06110"></a><span class="lineno"> 6110</span> <span class="comment">// Returns true iff the unit test passed (i.e. all test suites passed).</span></div><div class="line"><a name="l06111"></a><span class="lineno"> 6111</span> <span class="keywordtype">bool</span> UnitTest::Passed()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> impl()->Passed(); }</div><div class="line"><a name="l06112"></a><span class="lineno"> 6112</span> </div><div class="line"><a name="l06113"></a><span class="lineno"> 6113</span> <span class="comment">// Returns true iff the unit test failed (i.e. some test suite failed</span></div><div class="line"><a name="l06114"></a><span class="lineno"> 6114</span> <span class="comment">// or something outside of all tests failed).</span></div><div class="line"><a name="l06115"></a><span class="lineno"> 6115</span> <span class="keywordtype">bool</span> UnitTest::Failed()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> impl()->Failed(); }</div><div class="line"><a name="l06116"></a><span class="lineno"> 6116</span> </div><div class="line"><a name="l06117"></a><span class="lineno"> 6117</span> <span class="comment">// Gets the i-th test suite among all the test suites. i can range from 0 to</span></div><div class="line"><a name="l06118"></a><span class="lineno"> 6118</span> <span class="comment">// total_test_suite_count() - 1. If i is not in that range, returns NULL.</span></div><div class="line"><a name="l06119"></a><span class="lineno"> 6119</span> <span class="keyword">const</span> TestSuite* UnitTest::GetTestSuite(<span class="keywordtype">int</span> i)<span class="keyword"> const </span>{</div><div class="line"><a name="l06120"></a><span class="lineno"> 6120</span>  <span class="keywordflow">return</span> impl()->GetTestSuite(i);</div><div class="line"><a name="l06121"></a><span class="lineno"> 6121</span> }</div><div class="line"><a name="l06122"></a><span class="lineno"> 6122</span> </div><div class="line"><a name="l06123"></a><span class="lineno"> 6123</span> <span class="comment">// Legacy API is deprecated but still available</span></div><div class="line"><a name="l06124"></a><span class="lineno"> 6124</span> <span class="preprocessor">#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_</span></div><div class="line"><a name="l06125"></a><span class="lineno"> 6125</span> <span class="keyword">const</span> TestCase* UnitTest::GetTestCase(<span class="keywordtype">int</span> i)<span class="keyword"> const </span>{</div><div class="line"><a name="l06126"></a><span class="lineno"> 6126</span>  <span class="keywordflow">return</span> impl()->GetTestCase(i);</div><div class="line"><a name="l06127"></a><span class="lineno"> 6127</span> }</div><div class="line"><a name="l06128"></a><span class="lineno"> 6128</span> <span class="preprocessor">#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_</span></div><div class="line"><a name="l06129"></a><span class="lineno"> 6129</span> </div><div class="line"><a name="l06130"></a><span class="lineno"> 6130</span> <span class="comment">// Returns the TestResult containing information on test failures and</span></div><div class="line"><a name="l06131"></a><span class="lineno"> 6131</span> <span class="comment">// properties logged outside of individual test suites.</span></div><div class="line"><a name="l06132"></a><span class="lineno"> 6132</span> <span class="keyword">const</span> TestResult& UnitTest::ad_hoc_test_result()<span class="keyword"> const </span>{</div><div class="line"><a name="l06133"></a><span class="lineno"> 6133</span>  <span class="keywordflow">return</span> *impl()->ad_hoc_test_result();</div><div class="line"><a name="l06134"></a><span class="lineno"> 6134</span> }</div><div class="line"><a name="l06135"></a><span class="lineno"> 6135</span> </div><div class="line"><a name="l06136"></a><span class="lineno"> 6136</span> <span class="comment">// Gets the i-th test suite among all the test suites. i can range from 0 to</span></div><div class="line"><a name="l06137"></a><span class="lineno"> 6137</span> <span class="comment">// total_test_suite_count() - 1. If i is not in that range, returns NULL.</span></div><div class="line"><a name="l06138"></a><span class="lineno"> 6138</span> TestSuite* UnitTest::GetMutableTestSuite(<span class="keywordtype">int</span> i) {</div><div class="line"><a name="l06139"></a><span class="lineno"> 6139</span>  <span class="keywordflow">return</span> impl()->GetMutableSuiteCase(i);</div><div class="line"><a name="l06140"></a><span class="lineno"> 6140</span> }</div><div class="line"><a name="l06141"></a><span class="lineno"> 6141</span> </div><div class="line"><a name="l06142"></a><span class="lineno"> 6142</span> <span class="comment">// Returns the list of event listeners that can be used to track events</span></div><div class="line"><a name="l06143"></a><span class="lineno"> 6143</span> <span class="comment">// inside Google Test.</span></div><div class="line"><a name="l06144"></a><span class="lineno"> 6144</span> TestEventListeners& UnitTest::listeners() {</div><div class="line"><a name="l06145"></a><span class="lineno"> 6145</span>  <span class="keywordflow">return</span> *impl()->listeners();</div><div class="line"><a name="l06146"></a><span class="lineno"> 6146</span> }</div><div class="line"><a name="l06147"></a><span class="lineno"> 6147</span> </div><div class="line"><a name="l06148"></a><span class="lineno"> 6148</span> <span class="comment">// Registers and returns a global test environment. When a test</span></div><div class="line"><a name="l06149"></a><span class="lineno"> 6149</span> <span class="comment">// program is run, all global test environments will be set-up in the</span></div><div class="line"><a name="l06150"></a><span class="lineno"> 6150</span> <span class="comment">// order they were registered. After all tests in the program have</span></div><div class="line"><a name="l06151"></a><span class="lineno"> 6151</span> <span class="comment">// finished, all global test environments will be torn-down in the</span></div><div class="line"><a name="l06152"></a><span class="lineno"> 6152</span> <span class="comment">// *reverse* order they were registered.</span></div><div class="line"><a name="l06153"></a><span class="lineno"> 6153</span> <span class="comment">//</span></div><div class="line"><a name="l06154"></a><span class="lineno"> 6154</span> <span class="comment">// The UnitTest object takes ownership of the given environment.</span></div><div class="line"><a name="l06155"></a><span class="lineno"> 6155</span> <span class="comment">//</span></div><div class="line"><a name="l06156"></a><span class="lineno"> 6156</span> <span class="comment">// We don't protect this under mutex_, as we only support calling it</span></div><div class="line"><a name="l06157"></a><span class="lineno"> 6157</span> <span class="comment">// from the main thread.</span></div><div class="line"><a name="l06158"></a><span class="lineno"> 6158</span> Environment* UnitTest::AddEnvironment(Environment* env) {</div><div class="line"><a name="l06159"></a><span class="lineno"> 6159</span>  <span class="keywordflow">if</span> (env == <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l06160"></a><span class="lineno"> 6160</span>  <span class="keywordflow">return</span> <span class="keyword">nullptr</span>;</div><div class="line"><a name="l06161"></a><span class="lineno"> 6161</span>  }</div><div class="line"><a name="l06162"></a><span class="lineno"> 6162</span> </div><div class="line"><a name="l06163"></a><span class="lineno"> 6163</span>  impl_->environments().push_back(env);</div><div class="line"><a name="l06164"></a><span class="lineno"> 6164</span>  <span class="keywordflow">return</span> env;</div><div class="line"><a name="l06165"></a><span class="lineno"> 6165</span> }</div><div class="line"><a name="l06166"></a><span class="lineno"> 6166</span> </div><div class="line"><a name="l06167"></a><span class="lineno"> 6167</span> <span class="comment">// Adds a TestPartResult to the current TestResult object. All Google Test</span></div><div class="line"><a name="l06168"></a><span class="lineno"> 6168</span> <span class="comment">// assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc) eventually call</span></div><div class="line"><a name="l06169"></a><span class="lineno"> 6169</span> <span class="comment">// this to report their results. The user code should use the</span></div><div class="line"><a name="l06170"></a><span class="lineno"> 6170</span> <span class="comment">// assertion macros instead of calling this directly.</span></div><div class="line"><a name="l06171"></a><span class="lineno"> 6171</span> <span class="keywordtype">void</span> UnitTest::AddTestPartResult(</div><div class="line"><a name="l06172"></a><span class="lineno"> 6172</span>  TestPartResult::Type result_type,</div><div class="line"><a name="l06173"></a><span class="lineno"> 6173</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* file_name,</div><div class="line"><a name="l06174"></a><span class="lineno"> 6174</span>  <span class="keywordtype">int</span> line_number,</div><div class="line"><a name="l06175"></a><span class="lineno"> 6175</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& message,</div><div class="line"><a name="l06176"></a><span class="lineno"> 6176</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& os_stack_trace) <a class="code" href="gtest_8h.html#a69abff5a4efdd07bd5faebe3dd318d06">GTEST_LOCK_EXCLUDED_</a>(mutex_) {</div><div class="line"><a name="l06177"></a><span class="lineno"> 6177</span>  Message msg;</div><div class="line"><a name="l06178"></a><span class="lineno"> 6178</span>  msg << message;</div><div class="line"><a name="l06179"></a><span class="lineno"> 6179</span> </div><div class="line"><a name="l06180"></a><span class="lineno"> 6180</span>  <a class="code" href="namespacetesting_1_1internal.html#a08b187c6cc4e28400aadf9a32fccc8de">internal::MutexLock</a> lock(&mutex_);</div><div class="line"><a name="l06181"></a><span class="lineno"> 6181</span>  <span class="keywordflow">if</span> (impl_->gtest_trace_stack().size() > 0) {</div><div class="line"><a name="l06182"></a><span class="lineno"> 6182</span>  msg << <span class="stringliteral">"\n"</span> << <a class="code" href="gtest_8h.html#a13d98c217176bd8722c395b9225fc19d">GTEST_NAME_</a> << <span class="stringliteral">" trace:"</span>;</div><div class="line"><a name="l06183"></a><span class="lineno"> 6183</span> </div><div class="line"><a name="l06184"></a><span class="lineno"> 6184</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = static_cast<int>(impl_->gtest_trace_stack().size());</div><div class="line"><a name="l06185"></a><span class="lineno"> 6185</span>  i > 0; --i) {</div><div class="line"><a name="l06186"></a><span class="lineno"> 6186</span>  <span class="keyword">const</span> internal::TraceInfo& trace = impl_->gtest_trace_stack()[i - 1];</div><div class="line"><a name="l06187"></a><span class="lineno"> 6187</span>  msg << <span class="stringliteral">"\n"</span> << <a class="code" href="namespacetesting_1_1internal.html#a31b7c3abed4a7c395f42c61e993989f4">internal::FormatFileLocation</a>(trace.file, trace.line)</div><div class="line"><a name="l06188"></a><span class="lineno"> 6188</span>  << <span class="stringliteral">" "</span> << trace.message;</div><div class="line"><a name="l06189"></a><span class="lineno"> 6189</span>  }</div><div class="line"><a name="l06190"></a><span class="lineno"> 6190</span>  }</div><div class="line"><a name="l06191"></a><span class="lineno"> 6191</span> </div><div class="line"><a name="l06192"></a><span class="lineno"> 6192</span>  <span class="keywordflow">if</span> (os_stack_trace.c_str() != <span class="keyword">nullptr</span> && !os_stack_trace.empty()) {</div><div class="line"><a name="l06193"></a><span class="lineno"> 6193</span>  msg << <a class="code" href="namespacetesting_1_1internal.html#a999c7ef9ff01b6d2d76669372c444aa3">internal::kStackTraceMarker</a> << os_stack_trace;</div><div class="line"><a name="l06194"></a><span class="lineno"> 6194</span>  }</div><div class="line"><a name="l06195"></a><span class="lineno"> 6195</span> </div><div class="line"><a name="l06196"></a><span class="lineno"> 6196</span>  <span class="keyword">const</span> TestPartResult result = TestPartResult(</div><div class="line"><a name="l06197"></a><span class="lineno"> 6197</span>  result_type, file_name, line_number, msg.GetString().c_str());</div><div class="line"><a name="l06198"></a><span class="lineno"> 6198</span>  impl_->GetTestPartResultReporterForCurrentThread()-></div><div class="line"><a name="l06199"></a><span class="lineno"> 6199</span>  ReportTestPartResult(result);</div><div class="line"><a name="l06200"></a><span class="lineno"> 6200</span> </div><div class="line"><a name="l06201"></a><span class="lineno"> 6201</span>  <span class="keywordflow">if</span> (result_type != TestPartResult::kSuccess &&</div><div class="line"><a name="l06202"></a><span class="lineno"> 6202</span>  result_type != TestPartResult::kSkip) {</div><div class="line"><a name="l06203"></a><span class="lineno"> 6203</span>  <span class="comment">// gtest_break_on_failure takes precedence over</span></div><div class="line"><a name="l06204"></a><span class="lineno"> 6204</span>  <span class="comment">// gtest_throw_on_failure. This allows a user to set the latter</span></div><div class="line"><a name="l06205"></a><span class="lineno"> 6205</span>  <span class="comment">// in the code (perhaps in order to use Google Test assertions</span></div><div class="line"><a name="l06206"></a><span class="lineno"> 6206</span>  <span class="comment">// with another testing framework) and specify the former on the</span></div><div class="line"><a name="l06207"></a><span class="lineno"> 6207</span>  <span class="comment">// command line for debugging.</span></div><div class="line"><a name="l06208"></a><span class="lineno"> 6208</span>  <span class="keywordflow">if</span> (<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(break_on_failure)) {</div><div class="line"><a name="l06209"></a><span class="lineno"> 6209</span> <span class="preprocessor">#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT</span></div><div class="line"><a name="l06210"></a><span class="lineno"> 6210</span>  <span class="comment">// Using DebugBreak on Windows allows gtest to still break into a debugger</span></div><div class="line"><a name="l06211"></a><span class="lineno"> 6211</span>  <span class="comment">// when a failure happens and both the --gtest_break_on_failure and</span></div><div class="line"><a name="l06212"></a><span class="lineno"> 6212</span>  <span class="comment">// the --gtest_catch_exceptions flags are specified.</span></div><div class="line"><a name="l06213"></a><span class="lineno"> 6213</span>  DebugBreak();</div><div class="line"><a name="l06214"></a><span class="lineno"> 6214</span> <span class="preprocessor">#elif (!defined(__native_client__)) && \</span></div><div class="line"><a name="l06215"></a><span class="lineno"> 6215</span> <span class="preprocessor"> ((defined(__clang__) || defined(__GNUC__)) && \</span></div><div class="line"><a name="l06216"></a><span class="lineno"> 6216</span> <span class="preprocessor"> (defined(__x86_64__) || defined(__i386__)))</span></div><div class="line"><a name="l06217"></a><span class="lineno"> 6217</span>  <span class="comment">// with clang/gcc we can achieve the same effect on x86 by invoking int3</span></div><div class="line"><a name="l06218"></a><span class="lineno"> 6218</span>  <span class="keyword">asm</span>(<span class="stringliteral">"int3"</span>);</div><div class="line"><a name="l06219"></a><span class="lineno"> 6219</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l06220"></a><span class="lineno"> 6220</span>  <span class="comment">// Dereference nullptr through a volatile pointer to prevent the compiler</span></div><div class="line"><a name="l06221"></a><span class="lineno"> 6221</span>  <span class="comment">// from removing. We use this rather than abort() or __builtin_trap() for</span></div><div class="line"><a name="l06222"></a><span class="lineno"> 6222</span>  <span class="comment">// portability: some debuggers don't correctly trap abort().</span></div><div class="line"><a name="l06223"></a><span class="lineno"> 6223</span>  *<span class="keyword">static_cast<</span><span class="keyword">volatile </span><span class="keywordtype">int</span>*<span class="keyword">></span>(<span class="keyword">nullptr</span>) = 1;</div><div class="line"><a name="l06224"></a><span class="lineno"> 6224</span> <span class="preprocessor">#endif // GTEST_OS_WINDOWS</span></div><div class="line"><a name="l06225"></a><span class="lineno"> 6225</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(throw_on_failure)) {</div><div class="line"><a name="l06226"></a><span class="lineno"> 6226</span> <span class="preprocessor">#if GTEST_HAS_EXCEPTIONS</span></div><div class="line"><a name="l06227"></a><span class="lineno"> 6227</span>  <span class="keywordflow">throw</span> internal::GoogleTestFailureException(result);</div><div class="line"><a name="l06228"></a><span class="lineno"> 6228</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l06229"></a><span class="lineno"> 6229</span>  <span class="comment">// We cannot call abort() as it generates a pop-up in debug mode</span></div><div class="line"><a name="l06230"></a><span class="lineno"> 6230</span>  <span class="comment">// that cannot be suppressed in VC 7.1 or below.</span></div><div class="line"><a name="l06231"></a><span class="lineno"> 6231</span>  exit(1);</div><div class="line"><a name="l06232"></a><span class="lineno"> 6232</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l06233"></a><span class="lineno"> 6233</span>  }</div><div class="line"><a name="l06234"></a><span class="lineno"> 6234</span>  }</div><div class="line"><a name="l06235"></a><span class="lineno"> 6235</span> }</div><div class="line"><a name="l06236"></a><span class="lineno"> 6236</span> </div><div class="line"><a name="l06237"></a><span class="lineno"> 6237</span> <span class="comment">// Adds a TestProperty to the current TestResult object when invoked from</span></div><div class="line"><a name="l06238"></a><span class="lineno"> 6238</span> <span class="comment">// inside a test, to current TestSuite's ad_hoc_test_result_ when invoked</span></div><div class="line"><a name="l06239"></a><span class="lineno"> 6239</span> <span class="comment">// from SetUpTestSuite or TearDownTestSuite, or to the global property set</span></div><div class="line"><a name="l06240"></a><span class="lineno"> 6240</span> <span class="comment">// when invoked elsewhere. If the result already contains a property with</span></div><div class="line"><a name="l06241"></a><span class="lineno"> 6241</span> <span class="comment">// the same key, the value will be updated.</span></div><div class="line"><a name="l06242"></a><span class="lineno"> 6242</span> <span class="keywordtype">void</span> UnitTest::RecordProperty(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& key,</div><div class="line"><a name="l06243"></a><span class="lineno"> 6243</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& value) {</div><div class="line"><a name="l06244"></a><span class="lineno"> 6244</span>  impl_->RecordProperty(TestProperty(key, value));</div><div class="line"><a name="l06245"></a><span class="lineno"> 6245</span> }</div><div class="line"><a name="l06246"></a><span class="lineno"> 6246</span> </div><div class="line"><a name="l06247"></a><span class="lineno"> 6247</span> <span class="comment">// Runs all tests in this UnitTest object and prints the result.</span></div><div class="line"><a name="l06248"></a><span class="lineno"> 6248</span> <span class="comment">// Returns 0 if successful, or 1 otherwise.</span></div><div class="line"><a name="l06249"></a><span class="lineno"> 6249</span> <span class="comment">//</span></div><div class="line"><a name="l06250"></a><span class="lineno"> 6250</span> <span class="comment">// We don't protect this under mutex_, as we only support calling it</span></div><div class="line"><a name="l06251"></a><span class="lineno"> 6251</span> <span class="comment">// from the main thread.</span></div><div class="line"><a name="l06252"></a><span class="lineno"> 6252</span> <span class="keywordtype">int</span> UnitTest::Run() {</div><div class="line"><a name="l06253"></a><span class="lineno"> 6253</span>  <span class="keyword">const</span> <span class="keywordtype">bool</span> in_death_test_child_process =</div><div class="line"><a name="l06254"></a><span class="lineno"> 6254</span>  <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">internal::GTEST_FLAG</a>(internal_run_death_test).length() > 0;</div><div class="line"><a name="l06255"></a><span class="lineno"> 6255</span> </div><div class="line"><a name="l06256"></a><span class="lineno"> 6256</span>  <span class="comment">// Google Test implements this protocol for catching that a test</span></div><div class="line"><a name="l06257"></a><span class="lineno"> 6257</span>  <span class="comment">// program exits before returning control to Google Test:</span></div><div class="line"><a name="l06258"></a><span class="lineno"> 6258</span>  <span class="comment">//</span></div><div class="line"><a name="l06259"></a><span class="lineno"> 6259</span>  <span class="comment">// 1. Upon start, Google Test creates a file whose absolute path</span></div><div class="line"><a name="l06260"></a><span class="lineno"> 6260</span>  <span class="comment">// is specified by the environment variable</span></div><div class="line"><a name="l06261"></a><span class="lineno"> 6261</span>  <span class="comment">// TEST_PREMATURE_EXIT_FILE.</span></div><div class="line"><a name="l06262"></a><span class="lineno"> 6262</span>  <span class="comment">// 2. When Google Test has finished its work, it deletes the file.</span></div><div class="line"><a name="l06263"></a><span class="lineno"> 6263</span>  <span class="comment">//</span></div><div class="line"><a name="l06264"></a><span class="lineno"> 6264</span>  <span class="comment">// This allows a test runner to set TEST_PREMATURE_EXIT_FILE before</span></div><div class="line"><a name="l06265"></a><span class="lineno"> 6265</span>  <span class="comment">// running a Google-Test-based test program and check the existence</span></div><div class="line"><a name="l06266"></a><span class="lineno"> 6266</span>  <span class="comment">// of the file at the end of the test execution to see if it has</span></div><div class="line"><a name="l06267"></a><span class="lineno"> 6267</span>  <span class="comment">// exited prematurely.</span></div><div class="line"><a name="l06268"></a><span class="lineno"> 6268</span> </div><div class="line"><a name="l06269"></a><span class="lineno"> 6269</span>  <span class="comment">// If we are in the child process of a death test, don't</span></div><div class="line"><a name="l06270"></a><span class="lineno"> 6270</span>  <span class="comment">// create/delete the premature exit file, as doing so is unnecessary</span></div><div class="line"><a name="l06271"></a><span class="lineno"> 6271</span>  <span class="comment">// and will confuse the parent process. Otherwise, create/delete</span></div><div class="line"><a name="l06272"></a><span class="lineno"> 6272</span>  <span class="comment">// the file upon entering/leaving this function. If the program</span></div><div class="line"><a name="l06273"></a><span class="lineno"> 6273</span>  <span class="comment">// somehow exits before this function has a chance to return, the</span></div><div class="line"><a name="l06274"></a><span class="lineno"> 6274</span>  <span class="comment">// premature-exit file will be left undeleted, causing a test runner</span></div><div class="line"><a name="l06275"></a><span class="lineno"> 6275</span>  <span class="comment">// that understands the premature-exit-file protocol to report the</span></div><div class="line"><a name="l06276"></a><span class="lineno"> 6276</span>  <span class="comment">// test as having failed.</span></div><div class="line"><a name="l06277"></a><span class="lineno"> 6277</span>  <span class="keyword">const</span> internal::ScopedPrematureExitFile premature_exit_file(</div><div class="line"><a name="l06278"></a><span class="lineno"> 6278</span>  in_death_test_child_process</div><div class="line"><a name="l06279"></a><span class="lineno"> 6279</span>  ? <span class="keyword">nullptr</span></div><div class="line"><a name="l06280"></a><span class="lineno"> 6280</span>  : <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a1d5e3da5a27eed25986859fa83cafe95">internal::posix::GetEnv</a>(<span class="stringliteral">"TEST_PREMATURE_EXIT_FILE"</span>));</div><div class="line"><a name="l06281"></a><span class="lineno"> 6281</span> </div><div class="line"><a name="l06282"></a><span class="lineno"> 6282</span>  <span class="comment">// Captures the value of GTEST_FLAG(catch_exceptions). This value will be</span></div><div class="line"><a name="l06283"></a><span class="lineno"> 6283</span>  <span class="comment">// used for the duration of the program.</span></div><div class="line"><a name="l06284"></a><span class="lineno"> 6284</span>  impl()->set_catch_exceptions(<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(catch_exceptions));</div><div class="line"><a name="l06285"></a><span class="lineno"> 6285</span> </div><div class="line"><a name="l06286"></a><span class="lineno"> 6286</span> <span class="preprocessor">#if GTEST_OS_WINDOWS</span></div><div class="line"><a name="l06287"></a><span class="lineno"> 6287</span>  <span class="comment">// Either the user wants Google Test to catch exceptions thrown by the</span></div><div class="line"><a name="l06288"></a><span class="lineno"> 6288</span>  <span class="comment">// tests or this is executing in the context of death test child</span></div><div class="line"><a name="l06289"></a><span class="lineno"> 6289</span>  <span class="comment">// process. In either case the user does not want to see pop-up dialogs</span></div><div class="line"><a name="l06290"></a><span class="lineno"> 6290</span>  <span class="comment">// about crashes - they are expected.</span></div><div class="line"><a name="l06291"></a><span class="lineno"> 6291</span>  <span class="keywordflow">if</span> (impl()->catch_exceptions() || in_death_test_child_process) {</div><div class="line"><a name="l06292"></a><span class="lineno"> 6292</span> <span class="preprocessor"># if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT</span></div><div class="line"><a name="l06293"></a><span class="lineno"> 6293</span>  <span class="comment">// SetErrorMode doesn't exist on CE.</span></div><div class="line"><a name="l06294"></a><span class="lineno"> 6294</span>  SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT |</div><div class="line"><a name="l06295"></a><span class="lineno"> 6295</span>  SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);</div><div class="line"><a name="l06296"></a><span class="lineno"> 6296</span> <span class="preprocessor"># endif // !GTEST_OS_WINDOWS_MOBILE</span></div><div class="line"><a name="l06297"></a><span class="lineno"> 6297</span> </div><div class="line"><a name="l06298"></a><span class="lineno"> 6298</span> <span class="preprocessor"># if (defined(_MSC_VER) || GTEST_OS_WINDOWS_MINGW) && !GTEST_OS_WINDOWS_MOBILE</span></div><div class="line"><a name="l06299"></a><span class="lineno"> 6299</span>  <span class="comment">// Death test children can be terminated with _abort(). On Windows,</span></div><div class="line"><a name="l06300"></a><span class="lineno"> 6300</span>  <span class="comment">// _abort() can show a dialog with a warning message. This forces the</span></div><div class="line"><a name="l06301"></a><span class="lineno"> 6301</span>  <span class="comment">// abort message to go to stderr instead.</span></div><div class="line"><a name="l06302"></a><span class="lineno"> 6302</span>  _set_error_mode(_OUT_TO_STDERR);</div><div class="line"><a name="l06303"></a><span class="lineno"> 6303</span> <span class="preprocessor"># endif</span></div><div class="line"><a name="l06304"></a><span class="lineno"> 6304</span> </div><div class="line"><a name="l06305"></a><span class="lineno"> 6305</span> <span class="preprocessor"># if defined(_MSC_VER) && !GTEST_OS_WINDOWS_MOBILE</span></div><div class="line"><a name="l06306"></a><span class="lineno"> 6306</span>  <span class="comment">// In the debug version, Visual Studio pops up a separate dialog</span></div><div class="line"><a name="l06307"></a><span class="lineno"> 6307</span>  <span class="comment">// offering a choice to debug the aborted program. We need to suppress</span></div><div class="line"><a name="l06308"></a><span class="lineno"> 6308</span>  <span class="comment">// this dialog or it will pop up for every EXPECT/ASSERT_DEATH statement</span></div><div class="line"><a name="l06309"></a><span class="lineno"> 6309</span>  <span class="comment">// executed. Google Test will notify the user of any unexpected</span></div><div class="line"><a name="l06310"></a><span class="lineno"> 6310</span>  <span class="comment">// failure via stderr.</span></div><div class="line"><a name="l06311"></a><span class="lineno"> 6311</span>  <span class="keywordflow">if</span> (!<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(break_on_failure))</div><div class="line"><a name="l06312"></a><span class="lineno"> 6312</span>  _set_abort_behavior(</div><div class="line"><a name="l06313"></a><span class="lineno"> 6313</span>  0x0, <span class="comment">// Clear the following flags:</span></div><div class="line"><a name="l06314"></a><span class="lineno"> 6314</span>  _WRITE_ABORT_MSG | _CALL_REPORTFAULT); <span class="comment">// pop-up window, core dump.</span></div><div class="line"><a name="l06315"></a><span class="lineno"> 6315</span> <span class="preprocessor"># endif</span></div><div class="line"><a name="l06316"></a><span class="lineno"> 6316</span>  }</div><div class="line"><a name="l06317"></a><span class="lineno"> 6317</span> <span class="preprocessor">#endif // GTEST_OS_WINDOWS</span></div><div class="line"><a name="l06318"></a><span class="lineno"> 6318</span> </div><div class="line"><a name="l06319"></a><span class="lineno"> 6319</span>  <span class="keywordflow">return</span> internal::HandleExceptionsInMethodIfSupported(</div><div class="line"><a name="l06320"></a><span class="lineno"> 6320</span>  impl(),</div><div class="line"><a name="l06321"></a><span class="lineno"> 6321</span>  &internal::UnitTestImpl::RunAllTests,</div><div class="line"><a name="l06322"></a><span class="lineno"> 6322</span>  <span class="stringliteral">"auxiliary test code (environments or event listeners)"</span>) ? 0 : 1;</div><div class="line"><a name="l06323"></a><span class="lineno"> 6323</span> }</div><div class="line"><a name="l06324"></a><span class="lineno"> 6324</span> </div><div class="line"><a name="l06325"></a><span class="lineno"> 6325</span> <span class="comment">// Returns the working directory when the first TEST() or TEST_F() was</span></div><div class="line"><a name="l06326"></a><span class="lineno"> 6326</span> <span class="comment">// executed.</span></div><div class="line"><a name="l06327"></a><span class="lineno"> 6327</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* UnitTest::original_working_dir()<span class="keyword"> const </span>{</div><div class="line"><a name="l06328"></a><span class="lineno"> 6328</span>  <span class="keywordflow">return</span> impl_->original_working_dir_.c_str();</div><div class="line"><a name="l06329"></a><span class="lineno"> 6329</span> }</div><div class="line"><a name="l06330"></a><span class="lineno"> 6330</span> </div><div class="line"><a name="l06331"></a><span class="lineno"> 6331</span> <span class="comment">// Returns the TestSuite object for the test that's currently running,</span></div><div class="line"><a name="l06332"></a><span class="lineno"> 6332</span> <span class="comment">// or NULL if no test is running.</span></div><div class="line"><a name="l06333"></a><span class="lineno"> 6333</span> <span class="keyword">const</span> TestSuite* UnitTest::current_test_suite() const</div><div class="line"><a name="l06334"></a><span class="lineno"> 6334</span>  <a class="code" href="gtest_8h.html#a69abff5a4efdd07bd5faebe3dd318d06">GTEST_LOCK_EXCLUDED_</a>(mutex_) {</div><div class="line"><a name="l06335"></a><span class="lineno"> 6335</span>  <a class="code" href="namespacetesting_1_1internal.html#a08b187c6cc4e28400aadf9a32fccc8de">internal::MutexLock</a> lock(&mutex_);</div><div class="line"><a name="l06336"></a><span class="lineno"> 6336</span>  <span class="keywordflow">return</span> impl_->current_test_suite();</div><div class="line"><a name="l06337"></a><span class="lineno"> 6337</span> }</div><div class="line"><a name="l06338"></a><span class="lineno"> 6338</span> </div><div class="line"><a name="l06339"></a><span class="lineno"> 6339</span> <span class="comment">// Legacy API is still available but deprecated</span></div><div class="line"><a name="l06340"></a><span class="lineno"> 6340</span> <span class="preprocessor">#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_</span></div><div class="line"><a name="l06341"></a><span class="lineno"> 6341</span> <span class="keyword">const</span> TestCase* UnitTest::current_test_case() const</div><div class="line"><a name="l06342"></a><span class="lineno"> 6342</span>  <a class="code" href="gtest_8h.html#a69abff5a4efdd07bd5faebe3dd318d06">GTEST_LOCK_EXCLUDED_</a>(mutex_) {</div><div class="line"><a name="l06343"></a><span class="lineno"> 6343</span>  <a class="code" href="namespacetesting_1_1internal.html#a08b187c6cc4e28400aadf9a32fccc8de">internal::MutexLock</a> lock(&mutex_);</div><div class="line"><a name="l06344"></a><span class="lineno"> 6344</span>  <span class="keywordflow">return</span> impl_->current_test_suite();</div><div class="line"><a name="l06345"></a><span class="lineno"> 6345</span> }</div><div class="line"><a name="l06346"></a><span class="lineno"> 6346</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l06347"></a><span class="lineno"> 6347</span> </div><div class="line"><a name="l06348"></a><span class="lineno"> 6348</span> <span class="comment">// Returns the TestInfo object for the test that's currently running,</span></div><div class="line"><a name="l06349"></a><span class="lineno"> 6349</span> <span class="comment">// or NULL if no test is running.</span></div><div class="line"><a name="l06350"></a><span class="lineno"> 6350</span> <span class="keyword">const</span> TestInfo* UnitTest::current_test_info() const</div><div class="line"><a name="l06351"></a><span class="lineno"> 6351</span>  <a class="code" href="gtest_8h.html#a69abff5a4efdd07bd5faebe3dd318d06">GTEST_LOCK_EXCLUDED_</a>(mutex_) {</div><div class="line"><a name="l06352"></a><span class="lineno"> 6352</span>  <a class="code" href="namespacetesting_1_1internal.html#a08b187c6cc4e28400aadf9a32fccc8de">internal::MutexLock</a> lock(&mutex_);</div><div class="line"><a name="l06353"></a><span class="lineno"> 6353</span>  <span class="keywordflow">return</span> impl_->current_test_info();</div><div class="line"><a name="l06354"></a><span class="lineno"> 6354</span> }</div><div class="line"><a name="l06355"></a><span class="lineno"> 6355</span> </div><div class="line"><a name="l06356"></a><span class="lineno"> 6356</span> <span class="comment">// Returns the random seed used at the start of the current test run.</span></div><div class="line"><a name="l06357"></a><span class="lineno"> 6357</span> <span class="keywordtype">int</span> UnitTest::random_seed()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> impl_->random_seed(); }</div><div class="line"><a name="l06358"></a><span class="lineno"> 6358</span> </div><div class="line"><a name="l06359"></a><span class="lineno"> 6359</span> <span class="comment">// Returns ParameterizedTestSuiteRegistry object used to keep track of</span></div><div class="line"><a name="l06360"></a><span class="lineno"> 6360</span> <span class="comment">// value-parameterized tests and instantiate and register them.</span></div><div class="line"><a name="l06361"></a><span class="lineno"> 6361</span> internal::ParameterizedTestSuiteRegistry&</div><div class="line"><a name="l06362"></a><span class="lineno"> 6362</span> UnitTest::parameterized_test_registry() <a class="code" href="gtest_8h.html#a69abff5a4efdd07bd5faebe3dd318d06">GTEST_LOCK_EXCLUDED_</a>(mutex_) {</div><div class="line"><a name="l06363"></a><span class="lineno"> 6363</span>  <span class="keywordflow">return</span> impl_->parameterized_test_registry();</div><div class="line"><a name="l06364"></a><span class="lineno"> 6364</span> }</div><div class="line"><a name="l06365"></a><span class="lineno"> 6365</span> </div><div class="line"><a name="l06366"></a><span class="lineno"> 6366</span> <span class="comment">// Creates an empty UnitTest.</span></div><div class="line"><a name="l06367"></a><span class="lineno"> 6367</span> UnitTest::UnitTest() {</div><div class="line"><a name="l06368"></a><span class="lineno"> 6368</span>  impl_ = <span class="keyword">new</span> internal::UnitTestImpl(<span class="keyword">this</span>);</div><div class="line"><a name="l06369"></a><span class="lineno"> 6369</span> }</div><div class="line"><a name="l06370"></a><span class="lineno"> 6370</span> </div><div class="line"><a name="l06371"></a><span class="lineno"> 6371</span> <span class="comment">// Destructor of UnitTest.</span></div><div class="line"><a name="l06372"></a><span class="lineno"> 6372</span> UnitTest::~UnitTest() {</div><div class="line"><a name="l06373"></a><span class="lineno"> 6373</span>  <span class="keyword">delete</span> impl_;</div><div class="line"><a name="l06374"></a><span class="lineno"> 6374</span> }</div><div class="line"><a name="l06375"></a><span class="lineno"> 6375</span> </div><div class="line"><a name="l06376"></a><span class="lineno"> 6376</span> <span class="comment">// Pushes a trace defined by SCOPED_TRACE() on to the per-thread</span></div><div class="line"><a name="l06377"></a><span class="lineno"> 6377</span> <span class="comment">// Google Test trace stack.</span></div><div class="line"><a name="l06378"></a><span class="lineno"> 6378</span> <span class="keywordtype">void</span> UnitTest::PushGTestTrace(<span class="keyword">const</span> internal::TraceInfo& trace)</div><div class="line"><a name="l06379"></a><span class="lineno"> 6379</span>  <a class="code" href="gtest_8h.html#a69abff5a4efdd07bd5faebe3dd318d06">GTEST_LOCK_EXCLUDED_</a>(mutex_) {</div><div class="line"><a name="l06380"></a><span class="lineno"> 6380</span>  <a class="code" href="namespacetesting_1_1internal.html#a08b187c6cc4e28400aadf9a32fccc8de">internal::MutexLock</a> lock(&mutex_);</div><div class="line"><a name="l06381"></a><span class="lineno"> 6381</span>  impl_->gtest_trace_stack().push_back(trace);</div><div class="line"><a name="l06382"></a><span class="lineno"> 6382</span> }</div><div class="line"><a name="l06383"></a><span class="lineno"> 6383</span> </div><div class="line"><a name="l06384"></a><span class="lineno"> 6384</span> <span class="comment">// Pops a trace from the per-thread Google Test trace stack.</span></div><div class="line"><a name="l06385"></a><span class="lineno"> 6385</span> <span class="keywordtype">void</span> UnitTest::PopGTestTrace()</div><div class="line"><a name="l06386"></a><span class="lineno"> 6386</span>  <a class="code" href="gtest_8h.html#a69abff5a4efdd07bd5faebe3dd318d06">GTEST_LOCK_EXCLUDED_</a>(mutex_) {</div><div class="line"><a name="l06387"></a><span class="lineno"> 6387</span>  <a class="code" href="namespacetesting_1_1internal.html#a08b187c6cc4e28400aadf9a32fccc8de">internal::MutexLock</a> lock(&mutex_);</div><div class="line"><a name="l06388"></a><span class="lineno"> 6388</span>  impl_->gtest_trace_stack().pop_back();</div><div class="line"><a name="l06389"></a><span class="lineno"> 6389</span> }</div><div class="line"><a name="l06390"></a><span class="lineno"> 6390</span> </div><div class="line"><a name="l06391"></a><span class="lineno"> 6391</span> <span class="keyword">namespace </span>internal {</div><div class="line"><a name="l06392"></a><span class="lineno"> 6392</span> </div><div class="line"><a name="l06393"></a><span class="lineno"> 6393</span> UnitTestImpl::UnitTestImpl(UnitTest* parent)</div><div class="line"><a name="l06394"></a><span class="lineno"> 6394</span>  : parent_(parent),</div><div class="line"><a name="l06395"></a><span class="lineno"> 6395</span>  <a class="code" href="gtest-all_8cc.html#a88f79832f9d045112a76e9da8611cc13">GTEST_DISABLE_MSC_WARNINGS_PUSH_</a>(4355 <span class="comment">/* using this in initializer */</span>)</div><div class="line"><a name="l06396"></a><span class="lineno"> 6396</span>  default_global_test_part_result_reporter_(this),</div><div class="line"><a name="l06397"></a><span class="lineno"> 6397</span>  default_per_thread_test_part_result_reporter_(this),</div><div class="line"><a name="l06398"></a><span class="lineno"> 6398</span>  <a class="code" href="gtest-all_8cc.html#a789f37f9c345c2032699c194a58623d9">GTEST_DISABLE_MSC_WARNINGS_POP_</a>() global_test_part_result_repoter_(</div><div class="line"><a name="l06399"></a><span class="lineno"> 6399</span>  &default_global_test_part_result_reporter_),</div><div class="line"><a name="l06400"></a><span class="lineno"> 6400</span>  per_thread_test_part_result_reporter_(</div><div class="line"><a name="l06401"></a><span class="lineno"> 6401</span>  &default_per_thread_test_part_result_reporter_),</div><div class="line"><a name="l06402"></a><span class="lineno"> 6402</span>  parameterized_test_registry_(),</div><div class="line"><a name="l06403"></a><span class="lineno"> 6403</span>  parameterized_tests_registered_(false),</div><div class="line"><a name="l06404"></a><span class="lineno"> 6404</span>  last_death_test_suite_(-1),</div><div class="line"><a name="l06405"></a><span class="lineno"> 6405</span>  current_test_suite_(nullptr),</div><div class="line"><a name="l06406"></a><span class="lineno"> 6406</span>  current_test_info_(nullptr),</div><div class="line"><a name="l06407"></a><span class="lineno"> 6407</span>  ad_hoc_test_result_(),</div><div class="line"><a name="l06408"></a><span class="lineno"> 6408</span>  os_stack_trace_getter_(nullptr),</div><div class="line"><a name="l06409"></a><span class="lineno"> 6409</span>  post_flag_parse_init_performed_(false),</div><div class="line"><a name="l06410"></a><span class="lineno"> 6410</span>  random_seed_(0), <span class="comment">// Will be overridden by the flag before first use.</span></div><div class="line"><a name="l06411"></a><span class="lineno"> 6411</span>  random_(0), <span class="comment">// Will be reseeded before first use.</span></div><div class="line"><a name="l06412"></a><span class="lineno"> 6412</span>  start_timestamp_(0),</div><div class="line"><a name="l06413"></a><span class="lineno"> 6413</span>  elapsed_time_(0),</div><div class="line"><a name="l06414"></a><span class="lineno"> 6414</span> #if GTEST_HAS_DEATH_TEST</div><div class="line"><a name="l06415"></a><span class="lineno"> 6415</span>  death_test_factory_(new DefaultDeathTestFactory),</div><div class="line"><a name="l06416"></a><span class="lineno"> 6416</span> #endif</div><div class="line"><a name="l06417"></a><span class="lineno"> 6417</span>  <span class="comment">// Will be overridden by the flag before first use.</span></div><div class="line"><a name="l06418"></a><span class="lineno"> 6418</span>  catch_exceptions_(false) {</div><div class="line"><a name="l06419"></a><span class="lineno"> 6419</span>  listeners()->SetDefaultResultPrinter(<span class="keyword">new</span> PrettyUnitTestResultPrinter);</div><div class="line"><a name="l06420"></a><span class="lineno"> 6420</span> }</div><div class="line"><a name="l06421"></a><span class="lineno"> 6421</span> </div><div class="line"><a name="l06422"></a><span class="lineno"> 6422</span> UnitTestImpl::~UnitTestImpl() {</div><div class="line"><a name="l06423"></a><span class="lineno"> 6423</span>  <span class="comment">// Deletes every TestSuite.</span></div><div class="line"><a name="l06424"></a><span class="lineno"> 6424</span>  ForEach(test_suites_, internal::Delete<TestSuite>);</div><div class="line"><a name="l06425"></a><span class="lineno"> 6425</span> </div><div class="line"><a name="l06426"></a><span class="lineno"> 6426</span>  <span class="comment">// Deletes every Environment.</span></div><div class="line"><a name="l06427"></a><span class="lineno"> 6427</span>  ForEach(environments_, internal::Delete<Environment>);</div><div class="line"><a name="l06428"></a><span class="lineno"> 6428</span> </div><div class="line"><a name="l06429"></a><span class="lineno"> 6429</span>  <span class="keyword">delete</span> os_stack_trace_getter_;</div><div class="line"><a name="l06430"></a><span class="lineno"> 6430</span> }</div><div class="line"><a name="l06431"></a><span class="lineno"> 6431</span> </div><div class="line"><a name="l06432"></a><span class="lineno"> 6432</span> <span class="comment">// Adds a TestProperty to the current TestResult object when invoked in a</span></div><div class="line"><a name="l06433"></a><span class="lineno"> 6433</span> <span class="comment">// context of a test, to current test suite's ad_hoc_test_result when invoke</span></div><div class="line"><a name="l06434"></a><span class="lineno"> 6434</span> <span class="comment">// from SetUpTestSuite/TearDownTestSuite, or to the global property set</span></div><div class="line"><a name="l06435"></a><span class="lineno"> 6435</span> <span class="comment">// otherwise. If the result already contains a property with the same key,</span></div><div class="line"><a name="l06436"></a><span class="lineno"> 6436</span> <span class="comment">// the value will be updated.</span></div><div class="line"><a name="l06437"></a><span class="lineno"> 6437</span> <span class="keywordtype">void</span> UnitTestImpl::RecordProperty(<span class="keyword">const</span> TestProperty& test_property) {</div><div class="line"><a name="l06438"></a><span class="lineno"> 6438</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> xml_element;</div><div class="line"><a name="l06439"></a><span class="lineno"> 6439</span>  TestResult* test_result; <span class="comment">// TestResult appropriate for property recording.</span></div><div class="line"><a name="l06440"></a><span class="lineno"> 6440</span> </div><div class="line"><a name="l06441"></a><span class="lineno"> 6441</span>  <span class="keywordflow">if</span> (current_test_info_ != <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l06442"></a><span class="lineno"> 6442</span>  xml_element = <span class="stringliteral">"testcase"</span>;</div><div class="line"><a name="l06443"></a><span class="lineno"> 6443</span>  test_result = &(current_test_info_->result_);</div><div class="line"><a name="l06444"></a><span class="lineno"> 6444</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (current_test_suite_ != <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l06445"></a><span class="lineno"> 6445</span>  xml_element = <span class="stringliteral">"testsuite"</span>;</div><div class="line"><a name="l06446"></a><span class="lineno"> 6446</span>  test_result = &(current_test_suite_->ad_hoc_test_result_);</div><div class="line"><a name="l06447"></a><span class="lineno"> 6447</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l06448"></a><span class="lineno"> 6448</span>  xml_element = <span class="stringliteral">"testsuites"</span>;</div><div class="line"><a name="l06449"></a><span class="lineno"> 6449</span>  test_result = &ad_hoc_test_result_;</div><div class="line"><a name="l06450"></a><span class="lineno"> 6450</span>  }</div><div class="line"><a name="l06451"></a><span class="lineno"> 6451</span>  test_result->RecordProperty(xml_element, test_property);</div><div class="line"><a name="l06452"></a><span class="lineno"> 6452</span> }</div><div class="line"><a name="l06453"></a><span class="lineno"> 6453</span> </div><div class="line"><a name="l06454"></a><span class="lineno"> 6454</span> <span class="preprocessor">#if GTEST_HAS_DEATH_TEST</span></div><div class="line"><a name="l06455"></a><span class="lineno"> 6455</span> <span class="comment">// Disables event forwarding if the control is currently in a death test</span></div><div class="line"><a name="l06456"></a><span class="lineno"> 6456</span> <span class="comment">// subprocess. Must not be called before InitGoogleTest.</span></div><div class="line"><a name="l06457"></a><span class="lineno"> 6457</span> <span class="keywordtype">void</span> UnitTestImpl::SuppressTestEventsIfInSubprocess() {</div><div class="line"><a name="l06458"></a><span class="lineno"> 6458</span>  <span class="keywordflow">if</span> (internal_run_death_test_flag_.get() != <span class="keyword">nullptr</span>)</div><div class="line"><a name="l06459"></a><span class="lineno"> 6459</span>  listeners()->SuppressEventForwarding();</div><div class="line"><a name="l06460"></a><span class="lineno"> 6460</span> }</div><div class="line"><a name="l06461"></a><span class="lineno"> 6461</span> <span class="preprocessor">#endif // GTEST_HAS_DEATH_TEST</span></div><div class="line"><a name="l06462"></a><span class="lineno"> 6462</span> </div><div class="line"><a name="l06463"></a><span class="lineno"> 6463</span> <span class="comment">// Initializes event listeners performing XML output as specified by</span></div><div class="line"><a name="l06464"></a><span class="lineno"> 6464</span> <span class="comment">// UnitTestOptions. Must not be called before InitGoogleTest.</span></div><div class="line"><a name="l06465"></a><span class="lineno"> 6465</span> <span class="keywordtype">void</span> UnitTestImpl::ConfigureXmlOutput() {</div><div class="line"><a name="l06466"></a><span class="lineno"> 6466</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& output_format = UnitTestOptions::GetOutputFormat();</div><div class="line"><a name="l06467"></a><span class="lineno"> 6467</span>  <span class="keywordflow">if</span> (output_format == <span class="stringliteral">"xml"</span>) {</div><div class="line"><a name="l06468"></a><span class="lineno"> 6468</span>  listeners()->SetDefaultXmlGenerator(<span class="keyword">new</span> XmlUnitTestResultPrinter(</div><div class="line"><a name="l06469"></a><span class="lineno"> 6469</span>  UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));</div><div class="line"><a name="l06470"></a><span class="lineno"> 6470</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (output_format == <span class="stringliteral">"json"</span>) {</div><div class="line"><a name="l06471"></a><span class="lineno"> 6471</span>  listeners()->SetDefaultXmlGenerator(<span class="keyword">new</span> JsonUnitTestResultPrinter(</div><div class="line"><a name="l06472"></a><span class="lineno"> 6472</span>  UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));</div><div class="line"><a name="l06473"></a><span class="lineno"> 6473</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (output_format != <span class="stringliteral">""</span>) {</div><div class="line"><a name="l06474"></a><span class="lineno"> 6474</span>  <a class="code" href="gtest_8h.html#a8ef4cb4c465db8c15464aecc6d9510ef">GTEST_LOG_</a>(WARNING) << <span class="stringliteral">"WARNING: unrecognized output format \""</span></div><div class="line"><a name="l06475"></a><span class="lineno"> 6475</span>  << output_format << <span class="stringliteral">"\" ignored."</span>;</div><div class="line"><a name="l06476"></a><span class="lineno"> 6476</span>  }</div><div class="line"><a name="l06477"></a><span class="lineno"> 6477</span> }</div><div class="line"><a name="l06478"></a><span class="lineno"> 6478</span> </div><div class="line"><a name="l06479"></a><span class="lineno"> 6479</span> <span class="preprocessor">#if GTEST_CAN_STREAM_RESULTS_</span></div><div class="line"><a name="l06480"></a><span class="lineno"> 6480</span> <span class="comment">// Initializes event listeners for streaming test results in string form.</span></div><div class="line"><a name="l06481"></a><span class="lineno"> 6481</span> <span class="comment">// Must not be called before InitGoogleTest.</span></div><div class="line"><a name="l06482"></a><span class="lineno"> 6482</span> <span class="keywordtype">void</span> UnitTestImpl::ConfigureStreamingOutput() {</div><div class="line"><a name="l06483"></a><span class="lineno"> 6483</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& target = <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(stream_result_to);</div><div class="line"><a name="l06484"></a><span class="lineno"> 6484</span>  <span class="keywordflow">if</span> (!target.empty()) {</div><div class="line"><a name="l06485"></a><span class="lineno"> 6485</span>  <span class="keyword">const</span> <span class="keywordtype">size_t</span> pos = target.find(<span class="charliteral">':'</span>);</div><div class="line"><a name="l06486"></a><span class="lineno"> 6486</span>  <span class="keywordflow">if</span> (pos != std::string::npos) {</div><div class="line"><a name="l06487"></a><span class="lineno"> 6487</span>  listeners()->Append(<span class="keyword">new</span> StreamingListener(target.substr(0, pos),</div><div class="line"><a name="l06488"></a><span class="lineno"> 6488</span>  target.substr(pos+1)));</div><div class="line"><a name="l06489"></a><span class="lineno"> 6489</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l06490"></a><span class="lineno"> 6490</span>  <a class="code" href="gtest_8h.html#a8ef4cb4c465db8c15464aecc6d9510ef">GTEST_LOG_</a>(WARNING) << <span class="stringliteral">"unrecognized streaming target \""</span> << target</div><div class="line"><a name="l06491"></a><span class="lineno"> 6491</span>  << <span class="stringliteral">"\" ignored."</span>;</div><div class="line"><a name="l06492"></a><span class="lineno"> 6492</span>  }</div><div class="line"><a name="l06493"></a><span class="lineno"> 6493</span>  }</div><div class="line"><a name="l06494"></a><span class="lineno"> 6494</span> }</div><div class="line"><a name="l06495"></a><span class="lineno"> 6495</span> <span class="preprocessor">#endif // GTEST_CAN_STREAM_RESULTS_</span></div><div class="line"><a name="l06496"></a><span class="lineno"> 6496</span> </div><div class="line"><a name="l06497"></a><span class="lineno"> 6497</span> <span class="comment">// Performs initialization dependent upon flag values obtained in</span></div><div class="line"><a name="l06498"></a><span class="lineno"> 6498</span> <span class="comment">// ParseGoogleTestFlagsOnly. Is called from InitGoogleTest after the call to</span></div><div class="line"><a name="l06499"></a><span class="lineno"> 6499</span> <span class="comment">// ParseGoogleTestFlagsOnly. In case a user neglects to call InitGoogleTest</span></div><div class="line"><a name="l06500"></a><span class="lineno"> 6500</span> <span class="comment">// this function is also called from RunAllTests. Since this function can be</span></div><div class="line"><a name="l06501"></a><span class="lineno"> 6501</span> <span class="comment">// called more than once, it has to be idempotent.</span></div><div class="line"><a name="l06502"></a><span class="lineno"> 6502</span> <span class="keywordtype">void</span> UnitTestImpl::PostFlagParsingInit() {</div><div class="line"><a name="l06503"></a><span class="lineno"> 6503</span>  <span class="comment">// Ensures that this function does not execute more than once.</span></div><div class="line"><a name="l06504"></a><span class="lineno"> 6504</span>  <span class="keywordflow">if</span> (!post_flag_parse_init_performed_) {</div><div class="line"><a name="l06505"></a><span class="lineno"> 6505</span>  post_flag_parse_init_performed_ = <span class="keyword">true</span>;</div><div class="line"><a name="l06506"></a><span class="lineno"> 6506</span> </div><div class="line"><a name="l06507"></a><span class="lineno"> 6507</span> <span class="preprocessor">#if defined(GTEST_CUSTOM_TEST_EVENT_LISTENER_)</span></div><div class="line"><a name="l06508"></a><span class="lineno"> 6508</span>  <span class="comment">// Register to send notifications about key process state changes.</span></div><div class="line"><a name="l06509"></a><span class="lineno"> 6509</span>  listeners()->Append(<span class="keyword">new</span> GTEST_CUSTOM_TEST_EVENT_LISTENER_());</div><div class="line"><a name="l06510"></a><span class="lineno"> 6510</span> <span class="preprocessor">#endif // defined(GTEST_CUSTOM_TEST_EVENT_LISTENER_)</span></div><div class="line"><a name="l06511"></a><span class="lineno"> 6511</span> </div><div class="line"><a name="l06512"></a><span class="lineno"> 6512</span> <span class="preprocessor">#if GTEST_HAS_DEATH_TEST</span></div><div class="line"><a name="l06513"></a><span class="lineno"> 6513</span>  InitDeathTestSubprocessControlInfo();</div><div class="line"><a name="l06514"></a><span class="lineno"> 6514</span>  SuppressTestEventsIfInSubprocess();</div><div class="line"><a name="l06515"></a><span class="lineno"> 6515</span> <span class="preprocessor">#endif // GTEST_HAS_DEATH_TEST</span></div><div class="line"><a name="l06516"></a><span class="lineno"> 6516</span> </div><div class="line"><a name="l06517"></a><span class="lineno"> 6517</span>  <span class="comment">// Registers parameterized tests. This makes parameterized tests</span></div><div class="line"><a name="l06518"></a><span class="lineno"> 6518</span>  <span class="comment">// available to the UnitTest reflection API without running</span></div><div class="line"><a name="l06519"></a><span class="lineno"> 6519</span>  <span class="comment">// RUN_ALL_TESTS.</span></div><div class="line"><a name="l06520"></a><span class="lineno"> 6520</span>  RegisterParameterizedTests();</div><div class="line"><a name="l06521"></a><span class="lineno"> 6521</span> </div><div class="line"><a name="l06522"></a><span class="lineno"> 6522</span>  <span class="comment">// Configures listeners for XML output. This makes it possible for users</span></div><div class="line"><a name="l06523"></a><span class="lineno"> 6523</span>  <span class="comment">// to shut down the default XML output before invoking RUN_ALL_TESTS.</span></div><div class="line"><a name="l06524"></a><span class="lineno"> 6524</span>  ConfigureXmlOutput();</div><div class="line"><a name="l06525"></a><span class="lineno"> 6525</span> </div><div class="line"><a name="l06526"></a><span class="lineno"> 6526</span> <span class="preprocessor">#if GTEST_CAN_STREAM_RESULTS_</span></div><div class="line"><a name="l06527"></a><span class="lineno"> 6527</span>  <span class="comment">// Configures listeners for streaming test results to the specified server.</span></div><div class="line"><a name="l06528"></a><span class="lineno"> 6528</span>  ConfigureStreamingOutput();</div><div class="line"><a name="l06529"></a><span class="lineno"> 6529</span> <span class="preprocessor">#endif // GTEST_CAN_STREAM_RESULTS_</span></div><div class="line"><a name="l06530"></a><span class="lineno"> 6530</span> </div><div class="line"><a name="l06531"></a><span class="lineno"> 6531</span> <span class="preprocessor">#if GTEST_HAS_ABSL</span></div><div class="line"><a name="l06532"></a><span class="lineno"> 6532</span>  <span class="keywordflow">if</span> (<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(install_failure_signal_handler)) {</div><div class="line"><a name="l06533"></a><span class="lineno"> 6533</span>  absl::FailureSignalHandlerOptions options;</div><div class="line"><a name="l06534"></a><span class="lineno"> 6534</span>  absl::InstallFailureSignalHandler(options);</div><div class="line"><a name="l06535"></a><span class="lineno"> 6535</span>  }</div><div class="line"><a name="l06536"></a><span class="lineno"> 6536</span> <span class="preprocessor">#endif // GTEST_HAS_ABSL</span></div><div class="line"><a name="l06537"></a><span class="lineno"> 6537</span>  }</div><div class="line"><a name="l06538"></a><span class="lineno"> 6538</span> }</div><div class="line"><a name="l06539"></a><span class="lineno"> 6539</span> </div><div class="line"><a name="l06540"></a><span class="lineno"> 6540</span> <span class="comment">// A predicate that checks the name of a TestSuite against a known</span></div><div class="line"><a name="l06541"></a><span class="lineno"> 6541</span> <span class="comment">// value.</span></div><div class="line"><a name="l06542"></a><span class="lineno"> 6542</span> <span class="comment">//</span></div><div class="line"><a name="l06543"></a><span class="lineno"> 6543</span> <span class="comment">// This is used for implementation of the UnitTest class only. We put</span></div><div class="line"><a name="l06544"></a><span class="lineno"> 6544</span> <span class="comment">// it in the anonymous namespace to prevent polluting the outer</span></div><div class="line"><a name="l06545"></a><span class="lineno"> 6545</span> <span class="comment">// namespace.</span></div><div class="line"><a name="l06546"></a><span class="lineno"> 6546</span> <span class="comment">//</span></div><div class="line"><a name="l06547"></a><span class="lineno"> 6547</span> <span class="comment">// TestSuiteNameIs is copyable.</span></div><div class="line"><a name="l06548"></a><span class="lineno"> 6548</span> <span class="keyword">class </span>TestSuiteNameIs {</div><div class="line"><a name="l06549"></a><span class="lineno"> 6549</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l06550"></a><span class="lineno"> 6550</span>  <span class="comment">// Constructor.</span></div><div class="line"><a name="l06551"></a><span class="lineno"> 6551</span>  <span class="keyword">explicit</span> TestSuiteNameIs(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& name) : name_(name) {}</div><div class="line"><a name="l06552"></a><span class="lineno"> 6552</span> </div><div class="line"><a name="l06553"></a><span class="lineno"> 6553</span>  <span class="comment">// Returns true iff the name of test_suite matches name_.</span></div><div class="line"><a name="l06554"></a><span class="lineno"> 6554</span>  <span class="keywordtype">bool</span> operator()(<span class="keyword">const</span> TestSuite* test_suite)<span class="keyword"> const </span>{</div><div class="line"><a name="l06555"></a><span class="lineno"> 6555</span>  <span class="keywordflow">return</span> test_suite != <span class="keyword">nullptr</span> &&</div><div class="line"><a name="l06556"></a><span class="lineno"> 6556</span>  strcmp(test_suite->name(), name_.c_str()) == 0;</div><div class="line"><a name="l06557"></a><span class="lineno"> 6557</span>  }</div><div class="line"><a name="l06558"></a><span class="lineno"> 6558</span> </div><div class="line"><a name="l06559"></a><span class="lineno"> 6559</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l06560"></a><span class="lineno"> 6560</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> name_;</div><div class="line"><a name="l06561"></a><span class="lineno"> 6561</span> };</div><div class="line"><a name="l06562"></a><span class="lineno"> 6562</span> </div><div class="line"><a name="l06563"></a><span class="lineno"> 6563</span> <span class="comment">// Finds and returns a TestSuite with the given name. If one doesn't</span></div><div class="line"><a name="l06564"></a><span class="lineno"> 6564</span> <span class="comment">// exist, creates one and returns it. It's the CALLER'S</span></div><div class="line"><a name="l06565"></a><span class="lineno"> 6565</span> <span class="comment">// RESPONSIBILITY to ensure that this function is only called WHEN THE</span></div><div class="line"><a name="l06566"></a><span class="lineno"> 6566</span> <span class="comment">// TESTS ARE NOT SHUFFLED.</span></div><div class="line"><a name="l06567"></a><span class="lineno"> 6567</span> <span class="comment">//</span></div><div class="line"><a name="l06568"></a><span class="lineno"> 6568</span> <span class="comment">// Arguments:</span></div><div class="line"><a name="l06569"></a><span class="lineno"> 6569</span> <span class="comment">//</span></div><div class="line"><a name="l06570"></a><span class="lineno"> 6570</span> <span class="comment">// test_suite_name: name of the test suite</span></div><div class="line"><a name="l06571"></a><span class="lineno"> 6571</span> <span class="comment">// type_param: the name of the test suite's type parameter, or NULL if</span></div><div class="line"><a name="l06572"></a><span class="lineno"> 6572</span> <span class="comment">// this is not a typed or a type-parameterized test suite.</span></div><div class="line"><a name="l06573"></a><span class="lineno"> 6573</span> <span class="comment">// set_up_tc: pointer to the function that sets up the test suite</span></div><div class="line"><a name="l06574"></a><span class="lineno"> 6574</span> <span class="comment">// tear_down_tc: pointer to the function that tears down the test suite</span></div><div class="line"><a name="l06575"></a><span class="lineno"> 6575</span> TestSuite* UnitTestImpl::GetTestSuite(</div><div class="line"><a name="l06576"></a><span class="lineno"> 6576</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* test_suite_name, <span class="keyword">const</span> <span class="keywordtype">char</span>* type_param,</div><div class="line"><a name="l06577"></a><span class="lineno"> 6577</span>  <a class="code" href="namespacetesting_1_1internal.html#a83e4e0732ac6a9dcfe6ee299dc1b9fa2">internal::SetUpTestSuiteFunc</a> set_up_tc,</div><div class="line"><a name="l06578"></a><span class="lineno"> 6578</span>  <a class="code" href="namespacetesting_1_1internal.html#a8257a87aa42cebaa54b0c48a6ae657a5">internal::TearDownTestSuiteFunc</a> tear_down_tc) {</div><div class="line"><a name="l06579"></a><span class="lineno"> 6579</span>  <span class="comment">// Can we find a TestSuite with the given name?</span></div><div class="line"><a name="l06580"></a><span class="lineno"> 6580</span>  <span class="keyword">const</span> <span class="keyword">auto</span> test_suite =</div><div class="line"><a name="l06581"></a><span class="lineno"> 6581</span>  <a class="code" href="namespaceutl_1_1meta.html#aacf124929c0cbb3b29d34679bff50a96">std::find_if</a>(test_suites_.rbegin(), test_suites_.rend(),</div><div class="line"><a name="l06582"></a><span class="lineno"> 6582</span>  TestSuiteNameIs(test_suite_name));</div><div class="line"><a name="l06583"></a><span class="lineno"> 6583</span> </div><div class="line"><a name="l06584"></a><span class="lineno"> 6584</span>  <span class="keywordflow">if</span> (test_suite != test_suites_.rend()) <span class="keywordflow">return</span> *test_suite;</div><div class="line"><a name="l06585"></a><span class="lineno"> 6585</span> </div><div class="line"><a name="l06586"></a><span class="lineno"> 6586</span>  <span class="comment">// No. Let's create one.</span></div><div class="line"><a name="l06587"></a><span class="lineno"> 6587</span>  <span class="keyword">auto</span>* <span class="keyword">const</span> new_test_suite =</div><div class="line"><a name="l06588"></a><span class="lineno"> 6588</span>  <span class="keyword">new</span> TestSuite(test_suite_name, type_param, set_up_tc, tear_down_tc);</div><div class="line"><a name="l06589"></a><span class="lineno"> 6589</span> </div><div class="line"><a name="l06590"></a><span class="lineno"> 6590</span>  <span class="comment">// Is this a death test suite?</span></div><div class="line"><a name="l06591"></a><span class="lineno"> 6591</span>  <span class="keywordflow">if</span> (internal::UnitTestOptions::MatchesFilter(test_suite_name,</div><div class="line"><a name="l06592"></a><span class="lineno"> 6592</span>  kDeathTestSuiteFilter)) {</div><div class="line"><a name="l06593"></a><span class="lineno"> 6593</span>  <span class="comment">// Yes. Inserts the test suite after the last death test suite</span></div><div class="line"><a name="l06594"></a><span class="lineno"> 6594</span>  <span class="comment">// defined so far. This only works when the test suites haven't</span></div><div class="line"><a name="l06595"></a><span class="lineno"> 6595</span>  <span class="comment">// been shuffled. Otherwise we may end up running a death test</span></div><div class="line"><a name="l06596"></a><span class="lineno"> 6596</span>  <span class="comment">// after a non-death test.</span></div><div class="line"><a name="l06597"></a><span class="lineno"> 6597</span>  ++last_death_test_suite_;</div><div class="line"><a name="l06598"></a><span class="lineno"> 6598</span>  test_suites_.insert(test_suites_.begin() + last_death_test_suite_,</div><div class="line"><a name="l06599"></a><span class="lineno"> 6599</span>  new_test_suite);</div><div class="line"><a name="l06600"></a><span class="lineno"> 6600</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l06601"></a><span class="lineno"> 6601</span>  <span class="comment">// No. Appends to the end of the list.</span></div><div class="line"><a name="l06602"></a><span class="lineno"> 6602</span>  test_suites_.push_back(new_test_suite);</div><div class="line"><a name="l06603"></a><span class="lineno"> 6603</span>  }</div><div class="line"><a name="l06604"></a><span class="lineno"> 6604</span> </div><div class="line"><a name="l06605"></a><span class="lineno"> 6605</span>  test_suite_indices_.push_back(static_cast<int>(test_suite_indices_.size()));</div><div class="line"><a name="l06606"></a><span class="lineno"> 6606</span>  <span class="keywordflow">return</span> new_test_suite;</div><div class="line"><a name="l06607"></a><span class="lineno"> 6607</span> }</div><div class="line"><a name="l06608"></a><span class="lineno"> 6608</span> </div><div class="line"><a name="l06609"></a><span class="lineno"> 6609</span> <span class="comment">// Helpers for setting up / tearing down the given environment. They</span></div><div class="line"><a name="l06610"></a><span class="lineno"> 6610</span> <span class="comment">// are for use in the ForEach() function.</span></div><div class="line"><a name="l06611"></a><span class="lineno"> 6611</span> <span class="keyword">static</span> <span class="keywordtype">void</span> SetUpEnvironment(Environment* env) { env->SetUp(); }</div><div class="line"><a name="l06612"></a><span class="lineno"> 6612</span> <span class="keyword">static</span> <span class="keywordtype">void</span> TearDownEnvironment(Environment* env) { env->TearDown(); }</div><div class="line"><a name="l06613"></a><span class="lineno"> 6613</span> </div><div class="line"><a name="l06614"></a><span class="lineno"> 6614</span> <span class="comment">// Runs all tests in this UnitTest object, prints the result, and</span></div><div class="line"><a name="l06615"></a><span class="lineno"> 6615</span> <span class="comment">// returns true if all tests are successful. If any exception is</span></div><div class="line"><a name="l06616"></a><span class="lineno"> 6616</span> <span class="comment">// thrown during a test, the test is considered to be failed, but the</span></div><div class="line"><a name="l06617"></a><span class="lineno"> 6617</span> <span class="comment">// rest of the tests will still be run.</span></div><div class="line"><a name="l06618"></a><span class="lineno"> 6618</span> <span class="comment">//</span></div><div class="line"><a name="l06619"></a><span class="lineno"> 6619</span> <span class="comment">// When parameterized tests are enabled, it expands and registers</span></div><div class="line"><a name="l06620"></a><span class="lineno"> 6620</span> <span class="comment">// parameterized tests first in RegisterParameterizedTests().</span></div><div class="line"><a name="l06621"></a><span class="lineno"> 6621</span> <span class="comment">// All other functions called from RunAllTests() may safely assume that</span></div><div class="line"><a name="l06622"></a><span class="lineno"> 6622</span> <span class="comment">// parameterized tests are ready to be counted and run.</span></div><div class="line"><a name="l06623"></a><span class="lineno"> 6623</span> <span class="keywordtype">bool</span> UnitTestImpl::RunAllTests() {</div><div class="line"><a name="l06624"></a><span class="lineno"> 6624</span>  <span class="comment">// True iff Google Test is initialized before RUN_ALL_TESTS() is called.</span></div><div class="line"><a name="l06625"></a><span class="lineno"> 6625</span>  <span class="keyword">const</span> <span class="keywordtype">bool</span> gtest_is_initialized_before_run_all_tests = GTestIsInitialized();</div><div class="line"><a name="l06626"></a><span class="lineno"> 6626</span> </div><div class="line"><a name="l06627"></a><span class="lineno"> 6627</span>  <span class="comment">// Do not run any test if the --help flag was specified.</span></div><div class="line"><a name="l06628"></a><span class="lineno"> 6628</span>  <span class="keywordflow">if</span> (g_help_flag)</div><div class="line"><a name="l06629"></a><span class="lineno"> 6629</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l06630"></a><span class="lineno"> 6630</span> </div><div class="line"><a name="l06631"></a><span class="lineno"> 6631</span>  <span class="comment">// Repeats the call to the post-flag parsing initialization in case the</span></div><div class="line"><a name="l06632"></a><span class="lineno"> 6632</span>  <span class="comment">// user didn't call InitGoogleTest.</span></div><div class="line"><a name="l06633"></a><span class="lineno"> 6633</span>  PostFlagParsingInit();</div><div class="line"><a name="l06634"></a><span class="lineno"> 6634</span> </div><div class="line"><a name="l06635"></a><span class="lineno"> 6635</span>  <span class="comment">// Even if sharding is not on, test runners may want to use the</span></div><div class="line"><a name="l06636"></a><span class="lineno"> 6636</span>  <span class="comment">// GTEST_SHARD_STATUS_FILE to query whether the test supports the sharding</span></div><div class="line"><a name="l06637"></a><span class="lineno"> 6637</span>  <span class="comment">// protocol.</span></div><div class="line"><a name="l06638"></a><span class="lineno"> 6638</span>  internal::WriteToShardStatusFileIfNeeded();</div><div class="line"><a name="l06639"></a><span class="lineno"> 6639</span> </div><div class="line"><a name="l06640"></a><span class="lineno"> 6640</span>  <span class="comment">// True iff we are in a subprocess for running a thread-safe-style</span></div><div class="line"><a name="l06641"></a><span class="lineno"> 6641</span>  <span class="comment">// death test.</span></div><div class="line"><a name="l06642"></a><span class="lineno"> 6642</span>  <span class="keywordtype">bool</span> in_subprocess_for_death_test = <span class="keyword">false</span>;</div><div class="line"><a name="l06643"></a><span class="lineno"> 6643</span> </div><div class="line"><a name="l06644"></a><span class="lineno"> 6644</span> <span class="preprocessor">#if GTEST_HAS_DEATH_TEST</span></div><div class="line"><a name="l06645"></a><span class="lineno"> 6645</span>  in_subprocess_for_death_test =</div><div class="line"><a name="l06646"></a><span class="lineno"> 6646</span>  (internal_run_death_test_flag_.get() != <span class="keyword">nullptr</span>);</div><div class="line"><a name="l06647"></a><span class="lineno"> 6647</span> <span class="preprocessor"># if defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_)</span></div><div class="line"><a name="l06648"></a><span class="lineno"> 6648</span>  <span class="keywordflow">if</span> (in_subprocess_for_death_test) {</div><div class="line"><a name="l06649"></a><span class="lineno"> 6649</span>  GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_();</div><div class="line"><a name="l06650"></a><span class="lineno"> 6650</span>  }</div><div class="line"><a name="l06651"></a><span class="lineno"> 6651</span> <span class="preprocessor"># endif // defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_)</span></div><div class="line"><a name="l06652"></a><span class="lineno"> 6652</span> <span class="preprocessor">#endif // GTEST_HAS_DEATH_TEST</span></div><div class="line"><a name="l06653"></a><span class="lineno"> 6653</span> </div><div class="line"><a name="l06654"></a><span class="lineno"> 6654</span>  <span class="keyword">const</span> <span class="keywordtype">bool</span> should_shard = ShouldShard(kTestTotalShards, kTestShardIndex,</div><div class="line"><a name="l06655"></a><span class="lineno"> 6655</span>  in_subprocess_for_death_test);</div><div class="line"><a name="l06656"></a><span class="lineno"> 6656</span> </div><div class="line"><a name="l06657"></a><span class="lineno"> 6657</span>  <span class="comment">// Compares the full test names with the filter to decide which</span></div><div class="line"><a name="l06658"></a><span class="lineno"> 6658</span>  <span class="comment">// tests to run.</span></div><div class="line"><a name="l06659"></a><span class="lineno"> 6659</span>  <span class="keyword">const</span> <span class="keywordtype">bool</span> has_tests_to_run = FilterTests(should_shard</div><div class="line"><a name="l06660"></a><span class="lineno"> 6660</span>  ? HONOR_SHARDING_PROTOCOL</div><div class="line"><a name="l06661"></a><span class="lineno"> 6661</span>  : IGNORE_SHARDING_PROTOCOL) > 0;</div><div class="line"><a name="l06662"></a><span class="lineno"> 6662</span> </div><div class="line"><a name="l06663"></a><span class="lineno"> 6663</span>  <span class="comment">// Lists the tests and exits if the --gtest_list_tests flag was specified.</span></div><div class="line"><a name="l06664"></a><span class="lineno"> 6664</span>  <span class="keywordflow">if</span> (<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(list_tests)) {</div><div class="line"><a name="l06665"></a><span class="lineno"> 6665</span>  <span class="comment">// This must be called *after* FilterTests() has been called.</span></div><div class="line"><a name="l06666"></a><span class="lineno"> 6666</span>  ListTestsMatchingFilter();</div><div class="line"><a name="l06667"></a><span class="lineno"> 6667</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l06668"></a><span class="lineno"> 6668</span>  }</div><div class="line"><a name="l06669"></a><span class="lineno"> 6669</span> </div><div class="line"><a name="l06670"></a><span class="lineno"> 6670</span>  random_seed_ = <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(shuffle) ?</div><div class="line"><a name="l06671"></a><span class="lineno"> 6671</span>  GetRandomSeedFromFlag(<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(random_seed)) : 0;</div><div class="line"><a name="l06672"></a><span class="lineno"> 6672</span> </div><div class="line"><a name="l06673"></a><span class="lineno"> 6673</span>  <span class="comment">// True iff at least one test has failed.</span></div><div class="line"><a name="l06674"></a><span class="lineno"> 6674</span>  <span class="keywordtype">bool</span> failed = <span class="keyword">false</span>;</div><div class="line"><a name="l06675"></a><span class="lineno"> 6675</span> </div><div class="line"><a name="l06676"></a><span class="lineno"> 6676</span>  TestEventListener* repeater = listeners()->repeater();</div><div class="line"><a name="l06677"></a><span class="lineno"> 6677</span> </div><div class="line"><a name="l06678"></a><span class="lineno"> 6678</span>  start_timestamp_ = GetTimeInMillis();</div><div class="line"><a name="l06679"></a><span class="lineno"> 6679</span>  repeater->OnTestProgramStart(*parent_);</div><div class="line"><a name="l06680"></a><span class="lineno"> 6680</span> </div><div class="line"><a name="l06681"></a><span class="lineno"> 6681</span>  <span class="comment">// How many times to repeat the tests? We don't want to repeat them</span></div><div class="line"><a name="l06682"></a><span class="lineno"> 6682</span>  <span class="comment">// when we are inside the subprocess of a death test.</span></div><div class="line"><a name="l06683"></a><span class="lineno"> 6683</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="namespaceutl_1_1meta.html#aa013c45afb59b5c132a72be54ba145fb">repeat</a> = in_subprocess_for_death_test ? 1 : <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(<a class="code" href="namespaceutl_1_1meta.html#aa013c45afb59b5c132a72be54ba145fb">repeat</a>);</div><div class="line"><a name="l06684"></a><span class="lineno"> 6684</span>  <span class="comment">// Repeats forever if the repeat count is negative.</span></div><div class="line"><a name="l06685"></a><span class="lineno"> 6685</span>  <span class="keyword">const</span> <span class="keywordtype">bool</span> forever = <a class="code" href="namespaceutl_1_1meta.html#aa013c45afb59b5c132a72be54ba145fb">repeat</a> < 0;</div><div class="line"><a name="l06686"></a><span class="lineno"> 6686</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; forever || i != <a class="code" href="namespaceutl_1_1meta.html#aa013c45afb59b5c132a72be54ba145fb">repeat</a>; i++) {</div><div class="line"><a name="l06687"></a><span class="lineno"> 6687</span>  <span class="comment">// We want to preserve failures generated by ad-hoc test</span></div><div class="line"><a name="l06688"></a><span class="lineno"> 6688</span>  <span class="comment">// assertions executed before RUN_ALL_TESTS().</span></div><div class="line"><a name="l06689"></a><span class="lineno"> 6689</span>  ClearNonAdHocTestResult();</div><div class="line"><a name="l06690"></a><span class="lineno"> 6690</span> </div><div class="line"><a name="l06691"></a><span class="lineno"> 6691</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a66a845df404b38fe85c5e14a069f255a">TimeInMillis</a> start = GetTimeInMillis();</div><div class="line"><a name="l06692"></a><span class="lineno"> 6692</span> </div><div class="line"><a name="l06693"></a><span class="lineno"> 6693</span>  <span class="comment">// Shuffles test suites and tests if requested.</span></div><div class="line"><a name="l06694"></a><span class="lineno"> 6694</span>  <span class="keywordflow">if</span> (has_tests_to_run && <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(shuffle)) {</div><div class="line"><a name="l06695"></a><span class="lineno"> 6695</span>  random()->Reseed(random_seed_);</div><div class="line"><a name="l06696"></a><span class="lineno"> 6696</span>  <span class="comment">// This should be done before calling OnTestIterationStart(),</span></div><div class="line"><a name="l06697"></a><span class="lineno"> 6697</span>  <span class="comment">// such that a test event listener can see the actual test order</span></div><div class="line"><a name="l06698"></a><span class="lineno"> 6698</span>  <span class="comment">// in the event.</span></div><div class="line"><a name="l06699"></a><span class="lineno"> 6699</span>  ShuffleTests();</div><div class="line"><a name="l06700"></a><span class="lineno"> 6700</span>  }</div><div class="line"><a name="l06701"></a><span class="lineno"> 6701</span> </div><div class="line"><a name="l06702"></a><span class="lineno"> 6702</span>  <span class="comment">// Tells the unit test event listeners that the tests are about to start.</span></div><div class="line"><a name="l06703"></a><span class="lineno"> 6703</span>  repeater->OnTestIterationStart(*parent_, i);</div><div class="line"><a name="l06704"></a><span class="lineno"> 6704</span> </div><div class="line"><a name="l06705"></a><span class="lineno"> 6705</span>  <span class="comment">// Runs each test suite if there is at least one test to run.</span></div><div class="line"><a name="l06706"></a><span class="lineno"> 6706</span>  <span class="keywordflow">if</span> (has_tests_to_run) {</div><div class="line"><a name="l06707"></a><span class="lineno"> 6707</span>  <span class="comment">// Sets up all environments beforehand.</span></div><div class="line"><a name="l06708"></a><span class="lineno"> 6708</span>  repeater->OnEnvironmentsSetUpStart(*parent_);</div><div class="line"><a name="l06709"></a><span class="lineno"> 6709</span>  ForEach(environments_, SetUpEnvironment);</div><div class="line"><a name="l06710"></a><span class="lineno"> 6710</span>  repeater->OnEnvironmentsSetUpEnd(*parent_);</div><div class="line"><a name="l06711"></a><span class="lineno"> 6711</span> </div><div class="line"><a name="l06712"></a><span class="lineno"> 6712</span>  <span class="comment">// Runs the tests only if there was no fatal failure during global</span></div><div class="line"><a name="l06713"></a><span class="lineno"> 6713</span>  <span class="comment">// set-up.</span></div><div class="line"><a name="l06714"></a><span class="lineno"> 6714</span>  <span class="keywordflow">if</span> (!Test::HasFatalFailure()) {</div><div class="line"><a name="l06715"></a><span class="lineno"> 6715</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> test_index = 0; test_index < total_test_suite_count();</div><div class="line"><a name="l06716"></a><span class="lineno"> 6716</span>  test_index++) {</div><div class="line"><a name="l06717"></a><span class="lineno"> 6717</span>  GetMutableSuiteCase(test_index)->Run();</div><div class="line"><a name="l06718"></a><span class="lineno"> 6718</span>  }</div><div class="line"><a name="l06719"></a><span class="lineno"> 6719</span>  }</div><div class="line"><a name="l06720"></a><span class="lineno"> 6720</span> </div><div class="line"><a name="l06721"></a><span class="lineno"> 6721</span>  <span class="comment">// Tears down all environments in reverse order afterwards.</span></div><div class="line"><a name="l06722"></a><span class="lineno"> 6722</span>  repeater->OnEnvironmentsTearDownStart(*parent_);</div><div class="line"><a name="l06723"></a><span class="lineno"> 6723</span>  std::for_each(environments_.rbegin(), environments_.rend(),</div><div class="line"><a name="l06724"></a><span class="lineno"> 6724</span>  TearDownEnvironment);</div><div class="line"><a name="l06725"></a><span class="lineno"> 6725</span>  repeater->OnEnvironmentsTearDownEnd(*parent_);</div><div class="line"><a name="l06726"></a><span class="lineno"> 6726</span>  }</div><div class="line"><a name="l06727"></a><span class="lineno"> 6727</span> </div><div class="line"><a name="l06728"></a><span class="lineno"> 6728</span>  elapsed_time_ = GetTimeInMillis() - start;</div><div class="line"><a name="l06729"></a><span class="lineno"> 6729</span> </div><div class="line"><a name="l06730"></a><span class="lineno"> 6730</span>  <span class="comment">// Tells the unit test event listener that the tests have just finished.</span></div><div class="line"><a name="l06731"></a><span class="lineno"> 6731</span>  repeater->OnTestIterationEnd(*parent_, i);</div><div class="line"><a name="l06732"></a><span class="lineno"> 6732</span> </div><div class="line"><a name="l06733"></a><span class="lineno"> 6733</span>  <span class="comment">// Gets the result and clears it.</span></div><div class="line"><a name="l06734"></a><span class="lineno"> 6734</span>  <span class="keywordflow">if</span> (!Passed()) {</div><div class="line"><a name="l06735"></a><span class="lineno"> 6735</span>  failed = <span class="keyword">true</span>;</div><div class="line"><a name="l06736"></a><span class="lineno"> 6736</span>  }</div><div class="line"><a name="l06737"></a><span class="lineno"> 6737</span> </div><div class="line"><a name="l06738"></a><span class="lineno"> 6738</span>  <span class="comment">// Restores the original test order after the iteration. This</span></div><div class="line"><a name="l06739"></a><span class="lineno"> 6739</span>  <span class="comment">// allows the user to quickly repro a failure that happens in the</span></div><div class="line"><a name="l06740"></a><span class="lineno"> 6740</span>  <span class="comment">// N-th iteration without repeating the first (N - 1) iterations.</span></div><div class="line"><a name="l06741"></a><span class="lineno"> 6741</span>  <span class="comment">// This is not enclosed in "if (GTEST_FLAG(shuffle)) { ... }", in</span></div><div class="line"><a name="l06742"></a><span class="lineno"> 6742</span>  <span class="comment">// case the user somehow changes the value of the flag somewhere</span></div><div class="line"><a name="l06743"></a><span class="lineno"> 6743</span>  <span class="comment">// (it's always safe to unshuffle the tests).</span></div><div class="line"><a name="l06744"></a><span class="lineno"> 6744</span>  UnshuffleTests();</div><div class="line"><a name="l06745"></a><span class="lineno"> 6745</span> </div><div class="line"><a name="l06746"></a><span class="lineno"> 6746</span>  <span class="keywordflow">if</span> (<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(shuffle)) {</div><div class="line"><a name="l06747"></a><span class="lineno"> 6747</span>  <span class="comment">// Picks a new random seed for each iteration.</span></div><div class="line"><a name="l06748"></a><span class="lineno"> 6748</span>  random_seed_ = GetNextRandomSeed(random_seed_);</div><div class="line"><a name="l06749"></a><span class="lineno"> 6749</span>  }</div><div class="line"><a name="l06750"></a><span class="lineno"> 6750</span>  }</div><div class="line"><a name="l06751"></a><span class="lineno"> 6751</span> </div><div class="line"><a name="l06752"></a><span class="lineno"> 6752</span>  repeater->OnTestProgramEnd(*parent_);</div><div class="line"><a name="l06753"></a><span class="lineno"> 6753</span> </div><div class="line"><a name="l06754"></a><span class="lineno"> 6754</span>  <span class="keywordflow">if</span> (!gtest_is_initialized_before_run_all_tests) {</div><div class="line"><a name="l06755"></a><span class="lineno"> 6755</span>  ColoredPrintf(</div><div class="line"><a name="l06756"></a><span class="lineno"> 6756</span>  <a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea9ebb3ddab9391781f6ee5021e1e443c3">COLOR_RED</a>,</div><div class="line"><a name="l06757"></a><span class="lineno"> 6757</span>  <span class="stringliteral">"\nIMPORTANT NOTICE - DO NOT IGNORE:\n"</span></div><div class="line"><a name="l06758"></a><span class="lineno"> 6758</span>  <span class="stringliteral">"This test program did NOT call "</span> <a class="code" href="gtest_8h.html#aa5e27ad4f88278501ef71bd9ddbb44c6">GTEST_INIT_GOOGLE_TEST_NAME_</a></div><div class="line"><a name="l06759"></a><span class="lineno"> 6759</span>  <span class="stringliteral">"() before calling RUN_ALL_TESTS(). This is INVALID. Soon "</span> <a class="code" href="gtest_8h.html#a13d98c217176bd8722c395b9225fc19d">GTEST_NAME_</a></div><div class="line"><a name="l06760"></a><span class="lineno"> 6760</span>  <span class="stringliteral">" will start to enforce the valid usage. "</span></div><div class="line"><a name="l06761"></a><span class="lineno"> 6761</span>  <span class="stringliteral">"Please fix it ASAP, or IT WILL START TO FAIL.\n"</span>); <span class="comment">// NOLINT</span></div><div class="line"><a name="l06762"></a><span class="lineno"> 6762</span> <span class="preprocessor">#if GTEST_FOR_GOOGLE_</span></div><div class="line"><a name="l06763"></a><span class="lineno"> 6763</span>  ColoredPrintf(<a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea9ebb3ddab9391781f6ee5021e1e443c3">COLOR_RED</a>,</div><div class="line"><a name="l06764"></a><span class="lineno"> 6764</span>  <span class="stringliteral">"For more details, see http://wiki/Main/ValidGUnitMain.\n"</span>);</div><div class="line"><a name="l06765"></a><span class="lineno"> 6765</span> <span class="preprocessor">#endif // GTEST_FOR_GOOGLE_</span></div><div class="line"><a name="l06766"></a><span class="lineno"> 6766</span>  }</div><div class="line"><a name="l06767"></a><span class="lineno"> 6767</span> </div><div class="line"><a name="l06768"></a><span class="lineno"> 6768</span>  <span class="keywordflow">return</span> !failed;</div><div class="line"><a name="l06769"></a><span class="lineno"> 6769</span> }</div><div class="line"><a name="l06770"></a><span class="lineno"> 6770</span> </div><div class="line"><a name="l06771"></a><span class="lineno"> 6771</span> <span class="comment">// Reads the GTEST_SHARD_STATUS_FILE environment variable, and creates the file</span></div><div class="line"><a name="l06772"></a><span class="lineno"> 6772</span> <span class="comment">// if the variable is present. If a file already exists at this location, this</span></div><div class="line"><a name="l06773"></a><span class="lineno"> 6773</span> <span class="comment">// function will write over it. If the variable is present, but the file cannot</span></div><div class="line"><a name="l06774"></a><span class="lineno"> 6774</span> <span class="comment">// be created, prints an error and exits.</span></div><div class="line"><a name="l06775"></a><span class="lineno"> 6775</span> <span class="keywordtype">void</span> WriteToShardStatusFileIfNeeded() {</div><div class="line"><a name="l06776"></a><span class="lineno"> 6776</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> test_shard_file = <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a1d5e3da5a27eed25986859fa83cafe95">posix::GetEnv</a>(kTestShardStatusFile);</div><div class="line"><a name="l06777"></a><span class="lineno"> 6777</span>  <span class="keywordflow">if</span> (test_shard_file != <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l06778"></a><span class="lineno"> 6778</span>  FILE* <span class="keyword">const</span> file = <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a4042201dcc4932641d484e7ddf94de7d">posix::FOpen</a>(test_shard_file, <span class="stringliteral">"w"</span>);</div><div class="line"><a name="l06779"></a><span class="lineno"> 6779</span>  <span class="keywordflow">if</span> (file == <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l06780"></a><span class="lineno"> 6780</span>  ColoredPrintf(<a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea9ebb3ddab9391781f6ee5021e1e443c3">COLOR_RED</a>,</div><div class="line"><a name="l06781"></a><span class="lineno"> 6781</span>  <span class="stringliteral">"Could not write to the test shard status file \"%s\" "</span></div><div class="line"><a name="l06782"></a><span class="lineno"> 6782</span>  <span class="stringliteral">"specified by the %s environment variable.\n"</span>,</div><div class="line"><a name="l06783"></a><span class="lineno"> 6783</span>  test_shard_file, kTestShardStatusFile);</div><div class="line"><a name="l06784"></a><span class="lineno"> 6784</span>  fflush(stdout);</div><div class="line"><a name="l06785"></a><span class="lineno"> 6785</span>  exit(EXIT_FAILURE);</div><div class="line"><a name="l06786"></a><span class="lineno"> 6786</span>  }</div><div class="line"><a name="l06787"></a><span class="lineno"> 6787</span>  fclose(file);</div><div class="line"><a name="l06788"></a><span class="lineno"> 6788</span>  }</div><div class="line"><a name="l06789"></a><span class="lineno"> 6789</span> }</div><div class="line"><a name="l06790"></a><span class="lineno"> 6790</span> </div><div class="line"><a name="l06791"></a><span class="lineno"> 6791</span> <span class="comment">// Checks whether sharding is enabled by examining the relevant</span></div><div class="line"><a name="l06792"></a><span class="lineno"> 6792</span> <span class="comment">// environment variable values. If the variables are present,</span></div><div class="line"><a name="l06793"></a><span class="lineno"> 6793</span> <span class="comment">// but inconsistent (i.e., shard_index >= total_shards), prints</span></div><div class="line"><a name="l06794"></a><span class="lineno"> 6794</span> <span class="comment">// an error and exits. If in_subprocess_for_death_test, sharding is</span></div><div class="line"><a name="l06795"></a><span class="lineno"> 6795</span> <span class="comment">// disabled because it must only be applied to the original test</span></div><div class="line"><a name="l06796"></a><span class="lineno"> 6796</span> <span class="comment">// process. Otherwise, we could filter out death tests we intended to execute.</span></div><div class="line"><a name="l06797"></a><span class="lineno"> 6797</span> <span class="keywordtype">bool</span> ShouldShard(<span class="keyword">const</span> <span class="keywordtype">char</span>* total_shards_env,</div><div class="line"><a name="l06798"></a><span class="lineno"> 6798</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* shard_index_env,</div><div class="line"><a name="l06799"></a><span class="lineno"> 6799</span>  <span class="keywordtype">bool</span> in_subprocess_for_death_test) {</div><div class="line"><a name="l06800"></a><span class="lineno"> 6800</span>  <span class="keywordflow">if</span> (in_subprocess_for_death_test) {</div><div class="line"><a name="l06801"></a><span class="lineno"> 6801</span>  <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l06802"></a><span class="lineno"> 6802</span>  }</div><div class="line"><a name="l06803"></a><span class="lineno"> 6803</span> </div><div class="line"><a name="l06804"></a><span class="lineno"> 6804</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8ee38faaf875f133358abaf9bc056cec">Int32</a> total_shards = Int32FromEnvOrDie(total_shards_env, -1);</div><div class="line"><a name="l06805"></a><span class="lineno"> 6805</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8ee38faaf875f133358abaf9bc056cec">Int32</a> shard_index = Int32FromEnvOrDie(shard_index_env, -1);</div><div class="line"><a name="l06806"></a><span class="lineno"> 6806</span> </div><div class="line"><a name="l06807"></a><span class="lineno"> 6807</span>  <span class="keywordflow">if</span> (total_shards == -1 && shard_index == -1) {</div><div class="line"><a name="l06808"></a><span class="lineno"> 6808</span>  <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l06809"></a><span class="lineno"> 6809</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (total_shards == -1 && shard_index != -1) {</div><div class="line"><a name="l06810"></a><span class="lineno"> 6810</span>  <span class="keyword">const</span> Message msg = Message()</div><div class="line"><a name="l06811"></a><span class="lineno"> 6811</span>  << <span class="stringliteral">"Invalid environment variables: you have "</span></div><div class="line"><a name="l06812"></a><span class="lineno"> 6812</span>  << kTestShardIndex << <span class="stringliteral">" = "</span> << shard_index</div><div class="line"><a name="l06813"></a><span class="lineno"> 6813</span>  << <span class="stringliteral">", but have left "</span> << kTestTotalShards << <span class="stringliteral">" unset.\n"</span>;</div><div class="line"><a name="l06814"></a><span class="lineno"> 6814</span>  ColoredPrintf(<a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea9ebb3ddab9391781f6ee5021e1e443c3">COLOR_RED</a>, <span class="stringliteral">"%s"</span>, msg.GetString().c_str());</div><div class="line"><a name="l06815"></a><span class="lineno"> 6815</span>  fflush(stdout);</div><div class="line"><a name="l06816"></a><span class="lineno"> 6816</span>  exit(EXIT_FAILURE);</div><div class="line"><a name="l06817"></a><span class="lineno"> 6817</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (total_shards != -1 && shard_index == -1) {</div><div class="line"><a name="l06818"></a><span class="lineno"> 6818</span>  <span class="keyword">const</span> Message msg = Message()</div><div class="line"><a name="l06819"></a><span class="lineno"> 6819</span>  << <span class="stringliteral">"Invalid environment variables: you have "</span></div><div class="line"><a name="l06820"></a><span class="lineno"> 6820</span>  << kTestTotalShards << <span class="stringliteral">" = "</span> << total_shards</div><div class="line"><a name="l06821"></a><span class="lineno"> 6821</span>  << <span class="stringliteral">", but have left "</span> << kTestShardIndex << <span class="stringliteral">" unset.\n"</span>;</div><div class="line"><a name="l06822"></a><span class="lineno"> 6822</span>  ColoredPrintf(<a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea9ebb3ddab9391781f6ee5021e1e443c3">COLOR_RED</a>, <span class="stringliteral">"%s"</span>, msg.GetString().c_str());</div><div class="line"><a name="l06823"></a><span class="lineno"> 6823</span>  fflush(stdout);</div><div class="line"><a name="l06824"></a><span class="lineno"> 6824</span>  exit(EXIT_FAILURE);</div><div class="line"><a name="l06825"></a><span class="lineno"> 6825</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (shard_index < 0 || shard_index >= total_shards) {</div><div class="line"><a name="l06826"></a><span class="lineno"> 6826</span>  <span class="keyword">const</span> Message msg = Message()</div><div class="line"><a name="l06827"></a><span class="lineno"> 6827</span>  << <span class="stringliteral">"Invalid environment variables: we require 0 <= "</span></div><div class="line"><a name="l06828"></a><span class="lineno"> 6828</span>  << kTestShardIndex << <span class="stringliteral">" < "</span> << kTestTotalShards</div><div class="line"><a name="l06829"></a><span class="lineno"> 6829</span>  << <span class="stringliteral">", but you have "</span> << kTestShardIndex << <span class="stringliteral">"="</span> << shard_index</div><div class="line"><a name="l06830"></a><span class="lineno"> 6830</span>  << <span class="stringliteral">", "</span> << kTestTotalShards << <span class="stringliteral">"="</span> << total_shards << <span class="stringliteral">".\n"</span>;</div><div class="line"><a name="l06831"></a><span class="lineno"> 6831</span>  ColoredPrintf(<a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea9ebb3ddab9391781f6ee5021e1e443c3">COLOR_RED</a>, <span class="stringliteral">"%s"</span>, msg.GetString().c_str());</div><div class="line"><a name="l06832"></a><span class="lineno"> 6832</span>  fflush(stdout);</div><div class="line"><a name="l06833"></a><span class="lineno"> 6833</span>  exit(EXIT_FAILURE);</div><div class="line"><a name="l06834"></a><span class="lineno"> 6834</span>  }</div><div class="line"><a name="l06835"></a><span class="lineno"> 6835</span> </div><div class="line"><a name="l06836"></a><span class="lineno"> 6836</span>  <span class="keywordflow">return</span> total_shards > 1;</div><div class="line"><a name="l06837"></a><span class="lineno"> 6837</span> }</div><div class="line"><a name="l06838"></a><span class="lineno"> 6838</span> </div><div class="line"><a name="l06839"></a><span class="lineno"> 6839</span> <span class="comment">// Parses the environment variable var as an Int32. If it is unset,</span></div><div class="line"><a name="l06840"></a><span class="lineno"> 6840</span> <span class="comment">// returns default_val. If it is not an Int32, prints an error</span></div><div class="line"><a name="l06841"></a><span class="lineno"> 6841</span> <span class="comment">// and aborts.</span></div><div class="line"><a name="l06842"></a><span class="lineno"> 6842</span> <a class="code" href="namespacetesting_1_1internal.html#a8ee38faaf875f133358abaf9bc056cec">Int32</a> Int32FromEnvOrDie(<span class="keyword">const</span> <span class="keywordtype">char</span>* var, <a class="code" href="namespacetesting_1_1internal.html#a8ee38faaf875f133358abaf9bc056cec">Int32</a> default_val) {</div><div class="line"><a name="l06843"></a><span class="lineno"> 6843</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* str_val = <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a1d5e3da5a27eed25986859fa83cafe95">posix::GetEnv</a>(var);</div><div class="line"><a name="l06844"></a><span class="lineno"> 6844</span>  <span class="keywordflow">if</span> (str_val == <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l06845"></a><span class="lineno"> 6845</span>  <span class="keywordflow">return</span> default_val;</div><div class="line"><a name="l06846"></a><span class="lineno"> 6846</span>  }</div><div class="line"><a name="l06847"></a><span class="lineno"> 6847</span> </div><div class="line"><a name="l06848"></a><span class="lineno"> 6848</span>  <a class="code" href="namespacetesting_1_1internal.html#a8ee38faaf875f133358abaf9bc056cec">Int32</a> result;</div><div class="line"><a name="l06849"></a><span class="lineno"> 6849</span>  <span class="keywordflow">if</span> (!<a class="code" href="namespacetesting_1_1internal.html#ac06fc81336a3d80755f4020d34321766">ParseInt32</a>(Message() << <span class="stringliteral">"The value of environment variable "</span> << var,</div><div class="line"><a name="l06850"></a><span class="lineno"> 6850</span>  str_val, &result)) {</div><div class="line"><a name="l06851"></a><span class="lineno"> 6851</span>  exit(EXIT_FAILURE);</div><div class="line"><a name="l06852"></a><span class="lineno"> 6852</span>  }</div><div class="line"><a name="l06853"></a><span class="lineno"> 6853</span>  <span class="keywordflow">return</span> result;</div><div class="line"><a name="l06854"></a><span class="lineno"> 6854</span> }</div><div class="line"><a name="l06855"></a><span class="lineno"> 6855</span> </div><div class="line"><a name="l06856"></a><span class="lineno"> 6856</span> <span class="comment">// Given the total number of shards, the shard index, and the test id,</span></div><div class="line"><a name="l06857"></a><span class="lineno"> 6857</span> <span class="comment">// returns true iff the test should be run on this shard. The test id is</span></div><div class="line"><a name="l06858"></a><span class="lineno"> 6858</span> <span class="comment">// some arbitrary but unique non-negative integer assigned to each test</span></div><div class="line"><a name="l06859"></a><span class="lineno"> 6859</span> <span class="comment">// method. Assumes that 0 <= shard_index < total_shards.</span></div><div class="line"><a name="l06860"></a><span class="lineno"> 6860</span> <span class="keywordtype">bool</span> ShouldRunTestOnShard(<span class="keywordtype">int</span> total_shards, <span class="keywordtype">int</span> shard_index, <span class="keywordtype">int</span> test_id) {</div><div class="line"><a name="l06861"></a><span class="lineno"> 6861</span>  <span class="keywordflow">return</span> (test_id % total_shards) == shard_index;</div><div class="line"><a name="l06862"></a><span class="lineno"> 6862</span> }</div><div class="line"><a name="l06863"></a><span class="lineno"> 6863</span> </div><div class="line"><a name="l06864"></a><span class="lineno"> 6864</span> <span class="comment">// Compares the name of each test with the user-specified filter to</span></div><div class="line"><a name="l06865"></a><span class="lineno"> 6865</span> <span class="comment">// decide whether the test should be run, then records the result in</span></div><div class="line"><a name="l06866"></a><span class="lineno"> 6866</span> <span class="comment">// each TestSuite and TestInfo object.</span></div><div class="line"><a name="l06867"></a><span class="lineno"> 6867</span> <span class="comment">// If shard_tests == true, further filters tests based on sharding</span></div><div class="line"><a name="l06868"></a><span class="lineno"> 6868</span> <span class="comment">// variables in the environment - see</span></div><div class="line"><a name="l06869"></a><span class="lineno"> 6869</span> <span class="comment">// https://github.com/google/googletest/blob/master/googletest/docs/advanced.md</span></div><div class="line"><a name="l06870"></a><span class="lineno"> 6870</span> <span class="comment">// . Returns the number of tests that should run.</span></div><div class="line"><a name="l06871"></a><span class="lineno"> 6871</span> <span class="keywordtype">int</span> UnitTestImpl::FilterTests(ReactionToSharding shard_tests) {</div><div class="line"><a name="l06872"></a><span class="lineno"> 6872</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8ee38faaf875f133358abaf9bc056cec">Int32</a> total_shards = shard_tests == HONOR_SHARDING_PROTOCOL ?</div><div class="line"><a name="l06873"></a><span class="lineno"> 6873</span>  Int32FromEnvOrDie(kTestTotalShards, -1) : -1;</div><div class="line"><a name="l06874"></a><span class="lineno"> 6874</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8ee38faaf875f133358abaf9bc056cec">Int32</a> shard_index = shard_tests == HONOR_SHARDING_PROTOCOL ?</div><div class="line"><a name="l06875"></a><span class="lineno"> 6875</span>  Int32FromEnvOrDie(kTestShardIndex, -1) : -1;</div><div class="line"><a name="l06876"></a><span class="lineno"> 6876</span> </div><div class="line"><a name="l06877"></a><span class="lineno"> 6877</span>  <span class="comment">// num_runnable_tests are the number of tests that will</span></div><div class="line"><a name="l06878"></a><span class="lineno"> 6878</span>  <span class="comment">// run across all shards (i.e., match filter and are not disabled).</span></div><div class="line"><a name="l06879"></a><span class="lineno"> 6879</span>  <span class="comment">// num_selected_tests are the number of tests to be run on</span></div><div class="line"><a name="l06880"></a><span class="lineno"> 6880</span>  <span class="comment">// this shard.</span></div><div class="line"><a name="l06881"></a><span class="lineno"> 6881</span>  <span class="keywordtype">int</span> num_runnable_tests = 0;</div><div class="line"><a name="l06882"></a><span class="lineno"> 6882</span>  <span class="keywordtype">int</span> num_selected_tests = 0;</div><div class="line"><a name="l06883"></a><span class="lineno"> 6883</span>  <span class="keywordflow">for</span> (<span class="keyword">auto</span>* test_suite : test_suites_) {</div><div class="line"><a name="l06884"></a><span class="lineno"> 6884</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& test_suite_name = test_suite->name();</div><div class="line"><a name="l06885"></a><span class="lineno"> 6885</span>  test_suite->set_should_run(<span class="keyword">false</span>);</div><div class="line"><a name="l06886"></a><span class="lineno"> 6886</span> </div><div class="line"><a name="l06887"></a><span class="lineno"> 6887</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j = 0; j < test_suite->test_info_list().size(); j++) {</div><div class="line"><a name="l06888"></a><span class="lineno"> 6888</span>  TestInfo* <span class="keyword">const</span> test_info = test_suite->test_info_list()[j];</div><div class="line"><a name="l06889"></a><span class="lineno"> 6889</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> test_name(test_info->name());</div><div class="line"><a name="l06890"></a><span class="lineno"> 6890</span>  <span class="comment">// A test is disabled if test suite name or test name matches</span></div><div class="line"><a name="l06891"></a><span class="lineno"> 6891</span>  <span class="comment">// kDisableTestFilter.</span></div><div class="line"><a name="l06892"></a><span class="lineno"> 6892</span>  <span class="keyword">const</span> <span class="keywordtype">bool</span> is_disabled = internal::UnitTestOptions::MatchesFilter(</div><div class="line"><a name="l06893"></a><span class="lineno"> 6893</span>  test_suite_name, kDisableTestFilter) ||</div><div class="line"><a name="l06894"></a><span class="lineno"> 6894</span>  internal::UnitTestOptions::MatchesFilter(</div><div class="line"><a name="l06895"></a><span class="lineno"> 6895</span>  test_name, kDisableTestFilter);</div><div class="line"><a name="l06896"></a><span class="lineno"> 6896</span>  test_info->is_disabled_ = is_disabled;</div><div class="line"><a name="l06897"></a><span class="lineno"> 6897</span> </div><div class="line"><a name="l06898"></a><span class="lineno"> 6898</span>  <span class="keyword">const</span> <span class="keywordtype">bool</span> matches_filter = internal::UnitTestOptions::FilterMatchesTest(</div><div class="line"><a name="l06899"></a><span class="lineno"> 6899</span>  test_suite_name, test_name);</div><div class="line"><a name="l06900"></a><span class="lineno"> 6900</span>  test_info->matches_filter_ = matches_filter;</div><div class="line"><a name="l06901"></a><span class="lineno"> 6901</span> </div><div class="line"><a name="l06902"></a><span class="lineno"> 6902</span>  <span class="keyword">const</span> <span class="keywordtype">bool</span> is_runnable =</div><div class="line"><a name="l06903"></a><span class="lineno"> 6903</span>  (<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(also_run_disabled_tests) || !is_disabled) &&</div><div class="line"><a name="l06904"></a><span class="lineno"> 6904</span>  matches_filter;</div><div class="line"><a name="l06905"></a><span class="lineno"> 6905</span> </div><div class="line"><a name="l06906"></a><span class="lineno"> 6906</span>  <span class="keyword">const</span> <span class="keywordtype">bool</span> is_in_another_shard =</div><div class="line"><a name="l06907"></a><span class="lineno"> 6907</span>  shard_tests != IGNORE_SHARDING_PROTOCOL &&</div><div class="line"><a name="l06908"></a><span class="lineno"> 6908</span>  !ShouldRunTestOnShard(total_shards, shard_index, num_runnable_tests);</div><div class="line"><a name="l06909"></a><span class="lineno"> 6909</span>  test_info->is_in_another_shard_ = is_in_another_shard;</div><div class="line"><a name="l06910"></a><span class="lineno"> 6910</span>  <span class="keyword">const</span> <span class="keywordtype">bool</span> is_selected = is_runnable && !is_in_another_shard;</div><div class="line"><a name="l06911"></a><span class="lineno"> 6911</span> </div><div class="line"><a name="l06912"></a><span class="lineno"> 6912</span>  num_runnable_tests += is_runnable;</div><div class="line"><a name="l06913"></a><span class="lineno"> 6913</span>  num_selected_tests += is_selected;</div><div class="line"><a name="l06914"></a><span class="lineno"> 6914</span> </div><div class="line"><a name="l06915"></a><span class="lineno"> 6915</span>  test_info->should_run_ = is_selected;</div><div class="line"><a name="l06916"></a><span class="lineno"> 6916</span>  test_suite->set_should_run(test_suite->should_run() || is_selected);</div><div class="line"><a name="l06917"></a><span class="lineno"> 6917</span>  }</div><div class="line"><a name="l06918"></a><span class="lineno"> 6918</span>  }</div><div class="line"><a name="l06919"></a><span class="lineno"> 6919</span>  <span class="keywordflow">return</span> num_selected_tests;</div><div class="line"><a name="l06920"></a><span class="lineno"> 6920</span> }</div><div class="line"><a name="l06921"></a><span class="lineno"> 6921</span> </div><div class="line"><a name="l06922"></a><span class="lineno"> 6922</span> <span class="comment">// Prints the given C-string on a single line by replacing all '\n'</span></div><div class="line"><a name="l06923"></a><span class="lineno"> 6923</span> <span class="comment">// characters with string "\\n". If the output takes more than</span></div><div class="line"><a name="l06924"></a><span class="lineno"> 6924</span> <span class="comment">// max_length characters, only prints the first max_length characters</span></div><div class="line"><a name="l06925"></a><span class="lineno"> 6925</span> <span class="comment">// and "...".</span></div><div class="line"><a name="l06926"></a><span class="lineno"> 6926</span> <span class="keyword">static</span> <span class="keywordtype">void</span> PrintOnOneLine(<span class="keyword">const</span> <span class="keywordtype">char</span>* str, <span class="keywordtype">int</span> max_length) {</div><div class="line"><a name="l06927"></a><span class="lineno"> 6927</span>  <span class="keywordflow">if</span> (str != <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l06928"></a><span class="lineno"> 6928</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; *str != <span class="charliteral">'\0'</span>; ++str) {</div><div class="line"><a name="l06929"></a><span class="lineno"> 6929</span>  <span class="keywordflow">if</span> (i >= max_length) {</div><div class="line"><a name="l06930"></a><span class="lineno"> 6930</span>  printf(<span class="stringliteral">"..."</span>);</div><div class="line"><a name="l06931"></a><span class="lineno"> 6931</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l06932"></a><span class="lineno"> 6932</span>  }</div><div class="line"><a name="l06933"></a><span class="lineno"> 6933</span>  <span class="keywordflow">if</span> (*str == <span class="charliteral">'\n'</span>) {</div><div class="line"><a name="l06934"></a><span class="lineno"> 6934</span>  printf(<span class="stringliteral">"\\n"</span>);</div><div class="line"><a name="l06935"></a><span class="lineno"> 6935</span>  i += 2;</div><div class="line"><a name="l06936"></a><span class="lineno"> 6936</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l06937"></a><span class="lineno"> 6937</span>  printf(<span class="stringliteral">"%c"</span>, *str);</div><div class="line"><a name="l06938"></a><span class="lineno"> 6938</span>  ++i;</div><div class="line"><a name="l06939"></a><span class="lineno"> 6939</span>  }</div><div class="line"><a name="l06940"></a><span class="lineno"> 6940</span>  }</div><div class="line"><a name="l06941"></a><span class="lineno"> 6941</span>  }</div><div class="line"><a name="l06942"></a><span class="lineno"> 6942</span> }</div><div class="line"><a name="l06943"></a><span class="lineno"> 6943</span> </div><div class="line"><a name="l06944"></a><span class="lineno"> 6944</span> <span class="comment">// Prints the names of the tests matching the user-specified filter flag.</span></div><div class="line"><a name="l06945"></a><span class="lineno"> 6945</span> <span class="keywordtype">void</span> UnitTestImpl::ListTestsMatchingFilter() {</div><div class="line"><a name="l06946"></a><span class="lineno"> 6946</span>  <span class="comment">// Print at most this many characters for each type/value parameter.</span></div><div class="line"><a name="l06947"></a><span class="lineno"> 6947</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> kMaxParamLength = 250;</div><div class="line"><a name="l06948"></a><span class="lineno"> 6948</span> </div><div class="line"><a name="l06949"></a><span class="lineno"> 6949</span>  <span class="keywordflow">for</span> (<span class="keyword">auto</span>* test_suite : test_suites_) {</div><div class="line"><a name="l06950"></a><span class="lineno"> 6950</span>  <span class="keywordtype">bool</span> printed_test_suite_name = <span class="keyword">false</span>;</div><div class="line"><a name="l06951"></a><span class="lineno"> 6951</span> </div><div class="line"><a name="l06952"></a><span class="lineno"> 6952</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j = 0; j < test_suite->test_info_list().size(); j++) {</div><div class="line"><a name="l06953"></a><span class="lineno"> 6953</span>  <span class="keyword">const</span> TestInfo* <span class="keyword">const</span> test_info = test_suite->test_info_list()[j];</div><div class="line"><a name="l06954"></a><span class="lineno"> 6954</span>  <span class="keywordflow">if</span> (test_info->matches_filter_) {</div><div class="line"><a name="l06955"></a><span class="lineno"> 6955</span>  <span class="keywordflow">if</span> (!printed_test_suite_name) {</div><div class="line"><a name="l06956"></a><span class="lineno"> 6956</span>  printed_test_suite_name = <span class="keyword">true</span>;</div><div class="line"><a name="l06957"></a><span class="lineno"> 6957</span>  printf(<span class="stringliteral">"%s."</span>, test_suite->name());</div><div class="line"><a name="l06958"></a><span class="lineno"> 6958</span>  <span class="keywordflow">if</span> (test_suite->type_param() != <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l06959"></a><span class="lineno"> 6959</span>  printf(<span class="stringliteral">" # %s = "</span>, kTypeParamLabel);</div><div class="line"><a name="l06960"></a><span class="lineno"> 6960</span>  <span class="comment">// We print the type parameter on a single line to make</span></div><div class="line"><a name="l06961"></a><span class="lineno"> 6961</span>  <span class="comment">// the output easy to parse by a program.</span></div><div class="line"><a name="l06962"></a><span class="lineno"> 6962</span>  PrintOnOneLine(test_suite->type_param(), kMaxParamLength);</div><div class="line"><a name="l06963"></a><span class="lineno"> 6963</span>  }</div><div class="line"><a name="l06964"></a><span class="lineno"> 6964</span>  printf(<span class="stringliteral">"\n"</span>);</div><div class="line"><a name="l06965"></a><span class="lineno"> 6965</span>  }</div><div class="line"><a name="l06966"></a><span class="lineno"> 6966</span>  printf(<span class="stringliteral">" %s"</span>, test_info->name());</div><div class="line"><a name="l06967"></a><span class="lineno"> 6967</span>  <span class="keywordflow">if</span> (test_info->value_param() != <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l06968"></a><span class="lineno"> 6968</span>  printf(<span class="stringliteral">" # %s = "</span>, kValueParamLabel);</div><div class="line"><a name="l06969"></a><span class="lineno"> 6969</span>  <span class="comment">// We print the value parameter on a single line to make the</span></div><div class="line"><a name="l06970"></a><span class="lineno"> 6970</span>  <span class="comment">// output easy to parse by a program.</span></div><div class="line"><a name="l06971"></a><span class="lineno"> 6971</span>  PrintOnOneLine(test_info->value_param(), kMaxParamLength);</div><div class="line"><a name="l06972"></a><span class="lineno"> 6972</span>  }</div><div class="line"><a name="l06973"></a><span class="lineno"> 6973</span>  printf(<span class="stringliteral">"\n"</span>);</div><div class="line"><a name="l06974"></a><span class="lineno"> 6974</span>  }</div><div class="line"><a name="l06975"></a><span class="lineno"> 6975</span>  }</div><div class="line"><a name="l06976"></a><span class="lineno"> 6976</span>  }</div><div class="line"><a name="l06977"></a><span class="lineno"> 6977</span>  fflush(stdout);</div><div class="line"><a name="l06978"></a><span class="lineno"> 6978</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& output_format = UnitTestOptions::GetOutputFormat();</div><div class="line"><a name="l06979"></a><span class="lineno"> 6979</span>  <span class="keywordflow">if</span> (output_format == <span class="stringliteral">"xml"</span> || output_format == <span class="stringliteral">"json"</span>) {</div><div class="line"><a name="l06980"></a><span class="lineno"> 6980</span>  FILE* fileout = OpenFileForWriting(</div><div class="line"><a name="l06981"></a><span class="lineno"> 6981</span>  UnitTestOptions::GetAbsolutePathToOutputFile().c_str());</div><div class="line"><a name="l06982"></a><span class="lineno"> 6982</span>  std::stringstream stream;</div><div class="line"><a name="l06983"></a><span class="lineno"> 6983</span>  <span class="keywordflow">if</span> (output_format == <span class="stringliteral">"xml"</span>) {</div><div class="line"><a name="l06984"></a><span class="lineno"> 6984</span>  XmlUnitTestResultPrinter(</div><div class="line"><a name="l06985"></a><span class="lineno"> 6985</span>  UnitTestOptions::GetAbsolutePathToOutputFile().c_str())</div><div class="line"><a name="l06986"></a><span class="lineno"> 6986</span>  .PrintXmlTestsList(&stream, test_suites_);</div><div class="line"><a name="l06987"></a><span class="lineno"> 6987</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (output_format == <span class="stringliteral">"json"</span>) {</div><div class="line"><a name="l06988"></a><span class="lineno"> 6988</span>  JsonUnitTestResultPrinter(</div><div class="line"><a name="l06989"></a><span class="lineno"> 6989</span>  UnitTestOptions::GetAbsolutePathToOutputFile().c_str())</div><div class="line"><a name="l06990"></a><span class="lineno"> 6990</span>  .PrintJsonTestList(&stream, test_suites_);</div><div class="line"><a name="l06991"></a><span class="lineno"> 6991</span>  }</div><div class="line"><a name="l06992"></a><span class="lineno"> 6992</span>  fprintf(fileout, <span class="stringliteral">"%s"</span>, StringStreamToString(&stream).c_str());</div><div class="line"><a name="l06993"></a><span class="lineno"> 6993</span>  fclose(fileout);</div><div class="line"><a name="l06994"></a><span class="lineno"> 6994</span>  }</div><div class="line"><a name="l06995"></a><span class="lineno"> 6995</span> }</div><div class="line"><a name="l06996"></a><span class="lineno"> 6996</span> </div><div class="line"><a name="l06997"></a><span class="lineno"> 6997</span> <span class="comment">// Sets the OS stack trace getter.</span></div><div class="line"><a name="l06998"></a><span class="lineno"> 6998</span> <span class="comment">//</span></div><div class="line"><a name="l06999"></a><span class="lineno"> 6999</span> <span class="comment">// Does nothing if the input and the current OS stack trace getter are</span></div><div class="line"><a name="l07000"></a><span class="lineno"> 7000</span> <span class="comment">// the same; otherwise, deletes the old getter and makes the input the</span></div><div class="line"><a name="l07001"></a><span class="lineno"> 7001</span> <span class="comment">// current getter.</span></div><div class="line"><a name="l07002"></a><span class="lineno"> 7002</span> <span class="keywordtype">void</span> UnitTestImpl::set_os_stack_trace_getter(</div><div class="line"><a name="l07003"></a><span class="lineno"> 7003</span>  OsStackTraceGetterInterface* getter) {</div><div class="line"><a name="l07004"></a><span class="lineno"> 7004</span>  <span class="keywordflow">if</span> (os_stack_trace_getter_ != getter) {</div><div class="line"><a name="l07005"></a><span class="lineno"> 7005</span>  <span class="keyword">delete</span> os_stack_trace_getter_;</div><div class="line"><a name="l07006"></a><span class="lineno"> 7006</span>  os_stack_trace_getter_ = getter;</div><div class="line"><a name="l07007"></a><span class="lineno"> 7007</span>  }</div><div class="line"><a name="l07008"></a><span class="lineno"> 7008</span> }</div><div class="line"><a name="l07009"></a><span class="lineno"> 7009</span> </div><div class="line"><a name="l07010"></a><span class="lineno"> 7010</span> <span class="comment">// Returns the current OS stack trace getter if it is not NULL;</span></div><div class="line"><a name="l07011"></a><span class="lineno"> 7011</span> <span class="comment">// otherwise, creates an OsStackTraceGetter, makes it the current</span></div><div class="line"><a name="l07012"></a><span class="lineno"> 7012</span> <span class="comment">// getter, and returns it.</span></div><div class="line"><a name="l07013"></a><span class="lineno"> 7013</span> OsStackTraceGetterInterface* UnitTestImpl::os_stack_trace_getter() {</div><div class="line"><a name="l07014"></a><span class="lineno"> 7014</span>  <span class="keywordflow">if</span> (os_stack_trace_getter_ == <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l07015"></a><span class="lineno"> 7015</span> <span class="preprocessor">#ifdef GTEST_OS_STACK_TRACE_GETTER_</span></div><div class="line"><a name="l07016"></a><span class="lineno"> 7016</span>  os_stack_trace_getter_ = <span class="keyword">new</span> GTEST_OS_STACK_TRACE_GETTER_;</div><div class="line"><a name="l07017"></a><span class="lineno"> 7017</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l07018"></a><span class="lineno"> 7018</span>  os_stack_trace_getter_ = <span class="keyword">new</span> OsStackTraceGetter;</div><div class="line"><a name="l07019"></a><span class="lineno"> 7019</span> <span class="preprocessor">#endif // GTEST_OS_STACK_TRACE_GETTER_</span></div><div class="line"><a name="l07020"></a><span class="lineno"> 7020</span>  }</div><div class="line"><a name="l07021"></a><span class="lineno"> 7021</span> </div><div class="line"><a name="l07022"></a><span class="lineno"> 7022</span>  <span class="keywordflow">return</span> os_stack_trace_getter_;</div><div class="line"><a name="l07023"></a><span class="lineno"> 7023</span> }</div><div class="line"><a name="l07024"></a><span class="lineno"> 7024</span> </div><div class="line"><a name="l07025"></a><span class="lineno"> 7025</span> <span class="comment">// Returns the most specific TestResult currently running.</span></div><div class="line"><a name="l07026"></a><span class="lineno"> 7026</span> TestResult* UnitTestImpl::current_test_result() {</div><div class="line"><a name="l07027"></a><span class="lineno"> 7027</span>  <span class="keywordflow">if</span> (current_test_info_ != <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l07028"></a><span class="lineno"> 7028</span>  <span class="keywordflow">return</span> &current_test_info_->result_;</div><div class="line"><a name="l07029"></a><span class="lineno"> 7029</span>  }</div><div class="line"><a name="l07030"></a><span class="lineno"> 7030</span>  <span class="keywordflow">if</span> (current_test_suite_ != <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l07031"></a><span class="lineno"> 7031</span>  <span class="keywordflow">return</span> &current_test_suite_->ad_hoc_test_result_;</div><div class="line"><a name="l07032"></a><span class="lineno"> 7032</span>  }</div><div class="line"><a name="l07033"></a><span class="lineno"> 7033</span>  <span class="keywordflow">return</span> &ad_hoc_test_result_;</div><div class="line"><a name="l07034"></a><span class="lineno"> 7034</span> }</div><div class="line"><a name="l07035"></a><span class="lineno"> 7035</span> </div><div class="line"><a name="l07036"></a><span class="lineno"> 7036</span> <span class="comment">// Shuffles all test suites, and the tests within each test suite,</span></div><div class="line"><a name="l07037"></a><span class="lineno"> 7037</span> <span class="comment">// making sure that death tests are still run first.</span></div><div class="line"><a name="l07038"></a><span class="lineno"> 7038</span> <span class="keywordtype">void</span> UnitTestImpl::ShuffleTests() {</div><div class="line"><a name="l07039"></a><span class="lineno"> 7039</span>  <span class="comment">// Shuffles the death test suites.</span></div><div class="line"><a name="l07040"></a><span class="lineno"> 7040</span>  ShuffleRange(random(), 0, last_death_test_suite_ + 1, &test_suite_indices_);</div><div class="line"><a name="l07041"></a><span class="lineno"> 7041</span> </div><div class="line"><a name="l07042"></a><span class="lineno"> 7042</span>  <span class="comment">// Shuffles the non-death test suites.</span></div><div class="line"><a name="l07043"></a><span class="lineno"> 7043</span>  ShuffleRange(random(), last_death_test_suite_ + 1,</div><div class="line"><a name="l07044"></a><span class="lineno"> 7044</span>  static_cast<int>(test_suites_.size()), &test_suite_indices_);</div><div class="line"><a name="l07045"></a><span class="lineno"> 7045</span> </div><div class="line"><a name="l07046"></a><span class="lineno"> 7046</span>  <span class="comment">// Shuffles the tests inside each test suite.</span></div><div class="line"><a name="l07047"></a><span class="lineno"> 7047</span>  <span class="keywordflow">for</span> (<span class="keyword">auto</span>& test_suite : test_suites_) {</div><div class="line"><a name="l07048"></a><span class="lineno"> 7048</span>  test_suite->ShuffleTests(random());</div><div class="line"><a name="l07049"></a><span class="lineno"> 7049</span>  }</div><div class="line"><a name="l07050"></a><span class="lineno"> 7050</span> }</div><div class="line"><a name="l07051"></a><span class="lineno"> 7051</span> </div><div class="line"><a name="l07052"></a><span class="lineno"> 7052</span> <span class="comment">// Restores the test suites and tests to their order before the first shuffle.</span></div><div class="line"><a name="l07053"></a><span class="lineno"> 7053</span> <span class="keywordtype">void</span> UnitTestImpl::UnshuffleTests() {</div><div class="line"><a name="l07054"></a><span class="lineno"> 7054</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i < test_suites_.size(); i++) {</div><div class="line"><a name="l07055"></a><span class="lineno"> 7055</span>  <span class="comment">// Unshuffles the tests in each test suite.</span></div><div class="line"><a name="l07056"></a><span class="lineno"> 7056</span>  test_suites_[i]->UnshuffleTests();</div><div class="line"><a name="l07057"></a><span class="lineno"> 7057</span>  <span class="comment">// Resets the index of each test suite.</span></div><div class="line"><a name="l07058"></a><span class="lineno"> 7058</span>  test_suite_indices_[i] = <span class="keyword">static_cast<</span><span class="keywordtype">int</span><span class="keyword">></span>(i);</div><div class="line"><a name="l07059"></a><span class="lineno"> 7059</span>  }</div><div class="line"><a name="l07060"></a><span class="lineno"> 7060</span> }</div><div class="line"><a name="l07061"></a><span class="lineno"> 7061</span> </div><div class="line"><a name="l07062"></a><span class="lineno"> 7062</span> <span class="comment">// Returns the current OS stack trace as an std::string.</span></div><div class="line"><a name="l07063"></a><span class="lineno"> 7063</span> <span class="comment">//</span></div><div class="line"><a name="l07064"></a><span class="lineno"> 7064</span> <span class="comment">// The maximum number of stack frames to be included is specified by</span></div><div class="line"><a name="l07065"></a><span class="lineno"> 7065</span> <span class="comment">// the gtest_stack_trace_depth flag. The skip_count parameter</span></div><div class="line"><a name="l07066"></a><span class="lineno"> 7066</span> <span class="comment">// specifies the number of top frames to be skipped, which doesn't</span></div><div class="line"><a name="l07067"></a><span class="lineno"> 7067</span> <span class="comment">// count against the number of frames to be included.</span></div><div class="line"><a name="l07068"></a><span class="lineno"> 7068</span> <span class="comment">//</span></div><div class="line"><a name="l07069"></a><span class="lineno"> 7069</span> <span class="comment">// For example, if Foo() calls Bar(), which in turn calls</span></div><div class="line"><a name="l07070"></a><span class="lineno"> 7070</span> <span class="comment">// GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in</span></div><div class="line"><a name="l07071"></a><span class="lineno"> 7071</span> <span class="comment">// the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't.</span></div><div class="line"><a name="l07072"></a><span class="lineno"> 7072</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> <a class="code" href="namespacetesting_1_1internal.html#ae7ae495d3207e26968dfbd537c5e6dee">GetCurrentOsStackTraceExceptTop</a>(UnitTest* <span class="comment">/*unit_test*/</span>,</div><div class="line"><a name="l07073"></a><span class="lineno"> 7073</span>  <span class="keywordtype">int</span> skip_count) {</div><div class="line"><a name="l07074"></a><span class="lineno"> 7074</span>  <span class="comment">// We pass skip_count + 1 to skip this wrapper function in addition</span></div><div class="line"><a name="l07075"></a><span class="lineno"> 7075</span>  <span class="comment">// to what the user really wants to skip.</span></div><div class="line"><a name="l07076"></a><span class="lineno"> 7076</span>  <span class="keywordflow">return</span> GetUnitTestImpl()->CurrentOsStackTraceExceptTop(skip_count + 1);</div><div class="line"><a name="l07077"></a><span class="lineno"> 7077</span> }</div><div class="line"><a name="l07078"></a><span class="lineno"> 7078</span> </div><div class="line"><a name="l07079"></a><span class="lineno"> 7079</span> <span class="comment">// Used by the GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_ macro to</span></div><div class="line"><a name="l07080"></a><span class="lineno"> 7080</span> <span class="comment">// suppress unreachable code warnings.</span></div><div class="line"><a name="l07081"></a><span class="lineno"> 7081</span> <span class="keyword">namespace </span>{</div><div class="line"><a name="l07082"></a><span class="lineno"> 7082</span> <span class="keyword">class </span>ClassUniqueToAlwaysTrue {};</div><div class="line"><a name="l07083"></a><span class="lineno"> 7083</span> }</div><div class="line"><a name="l07084"></a><span class="lineno"> 7084</span> </div><div class="line"><a name="l07085"></a><span class="lineno"> 7085</span> <span class="keywordtype">bool</span> <a class="code" href="namespacetesting_1_1internal.html#ab2709373c78eb8b1c22a6ba30cceba52">IsTrue</a>(<span class="keywordtype">bool</span> condition) { <span class="keywordflow">return</span> condition; }</div><div class="line"><a name="l07086"></a><span class="lineno"> 7086</span> </div><div class="line"><a name="l07087"></a><span class="lineno"> 7087</span> <span class="keywordtype">bool</span> <a class="code" href="namespacetesting_1_1internal.html#a4d46f09c3bfe68700b7f728d2cc3782f">AlwaysTrue</a>() {</div><div class="line"><a name="l07088"></a><span class="lineno"> 7088</span> <span class="preprocessor">#if GTEST_HAS_EXCEPTIONS</span></div><div class="line"><a name="l07089"></a><span class="lineno"> 7089</span>  <span class="comment">// This condition is always false so AlwaysTrue() never actually throws,</span></div><div class="line"><a name="l07090"></a><span class="lineno"> 7090</span>  <span class="comment">// but it makes the compiler think that it may throw.</span></div><div class="line"><a name="l07091"></a><span class="lineno"> 7091</span>  <span class="keywordflow">if</span> (<a class="code" href="namespacetesting_1_1internal.html#ab2709373c78eb8b1c22a6ba30cceba52">IsTrue</a>(<span class="keyword">false</span>))</div><div class="line"><a name="l07092"></a><span class="lineno"> 7092</span>  <span class="keywordflow">throw</span> ClassUniqueToAlwaysTrue();</div><div class="line"><a name="l07093"></a><span class="lineno"> 7093</span> <span class="preprocessor">#endif // GTEST_HAS_EXCEPTIONS</span></div><div class="line"><a name="l07094"></a><span class="lineno"> 7094</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l07095"></a><span class="lineno"> 7095</span> }</div><div class="line"><a name="l07096"></a><span class="lineno"> 7096</span> </div><div class="line"><a name="l07097"></a><span class="lineno"> 7097</span> <span class="comment">// If *pstr starts with the given prefix, modifies *pstr to be right</span></div><div class="line"><a name="l07098"></a><span class="lineno"> 7098</span> <span class="comment">// past the prefix and returns true; otherwise leaves *pstr unchanged</span></div><div class="line"><a name="l07099"></a><span class="lineno"> 7099</span> <span class="comment">// and returns false. None of pstr, *pstr, and prefix can be NULL.</span></div><div class="line"><a name="l07100"></a><span class="lineno"> 7100</span> <span class="keywordtype">bool</span> <a class="code" href="namespacetesting_1_1internal.html#aac72b20299ad4a99554ce161e1769560">SkipPrefix</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* prefix, <span class="keyword">const</span> <span class="keywordtype">char</span>** pstr) {</div><div class="line"><a name="l07101"></a><span class="lineno"> 7101</span>  <span class="keyword">const</span> <span class="keywordtype">size_t</span> prefix_len = strlen(prefix);</div><div class="line"><a name="l07102"></a><span class="lineno"> 7102</span>  <span class="keywordflow">if</span> (strncmp(*pstr, prefix, prefix_len) == 0) {</div><div class="line"><a name="l07103"></a><span class="lineno"> 7103</span>  *pstr += prefix_len;</div><div class="line"><a name="l07104"></a><span class="lineno"> 7104</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l07105"></a><span class="lineno"> 7105</span>  }</div><div class="line"><a name="l07106"></a><span class="lineno"> 7106</span>  <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l07107"></a><span class="lineno"> 7107</span> }</div><div class="line"><a name="l07108"></a><span class="lineno"> 7108</span> </div><div class="line"><a name="l07109"></a><span class="lineno"> 7109</span> <span class="comment">// Parses a string as a command line flag. The string should have</span></div><div class="line"><a name="l07110"></a><span class="lineno"> 7110</span> <span class="comment">// the format "--flag=value". When def_optional is true, the "=value"</span></div><div class="line"><a name="l07111"></a><span class="lineno"> 7111</span> <span class="comment">// part can be omitted.</span></div><div class="line"><a name="l07112"></a><span class="lineno"> 7112</span> <span class="comment">//</span></div><div class="line"><a name="l07113"></a><span class="lineno"> 7113</span> <span class="comment">// Returns the value of the flag, or NULL if the parsing failed.</span></div><div class="line"><a name="l07114"></a><span class="lineno"> 7114</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* ParseFlagValue(<span class="keyword">const</span> <span class="keywordtype">char</span>* str, <span class="keyword">const</span> <span class="keywordtype">char</span>* flag,</div><div class="line"><a name="l07115"></a><span class="lineno"> 7115</span>  <span class="keywordtype">bool</span> def_optional) {</div><div class="line"><a name="l07116"></a><span class="lineno"> 7116</span>  <span class="comment">// str and flag must not be NULL.</span></div><div class="line"><a name="l07117"></a><span class="lineno"> 7117</span>  <span class="keywordflow">if</span> (str == <span class="keyword">nullptr</span> || flag == <span class="keyword">nullptr</span>) <span class="keywordflow">return</span> <span class="keyword">nullptr</span>;</div><div class="line"><a name="l07118"></a><span class="lineno"> 7118</span> </div><div class="line"><a name="l07119"></a><span class="lineno"> 7119</span>  <span class="comment">// The flag must start with "--" followed by GTEST_FLAG_PREFIX_.</span></div><div class="line"><a name="l07120"></a><span class="lineno"> 7120</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> flag_str = <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(<span class="stringliteral">"--"</span>) + <a class="code" href="gtest_8h.html#a088e84784c589ba9b1fc48602ad8eabf">GTEST_FLAG_PREFIX_</a> + flag;</div><div class="line"><a name="l07121"></a><span class="lineno"> 7121</span>  <span class="keyword">const</span> <span class="keywordtype">size_t</span> flag_len = flag_str.length();</div><div class="line"><a name="l07122"></a><span class="lineno"> 7122</span>  <span class="keywordflow">if</span> (strncmp(str, flag_str.c_str(), flag_len) != 0) <span class="keywordflow">return</span> <span class="keyword">nullptr</span>;</div><div class="line"><a name="l07123"></a><span class="lineno"> 7123</span> </div><div class="line"><a name="l07124"></a><span class="lineno"> 7124</span>  <span class="comment">// Skips the flag name.</span></div><div class="line"><a name="l07125"></a><span class="lineno"> 7125</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* flag_end = str + flag_len;</div><div class="line"><a name="l07126"></a><span class="lineno"> 7126</span> </div><div class="line"><a name="l07127"></a><span class="lineno"> 7127</span>  <span class="comment">// When def_optional is true, it's OK to not have a "=value" part.</span></div><div class="line"><a name="l07128"></a><span class="lineno"> 7128</span>  <span class="keywordflow">if</span> (def_optional && (flag_end[0] == <span class="charliteral">'\0'</span>)) {</div><div class="line"><a name="l07129"></a><span class="lineno"> 7129</span>  <span class="keywordflow">return</span> flag_end;</div><div class="line"><a name="l07130"></a><span class="lineno"> 7130</span>  }</div><div class="line"><a name="l07131"></a><span class="lineno"> 7131</span> </div><div class="line"><a name="l07132"></a><span class="lineno"> 7132</span>  <span class="comment">// If def_optional is true and there are more characters after the</span></div><div class="line"><a name="l07133"></a><span class="lineno"> 7133</span>  <span class="comment">// flag name, or if def_optional is false, there must be a '=' after</span></div><div class="line"><a name="l07134"></a><span class="lineno"> 7134</span>  <span class="comment">// the flag name.</span></div><div class="line"><a name="l07135"></a><span class="lineno"> 7135</span>  <span class="keywordflow">if</span> (flag_end[0] != <span class="charliteral">'='</span>) <span class="keywordflow">return</span> <span class="keyword">nullptr</span>;</div><div class="line"><a name="l07136"></a><span class="lineno"> 7136</span> </div><div class="line"><a name="l07137"></a><span class="lineno"> 7137</span>  <span class="comment">// Returns the string after "=".</span></div><div class="line"><a name="l07138"></a><span class="lineno"> 7138</span>  <span class="keywordflow">return</span> flag_end + 1;</div><div class="line"><a name="l07139"></a><span class="lineno"> 7139</span> }</div><div class="line"><a name="l07140"></a><span class="lineno"> 7140</span> </div><div class="line"><a name="l07141"></a><span class="lineno"> 7141</span> <span class="comment">// Parses a string for a bool flag, in the form of either</span></div><div class="line"><a name="l07142"></a><span class="lineno"> 7142</span> <span class="comment">// "--flag=value" or "--flag".</span></div><div class="line"><a name="l07143"></a><span class="lineno"> 7143</span> <span class="comment">//</span></div><div class="line"><a name="l07144"></a><span class="lineno"> 7144</span> <span class="comment">// In the former case, the value is taken as true as long as it does</span></div><div class="line"><a name="l07145"></a><span class="lineno"> 7145</span> <span class="comment">// not start with '0', 'f', or 'F'.</span></div><div class="line"><a name="l07146"></a><span class="lineno"> 7146</span> <span class="comment">//</span></div><div class="line"><a name="l07147"></a><span class="lineno"> 7147</span> <span class="comment">// In the latter case, the value is taken as true.</span></div><div class="line"><a name="l07148"></a><span class="lineno"> 7148</span> <span class="comment">//</span></div><div class="line"><a name="l07149"></a><span class="lineno"> 7149</span> <span class="comment">// On success, stores the value of the flag in *value, and returns</span></div><div class="line"><a name="l07150"></a><span class="lineno"> 7150</span> <span class="comment">// true. On failure, returns false without changing *value.</span></div><div class="line"><a name="l07151"></a><span class="lineno"> 7151</span> <span class="keyword">static</span> <span class="keywordtype">bool</span> ParseBoolFlag(<span class="keyword">const</span> <span class="keywordtype">char</span>* str, <span class="keyword">const</span> <span class="keywordtype">char</span>* flag, <span class="keywordtype">bool</span>* value) {</div><div class="line"><a name="l07152"></a><span class="lineno"> 7152</span>  <span class="comment">// Gets the value of the flag as a string.</span></div><div class="line"><a name="l07153"></a><span class="lineno"> 7153</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> value_str = ParseFlagValue(str, flag, <span class="keyword">true</span>);</div><div class="line"><a name="l07154"></a><span class="lineno"> 7154</span> </div><div class="line"><a name="l07155"></a><span class="lineno"> 7155</span>  <span class="comment">// Aborts if the parsing failed.</span></div><div class="line"><a name="l07156"></a><span class="lineno"> 7156</span>  <span class="keywordflow">if</span> (value_str == <span class="keyword">nullptr</span>) <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l07157"></a><span class="lineno"> 7157</span> </div><div class="line"><a name="l07158"></a><span class="lineno"> 7158</span>  <span class="comment">// Converts the string value to a bool.</span></div><div class="line"><a name="l07159"></a><span class="lineno"> 7159</span>  *value = !(*value_str == <span class="charliteral">'0'</span> || *value_str == <span class="charliteral">'f'</span> || *value_str == <span class="charliteral">'F'</span>);</div><div class="line"><a name="l07160"></a><span class="lineno"> 7160</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l07161"></a><span class="lineno"> 7161</span> }</div><div class="line"><a name="l07162"></a><span class="lineno"> 7162</span> </div><div class="line"><a name="l07163"></a><span class="lineno"> 7163</span> <span class="comment">// Parses a string for an Int32 flag, in the form of</span></div><div class="line"><a name="l07164"></a><span class="lineno"> 7164</span> <span class="comment">// "--flag=value".</span></div><div class="line"><a name="l07165"></a><span class="lineno"> 7165</span> <span class="comment">//</span></div><div class="line"><a name="l07166"></a><span class="lineno"> 7166</span> <span class="comment">// On success, stores the value of the flag in *value, and returns</span></div><div class="line"><a name="l07167"></a><span class="lineno"> 7167</span> <span class="comment">// true. On failure, returns false without changing *value.</span></div><div class="line"><a name="l07168"></a><span class="lineno"> 7168</span> <span class="keywordtype">bool</span> ParseInt32Flag(<span class="keyword">const</span> <span class="keywordtype">char</span>* str, <span class="keyword">const</span> <span class="keywordtype">char</span>* flag, <a class="code" href="namespacetesting_1_1internal.html#a8ee38faaf875f133358abaf9bc056cec">Int32</a>* value) {</div><div class="line"><a name="l07169"></a><span class="lineno"> 7169</span>  <span class="comment">// Gets the value of the flag as a string.</span></div><div class="line"><a name="l07170"></a><span class="lineno"> 7170</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> value_str = ParseFlagValue(str, flag, <span class="keyword">false</span>);</div><div class="line"><a name="l07171"></a><span class="lineno"> 7171</span> </div><div class="line"><a name="l07172"></a><span class="lineno"> 7172</span>  <span class="comment">// Aborts if the parsing failed.</span></div><div class="line"><a name="l07173"></a><span class="lineno"> 7173</span>  <span class="keywordflow">if</span> (value_str == <span class="keyword">nullptr</span>) <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l07174"></a><span class="lineno"> 7174</span> </div><div class="line"><a name="l07175"></a><span class="lineno"> 7175</span>  <span class="comment">// Sets *value to the value of the flag.</span></div><div class="line"><a name="l07176"></a><span class="lineno"> 7176</span>  <span class="keywordflow">return</span> <a class="code" href="namespacetesting_1_1internal.html#ac06fc81336a3d80755f4020d34321766">ParseInt32</a>(Message() << <span class="stringliteral">"The value of flag --"</span> << flag,</div><div class="line"><a name="l07177"></a><span class="lineno"> 7177</span>  value_str, value);</div><div class="line"><a name="l07178"></a><span class="lineno"> 7178</span> }</div><div class="line"><a name="l07179"></a><span class="lineno"> 7179</span> </div><div class="line"><a name="l07180"></a><span class="lineno"> 7180</span> <span class="comment">// Parses a string for a string flag, in the form of</span></div><div class="line"><a name="l07181"></a><span class="lineno"> 7181</span> <span class="comment">// "--flag=value".</span></div><div class="line"><a name="l07182"></a><span class="lineno"> 7182</span> <span class="comment">//</span></div><div class="line"><a name="l07183"></a><span class="lineno"> 7183</span> <span class="comment">// On success, stores the value of the flag in *value, and returns</span></div><div class="line"><a name="l07184"></a><span class="lineno"> 7184</span> <span class="comment">// true. On failure, returns false without changing *value.</span></div><div class="line"><a name="l07185"></a><span class="lineno"> 7185</span> <span class="keyword">template</span> <<span class="keyword">typename</span> String></div><div class="line"><a name="l07186"></a><span class="lineno"> 7186</span> <span class="keyword">static</span> <span class="keywordtype">bool</span> ParseStringFlag(<span class="keyword">const</span> <span class="keywordtype">char</span>* str, <span class="keyword">const</span> <span class="keywordtype">char</span>* flag, String* value) {</div><div class="line"><a name="l07187"></a><span class="lineno"> 7187</span>  <span class="comment">// Gets the value of the flag as a string.</span></div><div class="line"><a name="l07188"></a><span class="lineno"> 7188</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> value_str = ParseFlagValue(str, flag, <span class="keyword">false</span>);</div><div class="line"><a name="l07189"></a><span class="lineno"> 7189</span> </div><div class="line"><a name="l07190"></a><span class="lineno"> 7190</span>  <span class="comment">// Aborts if the parsing failed.</span></div><div class="line"><a name="l07191"></a><span class="lineno"> 7191</span>  <span class="keywordflow">if</span> (value_str == <span class="keyword">nullptr</span>) <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l07192"></a><span class="lineno"> 7192</span> </div><div class="line"><a name="l07193"></a><span class="lineno"> 7193</span>  <span class="comment">// Sets *value to the value of the flag.</span></div><div class="line"><a name="l07194"></a><span class="lineno"> 7194</span>  *value = value_str;</div><div class="line"><a name="l07195"></a><span class="lineno"> 7195</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l07196"></a><span class="lineno"> 7196</span> }</div><div class="line"><a name="l07197"></a><span class="lineno"> 7197</span> </div><div class="line"><a name="l07198"></a><span class="lineno"> 7198</span> <span class="comment">// Determines whether a string has a prefix that Google Test uses for its</span></div><div class="line"><a name="l07199"></a><span class="lineno"> 7199</span> <span class="comment">// flags, i.e., starts with GTEST_FLAG_PREFIX_ or GTEST_FLAG_PREFIX_DASH_.</span></div><div class="line"><a name="l07200"></a><span class="lineno"> 7200</span> <span class="comment">// If Google Test detects that a command line flag has its prefix but is not</span></div><div class="line"><a name="l07201"></a><span class="lineno"> 7201</span> <span class="comment">// recognized, it will print its help message. Flags starting with</span></div><div class="line"><a name="l07202"></a><span class="lineno"> 7202</span> <span class="comment">// GTEST_INTERNAL_PREFIX_ followed by "internal_" are considered Google Test</span></div><div class="line"><a name="l07203"></a><span class="lineno"> 7203</span> <span class="comment">// internal flags and do not trigger the help message.</span></div><div class="line"><a name="l07204"></a><span class="lineno"> 7204</span> <span class="keyword">static</span> <span class="keywordtype">bool</span> HasGoogleTestFlagPrefix(<span class="keyword">const</span> <span class="keywordtype">char</span>* str) {</div><div class="line"><a name="l07205"></a><span class="lineno"> 7205</span>  <span class="keywordflow">return</span> (<a class="code" href="namespacetesting_1_1internal.html#aac72b20299ad4a99554ce161e1769560">SkipPrefix</a>(<span class="stringliteral">"--"</span>, &str) ||</div><div class="line"><a name="l07206"></a><span class="lineno"> 7206</span>  <a class="code" href="namespacetesting_1_1internal.html#aac72b20299ad4a99554ce161e1769560">SkipPrefix</a>(<span class="stringliteral">"-"</span>, &str) ||</div><div class="line"><a name="l07207"></a><span class="lineno"> 7207</span>  <a class="code" href="namespacetesting_1_1internal.html#aac72b20299ad4a99554ce161e1769560">SkipPrefix</a>(<span class="stringliteral">"/"</span>, &str)) &&</div><div class="line"><a name="l07208"></a><span class="lineno"> 7208</span>  !<a class="code" href="namespacetesting_1_1internal.html#aac72b20299ad4a99554ce161e1769560">SkipPrefix</a>(<a class="code" href="gtest_8h.html#a088e84784c589ba9b1fc48602ad8eabf">GTEST_FLAG_PREFIX_</a> <span class="stringliteral">"internal_"</span>, &str) &&</div><div class="line"><a name="l07209"></a><span class="lineno"> 7209</span>  (<a class="code" href="namespacetesting_1_1internal.html#aac72b20299ad4a99554ce161e1769560">SkipPrefix</a>(<a class="code" href="gtest_8h.html#a088e84784c589ba9b1fc48602ad8eabf">GTEST_FLAG_PREFIX_</a>, &str) ||</div><div class="line"><a name="l07210"></a><span class="lineno"> 7210</span>  <a class="code" href="namespacetesting_1_1internal.html#aac72b20299ad4a99554ce161e1769560">SkipPrefix</a>(<a class="code" href="gtest_8h.html#a4251ff898f9f94ec6b8b9402c3436759">GTEST_FLAG_PREFIX_DASH_</a>, &str));</div><div class="line"><a name="l07211"></a><span class="lineno"> 7211</span> }</div><div class="line"><a name="l07212"></a><span class="lineno"> 7212</span> </div><div class="line"><a name="l07213"></a><span class="lineno"> 7213</span> <span class="comment">// Prints a string containing code-encoded text. The following escape</span></div><div class="line"><a name="l07214"></a><span class="lineno"> 7214</span> <span class="comment">// sequences can be used in the string to control the text color:</span></div><div class="line"><a name="l07215"></a><span class="lineno"> 7215</span> <span class="comment">//</span></div><div class="line"><a name="l07216"></a><span class="lineno"> 7216</span> <span class="comment">// @@ prints a single '@' character.</span></div><div class="line"><a name="l07217"></a><span class="lineno"> 7217</span> <span class="comment">// @R changes the color to red.</span></div><div class="line"><a name="l07218"></a><span class="lineno"> 7218</span> <span class="comment">// @G changes the color to green.</span></div><div class="line"><a name="l07219"></a><span class="lineno"> 7219</span> <span class="comment">// @Y changes the color to yellow.</span></div><div class="line"><a name="l07220"></a><span class="lineno"> 7220</span> <span class="comment">// @D changes to the default terminal text color.</span></div><div class="line"><a name="l07221"></a><span class="lineno"> 7221</span> <span class="comment">//</span></div><div class="line"><a name="l07222"></a><span class="lineno"> 7222</span> <span class="keyword">static</span> <span class="keywordtype">void</span> PrintColorEncoded(<span class="keyword">const</span> <span class="keywordtype">char</span>* str) {</div><div class="line"><a name="l07223"></a><span class="lineno"> 7223</span>  <a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4e">GTestColor</a> color = <a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4eafcd8803dc9e37e374d5a4486afc230b7">COLOR_DEFAULT</a>; <span class="comment">// The current color.</span></div><div class="line"><a name="l07224"></a><span class="lineno"> 7224</span> </div><div class="line"><a name="l07225"></a><span class="lineno"> 7225</span>  <span class="comment">// Conceptually, we split the string into segments divided by escape</span></div><div class="line"><a name="l07226"></a><span class="lineno"> 7226</span>  <span class="comment">// sequences. Then we print one segment at a time. At the end of</span></div><div class="line"><a name="l07227"></a><span class="lineno"> 7227</span>  <span class="comment">// each iteration, the str pointer advances to the beginning of the</span></div><div class="line"><a name="l07228"></a><span class="lineno"> 7228</span>  <span class="comment">// next segment.</span></div><div class="line"><a name="l07229"></a><span class="lineno"> 7229</span>  <span class="keywordflow">for</span> (;;) {</div><div class="line"><a name="l07230"></a><span class="lineno"> 7230</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* p = strchr(str, <span class="charliteral">'@'</span>);</div><div class="line"><a name="l07231"></a><span class="lineno"> 7231</span>  <span class="keywordflow">if</span> (p == <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l07232"></a><span class="lineno"> 7232</span>  ColoredPrintf(color, <span class="stringliteral">"%s"</span>, str);</div><div class="line"><a name="l07233"></a><span class="lineno"> 7233</span>  <span class="keywordflow">return</span>;</div><div class="line"><a name="l07234"></a><span class="lineno"> 7234</span>  }</div><div class="line"><a name="l07235"></a><span class="lineno"> 7235</span> </div><div class="line"><a name="l07236"></a><span class="lineno"> 7236</span>  ColoredPrintf(color, <span class="stringliteral">"%s"</span>, <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(str, p).c_str());</div><div class="line"><a name="l07237"></a><span class="lineno"> 7237</span> </div><div class="line"><a name="l07238"></a><span class="lineno"> 7238</span>  <span class="keyword">const</span> <span class="keywordtype">char</span> ch = p[1];</div><div class="line"><a name="l07239"></a><span class="lineno"> 7239</span>  str = p + 2;</div><div class="line"><a name="l07240"></a><span class="lineno"> 7240</span>  <span class="keywordflow">if</span> (ch == <span class="charliteral">'@'</span>) {</div><div class="line"><a name="l07241"></a><span class="lineno"> 7241</span>  ColoredPrintf(color, <span class="stringliteral">"@"</span>);</div><div class="line"><a name="l07242"></a><span class="lineno"> 7242</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ch == <span class="charliteral">'D'</span>) {</div><div class="line"><a name="l07243"></a><span class="lineno"> 7243</span>  color = <a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4eafcd8803dc9e37e374d5a4486afc230b7">COLOR_DEFAULT</a>;</div><div class="line"><a name="l07244"></a><span class="lineno"> 7244</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ch == <span class="charliteral">'R'</span>) {</div><div class="line"><a name="l07245"></a><span class="lineno"> 7245</span>  color = <a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea9ebb3ddab9391781f6ee5021e1e443c3">COLOR_RED</a>;</div><div class="line"><a name="l07246"></a><span class="lineno"> 7246</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ch == <span class="charliteral">'G'</span>) {</div><div class="line"><a name="l07247"></a><span class="lineno"> 7247</span>  color = <a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea3b1e81f5b14a17b35a8672d57d166507">COLOR_GREEN</a>;</div><div class="line"><a name="l07248"></a><span class="lineno"> 7248</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ch == <span class="charliteral">'Y'</span>) {</div><div class="line"><a name="l07249"></a><span class="lineno"> 7249</span>  color = <a class="code" href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea2cca441161aca75a208ff08d07f5b1a5">COLOR_YELLOW</a>;</div><div class="line"><a name="l07250"></a><span class="lineno"> 7250</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l07251"></a><span class="lineno"> 7251</span>  --str;</div><div class="line"><a name="l07252"></a><span class="lineno"> 7252</span>  }</div><div class="line"><a name="l07253"></a><span class="lineno"> 7253</span>  }</div><div class="line"><a name="l07254"></a><span class="lineno"> 7254</span> }</div><div class="line"><a name="l07255"></a><span class="lineno"> 7255</span> </div><div class="line"><a name="l07256"></a><span class="lineno"> 7256</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kColorEncodedHelpMessage[] =</div><div class="line"><a name="l07257"></a><span class="lineno"> 7257</span> <span class="stringliteral">"This program contains tests written using "</span> <a class="code" href="gtest_8h.html#a13d98c217176bd8722c395b9225fc19d">GTEST_NAME_</a> <span class="stringliteral">". You can use the\n"</span></div><div class="line"><a name="l07258"></a><span class="lineno"> 7258</span> <span class="stringliteral">"following command line flags to control its behavior:\n"</span></div><div class="line"><a name="l07259"></a><span class="lineno"> 7259</span> <span class="stringliteral">"\n"</span></div><div class="line"><a name="l07260"></a><span class="lineno"> 7260</span> <span class="stringliteral">"Test Selection:\n"</span></div><div class="line"><a name="l07261"></a><span class="lineno"> 7261</span> <span class="stringliteral">" @G--"</span> <a class="code" href="gtest_8h.html#a088e84784c589ba9b1fc48602ad8eabf">GTEST_FLAG_PREFIX_</a> <span class="stringliteral">"list_tests@D\n"</span></div><div class="line"><a name="l07262"></a><span class="lineno"> 7262</span> <span class="stringliteral">" List the names of all tests instead of running them. The name of\n"</span></div><div class="line"><a name="l07263"></a><span class="lineno"> 7263</span> <span class="stringliteral">" TEST(Foo, Bar) is \"Foo.Bar\".\n"</span></div><div class="line"><a name="l07264"></a><span class="lineno"> 7264</span> <span class="stringliteral">" @G--"</span> <a class="code" href="gtest_8h.html#a088e84784c589ba9b1fc48602ad8eabf">GTEST_FLAG_PREFIX_</a> <span class="stringliteral">"filter=@YPOSTIVE_PATTERNS"</span></div><div class="line"><a name="l07265"></a><span class="lineno"> 7265</span>  <span class="stringliteral">"[@G-@YNEGATIVE_PATTERNS]@D\n"</span></div><div class="line"><a name="l07266"></a><span class="lineno"> 7266</span> <span class="stringliteral">" Run only the tests whose name matches one of the positive patterns but\n"</span></div><div class="line"><a name="l07267"></a><span class="lineno"> 7267</span> <span class="stringliteral">" none of the negative patterns. '?' matches any single character; '*'\n"</span></div><div class="line"><a name="l07268"></a><span class="lineno"> 7268</span> <span class="stringliteral">" matches any substring; ':' separates two patterns.\n"</span></div><div class="line"><a name="l07269"></a><span class="lineno"> 7269</span> <span class="stringliteral">" @G--"</span> <a class="code" href="gtest_8h.html#a088e84784c589ba9b1fc48602ad8eabf">GTEST_FLAG_PREFIX_</a> <span class="stringliteral">"also_run_disabled_tests@D\n"</span></div><div class="line"><a name="l07270"></a><span class="lineno"> 7270</span> <span class="stringliteral">" Run all disabled tests too.\n"</span></div><div class="line"><a name="l07271"></a><span class="lineno"> 7271</span> <span class="stringliteral">"\n"</span></div><div class="line"><a name="l07272"></a><span class="lineno"> 7272</span> <span class="stringliteral">"Test Execution:\n"</span></div><div class="line"><a name="l07273"></a><span class="lineno"> 7273</span> <span class="stringliteral">" @G--"</span> <a class="code" href="gtest_8h.html#a088e84784c589ba9b1fc48602ad8eabf">GTEST_FLAG_PREFIX_</a> <span class="stringliteral">"repeat=@Y[COUNT]@D\n"</span></div><div class="line"><a name="l07274"></a><span class="lineno"> 7274</span> <span class="stringliteral">" Run the tests repeatedly; use a negative count to repeat forever.\n"</span></div><div class="line"><a name="l07275"></a><span class="lineno"> 7275</span> <span class="stringliteral">" @G--"</span> <a class="code" href="gtest_8h.html#a088e84784c589ba9b1fc48602ad8eabf">GTEST_FLAG_PREFIX_</a> <span class="stringliteral">"shuffle@D\n"</span></div><div class="line"><a name="l07276"></a><span class="lineno"> 7276</span> <span class="stringliteral">" Randomize tests' orders on every iteration.\n"</span></div><div class="line"><a name="l07277"></a><span class="lineno"> 7277</span> <span class="stringliteral">" @G--"</span> <a class="code" href="gtest_8h.html#a088e84784c589ba9b1fc48602ad8eabf">GTEST_FLAG_PREFIX_</a> <span class="stringliteral">"random_seed=@Y[NUMBER]@D\n"</span></div><div class="line"><a name="l07278"></a><span class="lineno"> 7278</span> <span class="stringliteral">" Random number seed to use for shuffling test orders (between 1 and\n"</span></div><div class="line"><a name="l07279"></a><span class="lineno"> 7279</span> <span class="stringliteral">" 99999, or 0 to use a seed based on the current time).\n"</span></div><div class="line"><a name="l07280"></a><span class="lineno"> 7280</span> <span class="stringliteral">"\n"</span></div><div class="line"><a name="l07281"></a><span class="lineno"> 7281</span> <span class="stringliteral">"Test Output:\n"</span></div><div class="line"><a name="l07282"></a><span class="lineno"> 7282</span> <span class="stringliteral">" @G--"</span> <a class="code" href="gtest_8h.html#a088e84784c589ba9b1fc48602ad8eabf">GTEST_FLAG_PREFIX_</a> <span class="stringliteral">"color=@Y(@Gyes@Y|@Gno@Y|@Gauto@Y)@D\n"</span></div><div class="line"><a name="l07283"></a><span class="lineno"> 7283</span> <span class="stringliteral">" Enable/disable colored output. The default is @Gauto@D.\n"</span></div><div class="line"><a name="l07284"></a><span class="lineno"> 7284</span> <span class="stringliteral">" -@G-"</span> <a class="code" href="gtest_8h.html#a088e84784c589ba9b1fc48602ad8eabf">GTEST_FLAG_PREFIX_</a> <span class="stringliteral">"print_time=0@D\n"</span></div><div class="line"><a name="l07285"></a><span class="lineno"> 7285</span> <span class="stringliteral">" Don't print the elapsed time of each test.\n"</span></div><div class="line"><a name="l07286"></a><span class="lineno"> 7286</span> <span class="stringliteral">" @G--"</span> <a class="code" href="gtest_8h.html#a088e84784c589ba9b1fc48602ad8eabf">GTEST_FLAG_PREFIX_</a> <span class="stringliteral">"output=@Y(@Gjson@Y|@Gxml@Y)[@G:@YDIRECTORY_PATH@G"</span></div><div class="line"><a name="l07287"></a><span class="lineno"> 7287</span>  <a class="code" href="gtest_8h.html#afbb636e91bdd50267dbef11a50490b29">GTEST_PATH_SEP_</a> <span class="stringliteral">"@Y|@G:@YFILE_PATH]@D\n"</span></div><div class="line"><a name="l07288"></a><span class="lineno"> 7288</span> <span class="stringliteral">" Generate a JSON or XML report in the given directory or with the given\n"</span></div><div class="line"><a name="l07289"></a><span class="lineno"> 7289</span> <span class="stringliteral">" file name. @YFILE_PATH@D defaults to @Gtest_detail.xml@D.\n"</span></div><div class="line"><a name="l07290"></a><span class="lineno"> 7290</span> <span class="preprocessor"># if GTEST_CAN_STREAM_RESULTS_</span></div><div class="line"><a name="l07291"></a><span class="lineno"> 7291</span> <span class="stringliteral">" @G--"</span> <a class="code" href="gtest_8h.html#a088e84784c589ba9b1fc48602ad8eabf">GTEST_FLAG_PREFIX_</a> <span class="stringliteral">"stream_result_to=@YHOST@G:@YPORT@D\n"</span></div><div class="line"><a name="l07292"></a><span class="lineno"> 7292</span> <span class="stringliteral">" Stream test results to the given server.\n"</span></div><div class="line"><a name="l07293"></a><span class="lineno"> 7293</span> <span class="preprocessor"># endif // GTEST_CAN_STREAM_RESULTS_</span></div><div class="line"><a name="l07294"></a><span class="lineno"> 7294</span> <span class="stringliteral">"\n"</span></div><div class="line"><a name="l07295"></a><span class="lineno"> 7295</span> <span class="stringliteral">"Assertion Behavior:\n"</span></div><div class="line"><a name="l07296"></a><span class="lineno"> 7296</span> <span class="preprocessor"># if GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS</span></div><div class="line"><a name="l07297"></a><span class="lineno"> 7297</span> <span class="stringliteral">" @G--"</span> <a class="code" href="gtest_8h.html#a088e84784c589ba9b1fc48602ad8eabf">GTEST_FLAG_PREFIX_</a> <span class="stringliteral">"death_test_style=@Y(@Gfast@Y|@Gthreadsafe@Y)@D\n"</span></div><div class="line"><a name="l07298"></a><span class="lineno"> 7298</span> <span class="stringliteral">" Set the default death test style.\n"</span></div><div class="line"><a name="l07299"></a><span class="lineno"> 7299</span> <span class="preprocessor"># endif // GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS</span></div><div class="line"><a name="l07300"></a><span class="lineno"> 7300</span> <span class="stringliteral">" @G--"</span> <a class="code" href="gtest_8h.html#a088e84784c589ba9b1fc48602ad8eabf">GTEST_FLAG_PREFIX_</a> <span class="stringliteral">"break_on_failure@D\n"</span></div><div class="line"><a name="l07301"></a><span class="lineno"> 7301</span> <span class="stringliteral">" Turn assertion failures into debugger break-points.\n"</span></div><div class="line"><a name="l07302"></a><span class="lineno"> 7302</span> <span class="stringliteral">" @G--"</span> <a class="code" href="gtest_8h.html#a088e84784c589ba9b1fc48602ad8eabf">GTEST_FLAG_PREFIX_</a> <span class="stringliteral">"throw_on_failure@D\n"</span></div><div class="line"><a name="l07303"></a><span class="lineno"> 7303</span> <span class="stringliteral">" Turn assertion failures into C++ exceptions for use by an external\n"</span></div><div class="line"><a name="l07304"></a><span class="lineno"> 7304</span> <span class="stringliteral">" test framework.\n"</span></div><div class="line"><a name="l07305"></a><span class="lineno"> 7305</span> <span class="stringliteral">" @G--"</span> <a class="code" href="gtest_8h.html#a088e84784c589ba9b1fc48602ad8eabf">GTEST_FLAG_PREFIX_</a> <span class="stringliteral">"catch_exceptions=0@D\n"</span></div><div class="line"><a name="l07306"></a><span class="lineno"> 7306</span> <span class="stringliteral">" Do not report exceptions as test failures. Instead, allow them\n"</span></div><div class="line"><a name="l07307"></a><span class="lineno"> 7307</span> <span class="stringliteral">" to crash the program or throw a pop-up (on Windows).\n"</span></div><div class="line"><a name="l07308"></a><span class="lineno"> 7308</span> <span class="stringliteral">"\n"</span></div><div class="line"><a name="l07309"></a><span class="lineno"> 7309</span> <span class="stringliteral">"Except for @G--"</span> <a class="code" href="gtest_8h.html#a088e84784c589ba9b1fc48602ad8eabf">GTEST_FLAG_PREFIX_</a> <span class="stringliteral">"list_tests@D, you can alternatively set "</span></div><div class="line"><a name="l07310"></a><span class="lineno"> 7310</span>  <span class="stringliteral">"the corresponding\n"</span></div><div class="line"><a name="l07311"></a><span class="lineno"> 7311</span> <span class="stringliteral">"environment variable of a flag (all letters in upper-case). For example, to\n"</span></div><div class="line"><a name="l07312"></a><span class="lineno"> 7312</span> <span class="stringliteral">"disable colored text output, you can either specify @G--"</span> <a class="code" href="gtest_8h.html#a088e84784c589ba9b1fc48602ad8eabf">GTEST_FLAG_PREFIX_</a></div><div class="line"><a name="l07313"></a><span class="lineno"> 7313</span>  <span class="stringliteral">"color=no@D or set\n"</span></div><div class="line"><a name="l07314"></a><span class="lineno"> 7314</span> <span class="stringliteral">"the @G"</span> <a class="code" href="gtest_8h.html#a4018b7f288f974d022df397e2730633a">GTEST_FLAG_PREFIX_UPPER_</a> <span class="stringliteral">"COLOR@D environment variable to @Gno@D.\n"</span></div><div class="line"><a name="l07315"></a><span class="lineno"> 7315</span> <span class="stringliteral">"\n"</span></div><div class="line"><a name="l07316"></a><span class="lineno"> 7316</span> <span class="stringliteral">"For more information, please read the "</span> <a class="code" href="gtest_8h.html#a13d98c217176bd8722c395b9225fc19d">GTEST_NAME_</a> <span class="stringliteral">" documentation at\n"</span></div><div class="line"><a name="l07317"></a><span class="lineno"> 7317</span> <span class="stringliteral">"@G"</span> <a class="code" href="gtest_8h.html#a5aa3c938fc1d049f1d9c5332f6a0b1d4">GTEST_PROJECT_URL_</a> <span class="stringliteral">"@D. If you find a bug in "</span> <a class="code" href="gtest_8h.html#a13d98c217176bd8722c395b9225fc19d">GTEST_NAME_</a> <span class="stringliteral">"\n"</span></div><div class="line"><a name="l07318"></a><span class="lineno"> 7318</span> <span class="stringliteral">"(not one in your own code or tests), please report it to\n"</span></div><div class="line"><a name="l07319"></a><span class="lineno"> 7319</span> <span class="stringliteral">"@G<"</span> <a class="code" href="gtest_8h.html#a21086d276b1a64d6763ee8a94b12c1b8">GTEST_DEV_EMAIL_</a> <span class="stringliteral">">@D.\n"</span>;</div><div class="line"><a name="l07320"></a><span class="lineno"> 7320</span> </div><div class="line"><a name="l07321"></a><span class="lineno"> 7321</span> <span class="keyword">static</span> <span class="keywordtype">bool</span> ParseGoogleTestFlag(<span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> arg) {</div><div class="line"><a name="l07322"></a><span class="lineno"> 7322</span>  <span class="keywordflow">return</span> ParseBoolFlag(arg, kAlsoRunDisabledTestsFlag,</div><div class="line"><a name="l07323"></a><span class="lineno"> 7323</span>  &<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(also_run_disabled_tests)) ||</div><div class="line"><a name="l07324"></a><span class="lineno"> 7324</span>  ParseBoolFlag(arg, kBreakOnFailureFlag,</div><div class="line"><a name="l07325"></a><span class="lineno"> 7325</span>  &<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(break_on_failure)) ||</div><div class="line"><a name="l07326"></a><span class="lineno"> 7326</span>  ParseBoolFlag(arg, kCatchExceptionsFlag,</div><div class="line"><a name="l07327"></a><span class="lineno"> 7327</span>  &<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(catch_exceptions)) ||</div><div class="line"><a name="l07328"></a><span class="lineno"> 7328</span>  ParseStringFlag(arg, kColorFlag, &<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(color)) ||</div><div class="line"><a name="l07329"></a><span class="lineno"> 7329</span>  ParseStringFlag(arg, kDeathTestStyleFlag,</div><div class="line"><a name="l07330"></a><span class="lineno"> 7330</span>  &<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(death_test_style)) ||</div><div class="line"><a name="l07331"></a><span class="lineno"> 7331</span>  ParseBoolFlag(arg, kDeathTestUseFork,</div><div class="line"><a name="l07332"></a><span class="lineno"> 7332</span>  &<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(death_test_use_fork)) ||</div><div class="line"><a name="l07333"></a><span class="lineno"> 7333</span>  ParseStringFlag(arg, kFilterFlag, &<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(<a class="code" href="namespaceutl_1_1meta.html#ac72acc616316c322e750d20a46553ba4">filter</a>)) ||</div><div class="line"><a name="l07334"></a><span class="lineno"> 7334</span>  ParseStringFlag(arg, kInternalRunDeathTestFlag,</div><div class="line"><a name="l07335"></a><span class="lineno"> 7335</span>  &<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(internal_run_death_test)) ||</div><div class="line"><a name="l07336"></a><span class="lineno"> 7336</span>  ParseBoolFlag(arg, kListTestsFlag, &<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(list_tests)) ||</div><div class="line"><a name="l07337"></a><span class="lineno"> 7337</span>  ParseStringFlag(arg, kOutputFlag, &<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(output)) ||</div><div class="line"><a name="l07338"></a><span class="lineno"> 7338</span>  ParseBoolFlag(arg, kPrintTimeFlag, &<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(print_time)) ||</div><div class="line"><a name="l07339"></a><span class="lineno"> 7339</span>  ParseBoolFlag(arg, kPrintUTF8Flag, &<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(print_utf8)) ||</div><div class="line"><a name="l07340"></a><span class="lineno"> 7340</span>  ParseInt32Flag(arg, kRandomSeedFlag, &<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(random_seed)) ||</div><div class="line"><a name="l07341"></a><span class="lineno"> 7341</span>  ParseInt32Flag(arg, kRepeatFlag, &<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(<a class="code" href="namespaceutl_1_1meta.html#aa013c45afb59b5c132a72be54ba145fb">repeat</a>)) ||</div><div class="line"><a name="l07342"></a><span class="lineno"> 7342</span>  ParseBoolFlag(arg, kShuffleFlag, &<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(shuffle)) ||</div><div class="line"><a name="l07343"></a><span class="lineno"> 7343</span>  ParseInt32Flag(arg, kStackTraceDepthFlag,</div><div class="line"><a name="l07344"></a><span class="lineno"> 7344</span>  &<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(stack_trace_depth)) ||</div><div class="line"><a name="l07345"></a><span class="lineno"> 7345</span>  ParseStringFlag(arg, kStreamResultToFlag,</div><div class="line"><a name="l07346"></a><span class="lineno"> 7346</span>  &<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(stream_result_to)) ||</div><div class="line"><a name="l07347"></a><span class="lineno"> 7347</span>  ParseBoolFlag(arg, kThrowOnFailureFlag,</div><div class="line"><a name="l07348"></a><span class="lineno"> 7348</span>  &<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(throw_on_failure));</div><div class="line"><a name="l07349"></a><span class="lineno"> 7349</span> }</div><div class="line"><a name="l07350"></a><span class="lineno"> 7350</span> </div><div class="line"><a name="l07351"></a><span class="lineno"> 7351</span> <span class="preprocessor">#if GTEST_USE_OWN_FLAGFILE_FLAG_</span></div><div class="line"><a name="l07352"></a><span class="lineno"> 7352</span> <span class="keyword">static</span> <span class="keywordtype">void</span> LoadFlagsFromFile(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& path) {</div><div class="line"><a name="l07353"></a><span class="lineno"> 7353</span>  FILE* flagfile = <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a4042201dcc4932641d484e7ddf94de7d">posix::FOpen</a>(path.c_str(), <span class="stringliteral">"r"</span>);</div><div class="line"><a name="l07354"></a><span class="lineno"> 7354</span>  <span class="keywordflow">if</span> (!flagfile) {</div><div class="line"><a name="l07355"></a><span class="lineno"> 7355</span>  <a class="code" href="gtest_8h.html#a8ef4cb4c465db8c15464aecc6d9510ef">GTEST_LOG_</a>(FATAL) << <span class="stringliteral">"Unable to open file \""</span> << <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(flagfile)</div><div class="line"><a name="l07356"></a><span class="lineno"> 7356</span>  << <span class="stringliteral">"\""</span>;</div><div class="line"><a name="l07357"></a><span class="lineno"> 7357</span>  }</div><div class="line"><a name="l07358"></a><span class="lineno"> 7358</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> contents(<a class="code" href="namespacetesting_1_1internal.html#ab81b0af2a0131ea54dc11de00d5e6e51">ReadEntireFile</a>(flagfile));</div><div class="line"><a name="l07359"></a><span class="lineno"> 7359</span>  <a class="code" href="namespacetesting_1_1internal_1_1posix.html#af4beeaaa8d62916d5e3b644a1ddfbd6b">posix::FClose</a>(flagfile);</div><div class="line"><a name="l07360"></a><span class="lineno"> 7360</span>  std::vector<std::string> lines;</div><div class="line"><a name="l07361"></a><span class="lineno"> 7361</span>  SplitString(contents, <span class="charliteral">'\n'</span>, &lines);</div><div class="line"><a name="l07362"></a><span class="lineno"> 7362</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i < lines.size(); ++i) {</div><div class="line"><a name="l07363"></a><span class="lineno"> 7363</span>  <span class="keywordflow">if</span> (lines[i].<a class="code" href="namespaceutl_1_1meta.html#a58c1744750d0df133034f60a95f87e19">empty</a>())</div><div class="line"><a name="l07364"></a><span class="lineno"> 7364</span>  <span class="keywordflow">continue</span>;</div><div class="line"><a name="l07365"></a><span class="lineno"> 7365</span>  <span class="keywordflow">if</span> (!ParseGoogleTestFlag(lines[i].c_str()))</div><div class="line"><a name="l07366"></a><span class="lineno"> 7366</span>  g_help_flag = <span class="keyword">true</span>;</div><div class="line"><a name="l07367"></a><span class="lineno"> 7367</span>  }</div><div class="line"><a name="l07368"></a><span class="lineno"> 7368</span> }</div><div class="line"><a name="l07369"></a><span class="lineno"> 7369</span> <span class="preprocessor">#endif // GTEST_USE_OWN_FLAGFILE_FLAG_</span></div><div class="line"><a name="l07370"></a><span class="lineno"> 7370</span> </div><div class="line"><a name="l07371"></a><span class="lineno"> 7371</span> <span class="comment">// Parses the command line for Google Test flags, without initializing</span></div><div class="line"><a name="l07372"></a><span class="lineno"> 7372</span> <span class="comment">// other parts of Google Test. The type parameter CharType can be</span></div><div class="line"><a name="l07373"></a><span class="lineno"> 7373</span> <span class="comment">// instantiated to either char or wchar_t.</span></div><div class="line"><a name="l07374"></a><span class="lineno"> 7374</span> <span class="keyword">template</span> <<span class="keyword">typename</span> CharType></div><div class="line"><a name="l07375"></a><span class="lineno"> 7375</span> <span class="keywordtype">void</span> ParseGoogleTestFlagsOnlyImpl(<span class="keywordtype">int</span>* argc, CharType** argv) {</div><div class="line"><a name="l07376"></a><span class="lineno"> 7376</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 1; i < *argc; i++) {</div><div class="line"><a name="l07377"></a><span class="lineno"> 7377</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> arg_string = <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(argv[i]);</div><div class="line"><a name="l07378"></a><span class="lineno"> 7378</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> arg = arg_string.c_str();</div><div class="line"><a name="l07379"></a><span class="lineno"> 7379</span> </div><div class="line"><a name="l07380"></a><span class="lineno"> 7380</span>  <span class="keyword">using</span> internal::ParseBoolFlag;</div><div class="line"><a name="l07381"></a><span class="lineno"> 7381</span>  <span class="keyword">using</span> internal::ParseInt32Flag;</div><div class="line"><a name="l07382"></a><span class="lineno"> 7382</span>  <span class="keyword">using</span> internal::ParseStringFlag;</div><div class="line"><a name="l07383"></a><span class="lineno"> 7383</span> </div><div class="line"><a name="l07384"></a><span class="lineno"> 7384</span>  <span class="keywordtype">bool</span> remove_flag = <span class="keyword">false</span>;</div><div class="line"><a name="l07385"></a><span class="lineno"> 7385</span>  <span class="keywordflow">if</span> (ParseGoogleTestFlag(arg)) {</div><div class="line"><a name="l07386"></a><span class="lineno"> 7386</span>  remove_flag = <span class="keyword">true</span>;</div><div class="line"><a name="l07387"></a><span class="lineno"> 7387</span> <span class="preprocessor">#if GTEST_USE_OWN_FLAGFILE_FLAG_</span></div><div class="line"><a name="l07388"></a><span class="lineno"> 7388</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ParseStringFlag(arg, kFlagfileFlag, &<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(flagfile))) {</div><div class="line"><a name="l07389"></a><span class="lineno"> 7389</span>  LoadFlagsFromFile(<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(flagfile));</div><div class="line"><a name="l07390"></a><span class="lineno"> 7390</span>  remove_flag = <span class="keyword">true</span>;</div><div class="line"><a name="l07391"></a><span class="lineno"> 7391</span> <span class="preprocessor">#endif // GTEST_USE_OWN_FLAGFILE_FLAG_</span></div><div class="line"><a name="l07392"></a><span class="lineno"> 7392</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (arg_string == <span class="stringliteral">"--help"</span> || arg_string == <span class="stringliteral">"-h"</span> ||</div><div class="line"><a name="l07393"></a><span class="lineno"> 7393</span>  arg_string == <span class="stringliteral">"-?"</span> || arg_string == <span class="stringliteral">"/?"</span> ||</div><div class="line"><a name="l07394"></a><span class="lineno"> 7394</span>  HasGoogleTestFlagPrefix(arg)) {</div><div class="line"><a name="l07395"></a><span class="lineno"> 7395</span>  <span class="comment">// Both help flag and unrecognized Google Test flags (excluding</span></div><div class="line"><a name="l07396"></a><span class="lineno"> 7396</span>  <span class="comment">// internal ones) trigger help display.</span></div><div class="line"><a name="l07397"></a><span class="lineno"> 7397</span>  g_help_flag = <span class="keyword">true</span>;</div><div class="line"><a name="l07398"></a><span class="lineno"> 7398</span>  }</div><div class="line"><a name="l07399"></a><span class="lineno"> 7399</span> </div><div class="line"><a name="l07400"></a><span class="lineno"> 7400</span>  <span class="keywordflow">if</span> (remove_flag) {</div><div class="line"><a name="l07401"></a><span class="lineno"> 7401</span>  <span class="comment">// Shift the remainder of the argv list left by one. Note</span></div><div class="line"><a name="l07402"></a><span class="lineno"> 7402</span>  <span class="comment">// that argv has (*argc + 1) elements, the last one always being</span></div><div class="line"><a name="l07403"></a><span class="lineno"> 7403</span>  <span class="comment">// NULL. The following loop moves the trailing NULL element as</span></div><div class="line"><a name="l07404"></a><span class="lineno"> 7404</span>  <span class="comment">// well.</span></div><div class="line"><a name="l07405"></a><span class="lineno"> 7405</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = i; j != *argc; j++) {</div><div class="line"><a name="l07406"></a><span class="lineno"> 7406</span>  argv[j] = argv[j + 1];</div><div class="line"><a name="l07407"></a><span class="lineno"> 7407</span>  }</div><div class="line"><a name="l07408"></a><span class="lineno"> 7408</span> </div><div class="line"><a name="l07409"></a><span class="lineno"> 7409</span>  <span class="comment">// Decrements the argument count.</span></div><div class="line"><a name="l07410"></a><span class="lineno"> 7410</span>  (*argc)--;</div><div class="line"><a name="l07411"></a><span class="lineno"> 7411</span> </div><div class="line"><a name="l07412"></a><span class="lineno"> 7412</span>  <span class="comment">// We also need to decrement the iterator as we just removed</span></div><div class="line"><a name="l07413"></a><span class="lineno"> 7413</span>  <span class="comment">// an element.</span></div><div class="line"><a name="l07414"></a><span class="lineno"> 7414</span>  i--;</div><div class="line"><a name="l07415"></a><span class="lineno"> 7415</span>  }</div><div class="line"><a name="l07416"></a><span class="lineno"> 7416</span>  }</div><div class="line"><a name="l07417"></a><span class="lineno"> 7417</span> </div><div class="line"><a name="l07418"></a><span class="lineno"> 7418</span>  <span class="keywordflow">if</span> (g_help_flag) {</div><div class="line"><a name="l07419"></a><span class="lineno"> 7419</span>  <span class="comment">// We print the help here instead of in RUN_ALL_TESTS(), as the</span></div><div class="line"><a name="l07420"></a><span class="lineno"> 7420</span>  <span class="comment">// latter may not be called at all if the user is using Google</span></div><div class="line"><a name="l07421"></a><span class="lineno"> 7421</span>  <span class="comment">// Test with another testing framework.</span></div><div class="line"><a name="l07422"></a><span class="lineno"> 7422</span>  PrintColorEncoded(kColorEncodedHelpMessage);</div><div class="line"><a name="l07423"></a><span class="lineno"> 7423</span>  }</div><div class="line"><a name="l07424"></a><span class="lineno"> 7424</span> }</div><div class="line"><a name="l07425"></a><span class="lineno"> 7425</span> </div><div class="line"><a name="l07426"></a><span class="lineno"> 7426</span> <span class="comment">// Parses the command line for Google Test flags, without initializing</span></div><div class="line"><a name="l07427"></a><span class="lineno"> 7427</span> <span class="comment">// other parts of Google Test.</span></div><div class="line"><a name="l07428"></a><span class="lineno"> 7428</span> <span class="keywordtype">void</span> ParseGoogleTestFlagsOnly(<span class="keywordtype">int</span>* argc, <span class="keywordtype">char</span>** argv) {</div><div class="line"><a name="l07429"></a><span class="lineno"> 7429</span>  ParseGoogleTestFlagsOnlyImpl(argc, argv);</div><div class="line"><a name="l07430"></a><span class="lineno"> 7430</span> </div><div class="line"><a name="l07431"></a><span class="lineno"> 7431</span>  <span class="comment">// Fix the value of *_NSGetArgc() on macOS, but iff</span></div><div class="line"><a name="l07432"></a><span class="lineno"> 7432</span>  <span class="comment">// *_NSGetArgv() == argv</span></div><div class="line"><a name="l07433"></a><span class="lineno"> 7433</span>  <span class="comment">// Only applicable to char** version of argv</span></div><div class="line"><a name="l07434"></a><span class="lineno"> 7434</span> <span class="preprocessor">#if GTEST_OS_MAC</span></div><div class="line"><a name="l07435"></a><span class="lineno"> 7435</span> <span class="preprocessor">#ifndef GTEST_OS_IOS</span></div><div class="line"><a name="l07436"></a><span class="lineno"> 7436</span>  <span class="keywordflow">if</span> (*_NSGetArgv() == argv) {</div><div class="line"><a name="l07437"></a><span class="lineno"> 7437</span>  *_NSGetArgc() = *argc;</div><div class="line"><a name="l07438"></a><span class="lineno"> 7438</span>  }</div><div class="line"><a name="l07439"></a><span class="lineno"> 7439</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l07440"></a><span class="lineno"> 7440</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l07441"></a><span class="lineno"> 7441</span> }</div><div class="line"><a name="l07442"></a><span class="lineno"> 7442</span> <span class="keywordtype">void</span> ParseGoogleTestFlagsOnly(<span class="keywordtype">int</span>* argc, <span class="keywordtype">wchar_t</span>** argv) {</div><div class="line"><a name="l07443"></a><span class="lineno"> 7443</span>  ParseGoogleTestFlagsOnlyImpl(argc, argv);</div><div class="line"><a name="l07444"></a><span class="lineno"> 7444</span> }</div><div class="line"><a name="l07445"></a><span class="lineno"> 7445</span> </div><div class="line"><a name="l07446"></a><span class="lineno"> 7446</span> <span class="comment">// The internal implementation of InitGoogleTest().</span></div><div class="line"><a name="l07447"></a><span class="lineno"> 7447</span> <span class="comment">//</span></div><div class="line"><a name="l07448"></a><span class="lineno"> 7448</span> <span class="comment">// The type parameter CharType can be instantiated to either char or</span></div><div class="line"><a name="l07449"></a><span class="lineno"> 7449</span> <span class="comment">// wchar_t.</span></div><div class="line"><a name="l07450"></a><span class="lineno"> 7450</span> <span class="keyword">template</span> <<span class="keyword">typename</span> CharType></div><div class="line"><a name="l07451"></a><span class="lineno"> 7451</span> <span class="keywordtype">void</span> InitGoogleTestImpl(<span class="keywordtype">int</span>* argc, CharType** argv) {</div><div class="line"><a name="l07452"></a><span class="lineno"> 7452</span>  <span class="comment">// We don't want to run the initialization code twice.</span></div><div class="line"><a name="l07453"></a><span class="lineno"> 7453</span>  <span class="keywordflow">if</span> (GTestIsInitialized()) <span class="keywordflow">return</span>;</div><div class="line"><a name="l07454"></a><span class="lineno"> 7454</span> </div><div class="line"><a name="l07455"></a><span class="lineno"> 7455</span>  <span class="keywordflow">if</span> (*argc <= 0) <span class="keywordflow">return</span>;</div><div class="line"><a name="l07456"></a><span class="lineno"> 7456</span> </div><div class="line"><a name="l07457"></a><span class="lineno"> 7457</span>  g_argvs.clear();</div><div class="line"><a name="l07458"></a><span class="lineno"> 7458</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i != *argc; i++) {</div><div class="line"><a name="l07459"></a><span class="lineno"> 7459</span>  g_argvs.push_back(<a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(argv[i]));</div><div class="line"><a name="l07460"></a><span class="lineno"> 7460</span>  }</div><div class="line"><a name="l07461"></a><span class="lineno"> 7461</span> </div><div class="line"><a name="l07462"></a><span class="lineno"> 7462</span> <span class="preprocessor">#if GTEST_HAS_ABSL</span></div><div class="line"><a name="l07463"></a><span class="lineno"> 7463</span>  absl::InitializeSymbolizer(g_argvs[0].c_str());</div><div class="line"><a name="l07464"></a><span class="lineno"> 7464</span> <span class="preprocessor">#endif // GTEST_HAS_ABSL</span></div><div class="line"><a name="l07465"></a><span class="lineno"> 7465</span> </div><div class="line"><a name="l07466"></a><span class="lineno"> 7466</span>  ParseGoogleTestFlagsOnly(argc, argv);</div><div class="line"><a name="l07467"></a><span class="lineno"> 7467</span>  GetUnitTestImpl()->PostFlagParsingInit();</div><div class="line"><a name="l07468"></a><span class="lineno"> 7468</span> }</div><div class="line"><a name="l07469"></a><span class="lineno"> 7469</span> </div><div class="line"><a name="l07470"></a><span class="lineno"> 7470</span> } <span class="comment">// namespace internal</span></div><div class="line"><a name="l07471"></a><span class="lineno"> 7471</span> </div><div class="line"><a name="l07472"></a><span class="lineno"> 7472</span> <span class="comment">// Initializes Google Test. This must be called before calling</span></div><div class="line"><a name="l07473"></a><span class="lineno"> 7473</span> <span class="comment">// RUN_ALL_TESTS(). In particular, it parses a command line for the</span></div><div class="line"><a name="l07474"></a><span class="lineno"> 7474</span> <span class="comment">// flags that Google Test recognizes. Whenever a Google Test flag is</span></div><div class="line"><a name="l07475"></a><span class="lineno"> 7475</span> <span class="comment">// seen, it is removed from argv, and *argc is decremented.</span></div><div class="line"><a name="l07476"></a><span class="lineno"> 7476</span> <span class="comment">//</span></div><div class="line"><a name="l07477"></a><span class="lineno"> 7477</span> <span class="comment">// No value is returned. Instead, the Google Test flag variables are</span></div><div class="line"><a name="l07478"></a><span class="lineno"> 7478</span> <span class="comment">// updated.</span></div><div class="line"><a name="l07479"></a><span class="lineno"> 7479</span> <span class="comment">//</span></div><div class="line"><a name="l07480"></a><span class="lineno"> 7480</span> <span class="comment">// Calling the function for the second time has no user-visible effect.</span></div><div class="line"><a name="l07481"></a><span class="lineno"> 7481</span> <span class="keywordtype">void</span> <a class="code" href="namespacetesting.html#aee3f6f99df893f576f705f66c0559482">InitGoogleTest</a>(<span class="keywordtype">int</span>* argc, <span class="keywordtype">char</span>** argv) {</div><div class="line"><a name="l07482"></a><span class="lineno"> 7482</span> <span class="preprocessor">#if defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)</span></div><div class="line"><a name="l07483"></a><span class="lineno"> 7483</span>  GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_(argc, argv);</div><div class="line"><a name="l07484"></a><span class="lineno"> 7484</span> <span class="preprocessor">#else // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)</span></div><div class="line"><a name="l07485"></a><span class="lineno"> 7485</span>  internal::InitGoogleTestImpl(argc, argv);</div><div class="line"><a name="l07486"></a><span class="lineno"> 7486</span> <span class="preprocessor">#endif // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)</span></div><div class="line"><a name="l07487"></a><span class="lineno"> 7487</span> }</div><div class="line"><a name="l07488"></a><span class="lineno"> 7488</span> </div><div class="line"><a name="l07489"></a><span class="lineno"> 7489</span> <span class="comment">// This overloaded version can be used in Windows programs compiled in</span></div><div class="line"><a name="l07490"></a><span class="lineno"> 7490</span> <span class="comment">// UNICODE mode.</span></div><div class="line"><a name="l07491"></a><span class="lineno"> 7491</span> <span class="keywordtype">void</span> <a class="code" href="namespacetesting.html#aee3f6f99df893f576f705f66c0559482">InitGoogleTest</a>(<span class="keywordtype">int</span>* argc, <span class="keywordtype">wchar_t</span>** argv) {</div><div class="line"><a name="l07492"></a><span class="lineno"> 7492</span> <span class="preprocessor">#if defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)</span></div><div class="line"><a name="l07493"></a><span class="lineno"> 7493</span>  GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_(argc, argv);</div><div class="line"><a name="l07494"></a><span class="lineno"> 7494</span> <span class="preprocessor">#else // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)</span></div><div class="line"><a name="l07495"></a><span class="lineno"> 7495</span>  internal::InitGoogleTestImpl(argc, argv);</div><div class="line"><a name="l07496"></a><span class="lineno"> 7496</span> <span class="preprocessor">#endif // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)</span></div><div class="line"><a name="l07497"></a><span class="lineno"> 7497</span> }</div><div class="line"><a name="l07498"></a><span class="lineno"> 7498</span> </div><div class="line"><a name="l07499"></a><span class="lineno"> 7499</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> <a class="code" href="namespacetesting.html#abcf5181cecc3c07915dceb3de46ab07f">TempDir</a>() {</div><div class="line"><a name="l07500"></a><span class="lineno"> 7500</span> <span class="preprocessor">#if defined(GTEST_CUSTOM_TEMPDIR_FUNCTION_)</span></div><div class="line"><a name="l07501"></a><span class="lineno"> 7501</span>  <span class="keywordflow">return</span> GTEST_CUSTOM_TEMPDIR_FUNCTION_();</div><div class="line"><a name="l07502"></a><span class="lineno"> 7502</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l07503"></a><span class="lineno"> 7503</span> </div><div class="line"><a name="l07504"></a><span class="lineno"> 7504</span> <span class="preprocessor">#if GTEST_OS_WINDOWS_MOBILE</span></div><div class="line"><a name="l07505"></a><span class="lineno"> 7505</span>  <span class="keywordflow">return</span> <span class="stringliteral">"\\temp\\"</span>;</div><div class="line"><a name="l07506"></a><span class="lineno"> 7506</span> <span class="preprocessor">#elif GTEST_OS_WINDOWS</span></div><div class="line"><a name="l07507"></a><span class="lineno"> 7507</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* temp_dir = <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a1d5e3da5a27eed25986859fa83cafe95">internal::posix::GetEnv</a>(<span class="stringliteral">"TEMP"</span>);</div><div class="line"><a name="l07508"></a><span class="lineno"> 7508</span>  <span class="keywordflow">if</span> (temp_dir == <span class="keyword">nullptr</span> || temp_dir[0] == <span class="charliteral">'\0'</span>)</div><div class="line"><a name="l07509"></a><span class="lineno"> 7509</span>  <span class="keywordflow">return</span> <span class="stringliteral">"\\temp\\"</span>;</div><div class="line"><a name="l07510"></a><span class="lineno"> 7510</span>  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (temp_dir[strlen(temp_dir) - 1] == <span class="charliteral">'\\'</span>)</div><div class="line"><a name="l07511"></a><span class="lineno"> 7511</span>  <span class="keywordflow">return</span> temp_dir;</div><div class="line"><a name="l07512"></a><span class="lineno"> 7512</span>  <span class="keywordflow">else</span></div><div class="line"><a name="l07513"></a><span class="lineno"> 7513</span>  <span class="keywordflow">return</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(temp_dir) + <span class="stringliteral">"\\"</span>;</div><div class="line"><a name="l07514"></a><span class="lineno"> 7514</span> <span class="preprocessor">#elif GTEST_OS_LINUX_ANDROID</span></div><div class="line"><a name="l07515"></a><span class="lineno"> 7515</span>  <span class="keywordflow">return</span> <span class="stringliteral">"/sdcard/"</span>;</div><div class="line"><a name="l07516"></a><span class="lineno"> 7516</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l07517"></a><span class="lineno"> 7517</span>  <span class="keywordflow">return</span> <span class="stringliteral">"/tmp/"</span>;</div><div class="line"><a name="l07518"></a><span class="lineno"> 7518</span> <span class="preprocessor">#endif // GTEST_OS_WINDOWS_MOBILE</span></div><div class="line"><a name="l07519"></a><span class="lineno"> 7519</span> }</div><div class="line"><a name="l07520"></a><span class="lineno"> 7520</span> </div><div class="line"><a name="l07521"></a><span class="lineno"> 7521</span> <span class="comment">// Class ScopedTrace</span></div><div class="line"><a name="l07522"></a><span class="lineno"> 7522</span> </div><div class="line"><a name="l07523"></a><span class="lineno"> 7523</span> <span class="comment">// Pushes the given source file location and message onto a per-thread</span></div><div class="line"><a name="l07524"></a><span class="lineno"> 7524</span> <span class="comment">// trace stack maintained by Google Test.</span></div><div class="line"><a name="l07525"></a><span class="lineno"> 7525</span> <span class="keywordtype">void</span> ScopedTrace::PushTrace(<span class="keyword">const</span> <span class="keywordtype">char</span>* file, <span class="keywordtype">int</span> line, <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> message) {</div><div class="line"><a name="l07526"></a><span class="lineno"> 7526</span>  internal::TraceInfo trace;</div><div class="line"><a name="l07527"></a><span class="lineno"> 7527</span>  trace.file = file;</div><div class="line"><a name="l07528"></a><span class="lineno"> 7528</span>  trace.line = line;</div><div class="line"><a name="l07529"></a><span class="lineno"> 7529</span>  trace.message.swap(message);</div><div class="line"><a name="l07530"></a><span class="lineno"> 7530</span> </div><div class="line"><a name="l07531"></a><span class="lineno"> 7531</span>  UnitTest::GetInstance()->PushGTestTrace(trace);</div><div class="line"><a name="l07532"></a><span class="lineno"> 7532</span> }</div><div class="line"><a name="l07533"></a><span class="lineno"> 7533</span> </div><div class="line"><a name="l07534"></a><span class="lineno"> 7534</span> <span class="comment">// Pops the info pushed by the c'tor.</span></div><div class="line"><a name="l07535"></a><span class="lineno"> 7535</span> ScopedTrace::~ScopedTrace()</div><div class="line"><a name="l07536"></a><span class="lineno"> 7536</span>  <a class="code" href="gtest_8h.html#a69abff5a4efdd07bd5faebe3dd318d06">GTEST_LOCK_EXCLUDED_</a>(&UnitTest::mutex_) {</div><div class="line"><a name="l07537"></a><span class="lineno"> 7537</span>  UnitTest::GetInstance()->PopGTestTrace();</div><div class="line"><a name="l07538"></a><span class="lineno"> 7538</span> }</div><div class="line"><a name="l07539"></a><span class="lineno"> 7539</span> </div><div class="line"><a name="l07540"></a><span class="lineno"> 7540</span> } <span class="comment">// namespace testing</span></div><div class="line"><a name="l07541"></a><span class="lineno"> 7541</span> <span class="comment">// Copyright 2005, Google Inc.</span></div><div class="line"><a name="l07542"></a><span class="lineno"> 7542</span> <span class="comment">// All rights reserved.</span></div><div class="line"><a name="l07543"></a><span class="lineno"> 7543</span> <span class="comment">//</span></div><div class="line"><a name="l07544"></a><span class="lineno"> 7544</span> <span class="comment">// Redistribution and use in source and binary forms, with or without</span></div><div class="line"><a name="l07545"></a><span class="lineno"> 7545</span> <span class="comment">// modification, are permitted provided that the following conditions are</span></div><div class="line"><a name="l07546"></a><span class="lineno"> 7546</span> <span class="comment">// met:</span></div><div class="line"><a name="l07547"></a><span class="lineno"> 7547</span> <span class="comment">//</span></div><div class="line"><a name="l07548"></a><span class="lineno"> 7548</span> <span class="comment">// * Redistributions of source code must retain the above copyright</span></div><div class="line"><a name="l07549"></a><span class="lineno"> 7549</span> <span class="comment">// notice, this list of conditions and the following disclaimer.</span></div><div class="line"><a name="l07550"></a><span class="lineno"> 7550</span> <span class="comment">// * Redistributions in binary form must reproduce the above</span></div><div class="line"><a name="l07551"></a><span class="lineno"> 7551</span> <span class="comment">// copyright notice, this list of conditions and the following disclaimer</span></div><div class="line"><a name="l07552"></a><span class="lineno"> 7552</span> <span class="comment">// in the documentation and/or other materials provided with the</span></div><div class="line"><a name="l07553"></a><span class="lineno"> 7553</span> <span class="comment">// distribution.</span></div><div class="line"><a name="l07554"></a><span class="lineno"> 7554</span> <span class="comment">// * Neither the name of Google Inc. nor the names of its</span></div><div class="line"><a name="l07555"></a><span class="lineno"> 7555</span> <span class="comment">// contributors may be used to endorse or promote products derived from</span></div><div class="line"><a name="l07556"></a><span class="lineno"> 7556</span> <span class="comment">// this software without specific prior written permission.</span></div><div class="line"><a name="l07557"></a><span class="lineno"> 7557</span> <span class="comment">//</span></div><div class="line"><a name="l07558"></a><span class="lineno"> 7558</span> <span class="comment">// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span></div><div class="line"><a name="l07559"></a><span class="lineno"> 7559</span> <span class="comment">// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</span></div><div class="line"><a name="l07560"></a><span class="lineno"> 7560</span> <span class="comment">// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR</span></div><div class="line"><a name="l07561"></a><span class="lineno"> 7561</span> <span class="comment">// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT</span></div><div class="line"><a name="l07562"></a><span class="lineno"> 7562</span> <span class="comment">// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span></div><div class="line"><a name="l07563"></a><span class="lineno"> 7563</span> <span class="comment">// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</span></div><div class="line"><a name="l07564"></a><span class="lineno"> 7564</span> <span class="comment">// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</span></div><div class="line"><a name="l07565"></a><span class="lineno"> 7565</span> <span class="comment">// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY</span></div><div class="line"><a name="l07566"></a><span class="lineno"> 7566</span> <span class="comment">// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span></div><div class="line"><a name="l07567"></a><span class="lineno"> 7567</span> <span class="comment">// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE</span></div><div class="line"><a name="l07568"></a><span class="lineno"> 7568</span> <span class="comment">// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span></div><div class="line"><a name="l07569"></a><span class="lineno"> 7569</span> </div><div class="line"><a name="l07570"></a><span class="lineno"> 7570</span> <span class="comment">//</span></div><div class="line"><a name="l07571"></a><span class="lineno"> 7571</span> <span class="comment">// This file implements death tests.</span></div><div class="line"><a name="l07572"></a><span class="lineno"> 7572</span> </div><div class="line"><a name="l07573"></a><span class="lineno"> 7573</span> </div><div class="line"><a name="l07574"></a><span class="lineno"> 7574</span> <span class="preprocessor">#include <utility></span></div><div class="line"><a name="l07575"></a><span class="lineno"> 7575</span> </div><div class="line"><a name="l07576"></a><span class="lineno"> 7576</span> </div><div class="line"><a name="l07577"></a><span class="lineno"> 7577</span> <span class="preprocessor">#if GTEST_HAS_DEATH_TEST</span></div><div class="line"><a name="l07578"></a><span class="lineno"> 7578</span> </div><div class="line"><a name="l07579"></a><span class="lineno"> 7579</span> <span class="preprocessor"># if GTEST_OS_MAC</span></div><div class="line"><a name="l07580"></a><span class="lineno"> 7580</span> <span class="preprocessor"># include <crt_externs.h></span></div><div class="line"><a name="l07581"></a><span class="lineno"> 7581</span> <span class="preprocessor"># endif // GTEST_OS_MAC</span></div><div class="line"><a name="l07582"></a><span class="lineno"> 7582</span> </div><div class="line"><a name="l07583"></a><span class="lineno"> 7583</span> <span class="preprocessor"># include <errno.h></span></div><div class="line"><a name="l07584"></a><span class="lineno"> 7584</span> <span class="preprocessor"># include <fcntl.h></span></div><div class="line"><a name="l07585"></a><span class="lineno"> 7585</span> <span class="preprocessor"># include <limits.h></span></div><div class="line"><a name="l07586"></a><span class="lineno"> 7586</span> </div><div class="line"><a name="l07587"></a><span class="lineno"> 7587</span> <span class="preprocessor"># if GTEST_OS_LINUX</span></div><div class="line"><a name="l07588"></a><span class="lineno"> 7588</span> <span class="preprocessor"># include <signal.h></span></div><div class="line"><a name="l07589"></a><span class="lineno"> 7589</span> <span class="preprocessor"># endif // GTEST_OS_LINUX</span></div><div class="line"><a name="l07590"></a><span class="lineno"> 7590</span> </div><div class="line"><a name="l07591"></a><span class="lineno"> 7591</span> <span class="preprocessor"># include <stdarg.h></span></div><div class="line"><a name="l07592"></a><span class="lineno"> 7592</span> </div><div class="line"><a name="l07593"></a><span class="lineno"> 7593</span> <span class="preprocessor"># if GTEST_OS_WINDOWS</span></div><div class="line"><a name="l07594"></a><span class="lineno"> 7594</span> <span class="preprocessor"># include <windows.h></span></div><div class="line"><a name="l07595"></a><span class="lineno"> 7595</span> <span class="preprocessor"># else</span></div><div class="line"><a name="l07596"></a><span class="lineno"> 7596</span> <span class="preprocessor"># include <sys/mman.h></span></div><div class="line"><a name="l07597"></a><span class="lineno"> 7597</span> <span class="preprocessor"># include <sys/wait.h></span></div><div class="line"><a name="l07598"></a><span class="lineno"> 7598</span> <span class="preprocessor"># endif // GTEST_OS_WINDOWS</span></div><div class="line"><a name="l07599"></a><span class="lineno"> 7599</span> </div><div class="line"><a name="l07600"></a><span class="lineno"> 7600</span> <span class="preprocessor"># if GTEST_OS_QNX</span></div><div class="line"><a name="l07601"></a><span class="lineno"> 7601</span> <span class="preprocessor"># include <spawn.h></span></div><div class="line"><a name="l07602"></a><span class="lineno"> 7602</span> <span class="preprocessor"># endif // GTEST_OS_QNX</span></div><div class="line"><a name="l07603"></a><span class="lineno"> 7603</span> </div><div class="line"><a name="l07604"></a><span class="lineno"> 7604</span> <span class="preprocessor"># if GTEST_OS_FUCHSIA</span></div><div class="line"><a name="l07605"></a><span class="lineno"> 7605</span> <span class="preprocessor"># include <lib/fdio/io.h></span></div><div class="line"><a name="l07606"></a><span class="lineno"> 7606</span> <span class="preprocessor"># include <lib/fdio/spawn.h></span></div><div class="line"><a name="l07607"></a><span class="lineno"> 7607</span> <span class="preprocessor"># include <lib/fdio/util.h></span></div><div class="line"><a name="l07608"></a><span class="lineno"> 7608</span> <span class="preprocessor"># include <lib/zx/socket.h></span></div><div class="line"><a name="l07609"></a><span class="lineno"> 7609</span> <span class="preprocessor"># include <lib/zx/port.h></span></div><div class="line"><a name="l07610"></a><span class="lineno"> 7610</span> <span class="preprocessor"># include <lib/zx/process.h></span></div><div class="line"><a name="l07611"></a><span class="lineno"> 7611</span> <span class="preprocessor"># include <zircon/processargs.h></span></div><div class="line"><a name="l07612"></a><span class="lineno"> 7612</span> <span class="preprocessor"># include <zircon/syscalls.h></span></div><div class="line"><a name="l07613"></a><span class="lineno"> 7613</span> <span class="preprocessor"># include <zircon/syscalls/policy.h></span></div><div class="line"><a name="l07614"></a><span class="lineno"> 7614</span> <span class="preprocessor"># include <zircon/syscalls/port.h></span></div><div class="line"><a name="l07615"></a><span class="lineno"> 7615</span> <span class="preprocessor"># endif // GTEST_OS_FUCHSIA</span></div><div class="line"><a name="l07616"></a><span class="lineno"> 7616</span> </div><div class="line"><a name="l07617"></a><span class="lineno"> 7617</span> <span class="preprocessor">#endif // GTEST_HAS_DEATH_TEST</span></div><div class="line"><a name="l07618"></a><span class="lineno"> 7618</span> </div><div class="line"><a name="l07619"></a><span class="lineno"> 7619</span> </div><div class="line"><a name="l07620"></a><span class="lineno"><a class="line" href="namespacetesting.html"> 7620</a></span> <span class="keyword">namespace </span><a class="code" href="namespacetesting.html">testing</a> {</div><div class="line"><a name="l07621"></a><span class="lineno"> 7621</span> </div><div class="line"><a name="l07622"></a><span class="lineno"> 7622</span> <span class="comment">// Constants.</span></div><div class="line"><a name="l07623"></a><span class="lineno"> 7623</span> </div><div class="line"><a name="l07624"></a><span class="lineno"> 7624</span> <span class="comment">// The default death test style.</span></div><div class="line"><a name="l07625"></a><span class="lineno"> 7625</span> <span class="comment">//</span></div><div class="line"><a name="l07626"></a><span class="lineno"> 7626</span> <span class="comment">// This is defined in internal/gtest-port.h as "fast", but can be overridden by</span></div><div class="line"><a name="l07627"></a><span class="lineno"> 7627</span> <span class="comment">// a definition in internal/custom/gtest-port.h. The recommended value, which is</span></div><div class="line"><a name="l07628"></a><span class="lineno"> 7628</span> <span class="comment">// used internally at Google, is "threadsafe".</span></div><div class="line"><a name="l07629"></a><span class="lineno"> 7629</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kDefaultDeathTestStyle[] = <a class="code" href="gtest_8h.html#a491d09ee62f1c9cfeafa3dbf75aaa9e2">GTEST_DEFAULT_DEATH_TEST_STYLE</a>;</div><div class="line"><a name="l07630"></a><span class="lineno"> 7630</span> </div><div class="line"><a name="l07631"></a><span class="lineno"> 7631</span> <a class="code" href="namespacetesting.html#a8e954ed3f0f6ca2e90b043e419c74123">GTEST_DEFINE_string_</a>(</div><div class="line"><a name="l07632"></a><span class="lineno"> 7632</span>  death_test_style,</div><div class="line"><a name="l07633"></a><span class="lineno"> 7633</span>  <a class="code" href="namespacetesting_1_1internal.html#a0967cbf18fb1594f82512d8d822aba21">internal::StringFromGTestEnv</a>(<span class="stringliteral">"death_test_style"</span>, kDefaultDeathTestStyle),</div><div class="line"><a name="l07634"></a><span class="lineno"> 7634</span>  <span class="stringliteral">"Indicates how to run a death test in a forked child process: "</span></div><div class="line"><a name="l07635"></a><span class="lineno"> 7635</span>  <span class="stringliteral">"\"threadsafe\" (child process re-executes the test binary "</span></div><div class="line"><a name="l07636"></a><span class="lineno"> 7636</span>  <span class="stringliteral">"from the beginning, running only the specific death test) or "</span></div><div class="line"><a name="l07637"></a><span class="lineno"> 7637</span>  <span class="stringliteral">"\"fast\" (child process runs the death test immediately "</span></div><div class="line"><a name="l07638"></a><span class="lineno"> 7638</span>  <span class="stringliteral">"after forking)."</span>);</div><div class="line"><a name="l07639"></a><span class="lineno"> 7639</span> </div><div class="line"><a name="l07640"></a><span class="lineno"> 7640</span> <a class="code" href="namespacetesting.html#a428e5944490e497df683cb8324ce4489">GTEST_DEFINE_bool_</a>(</div><div class="line"><a name="l07641"></a><span class="lineno"> 7641</span>  death_test_use_fork,</div><div class="line"><a name="l07642"></a><span class="lineno"> 7642</span>  <a class="code" href="namespacetesting_1_1internal.html#a1055088bb9b867e1b7b8f096f519d7c5">internal::BoolFromGTestEnv</a>(<span class="stringliteral">"death_test_use_fork"</span>, <span class="keyword">false</span>),</div><div class="line"><a name="l07643"></a><span class="lineno"> 7643</span>  <span class="stringliteral">"Instructs to use fork()/_exit() instead of clone() in death tests. "</span></div><div class="line"><a name="l07644"></a><span class="lineno"> 7644</span>  <span class="stringliteral">"Ignored and always uses fork() on POSIX systems where clone() is not "</span></div><div class="line"><a name="l07645"></a><span class="lineno"> 7645</span>  <span class="stringliteral">"implemented. Useful when running under valgrind or similar tools if "</span></div><div class="line"><a name="l07646"></a><span class="lineno"> 7646</span>  <span class="stringliteral">"those do not support clone(). Valgrind 3.3.1 will just fail if "</span></div><div class="line"><a name="l07647"></a><span class="lineno"> 7647</span>  <span class="stringliteral">"it sees an unsupported combination of clone() flags. "</span></div><div class="line"><a name="l07648"></a><span class="lineno"> 7648</span>  <span class="stringliteral">"It is not recommended to use this flag w/o valgrind though it will "</span></div><div class="line"><a name="l07649"></a><span class="lineno"> 7649</span>  <span class="stringliteral">"work in 99% of the cases. Once valgrind is fixed, this flag will "</span></div><div class="line"><a name="l07650"></a><span class="lineno"> 7650</span>  <span class="stringliteral">"most likely be removed."</span>);</div><div class="line"><a name="l07651"></a><span class="lineno"> 7651</span> </div><div class="line"><a name="l07652"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html"> 7652</a></span> <span class="keyword">namespace </span>internal {</div><div class="line"><a name="l07653"></a><span class="lineno"> 7653</span> <a class="code" href="namespacetesting_1_1internal.html#a20bfd9d47d8dd167ffc1c37a4c9ff73e">GTEST_DEFINE_string_</a>(</div><div class="line"><a name="l07654"></a><span class="lineno"> 7654</span>  internal_run_death_test, <span class="stringliteral">""</span>,</div><div class="line"><a name="l07655"></a><span class="lineno"> 7655</span>  <span class="stringliteral">"Indicates the file, line number, temporal index of "</span></div><div class="line"><a name="l07656"></a><span class="lineno"> 7656</span>  <span class="stringliteral">"the single death test to run, and a file descriptor to "</span></div><div class="line"><a name="l07657"></a><span class="lineno"> 7657</span>  <span class="stringliteral">"which a success code may be sent, all separated by "</span></div><div class="line"><a name="l07658"></a><span class="lineno"> 7658</span>  <span class="stringliteral">"the '|' characters. This flag is specified if and only if the current "</span></div><div class="line"><a name="l07659"></a><span class="lineno"> 7659</span>  <span class="stringliteral">"process is a sub-process launched for running a thread-safe "</span></div><div class="line"><a name="l07660"></a><span class="lineno"> 7660</span>  <span class="stringliteral">"death test. FOR INTERNAL USE ONLY."</span>);</div><div class="line"><a name="l07661"></a><span class="lineno"> 7661</span> } <span class="comment">// namespace internal</span></div><div class="line"><a name="l07662"></a><span class="lineno"> 7662</span> </div><div class="line"><a name="l07663"></a><span class="lineno"> 7663</span> <span class="preprocessor">#if GTEST_HAS_DEATH_TEST</span></div><div class="line"><a name="l07664"></a><span class="lineno"> 7664</span> </div><div class="line"><a name="l07665"></a><span class="lineno"> 7665</span> <span class="keyword">namespace </span>internal {</div><div class="line"><a name="l07666"></a><span class="lineno"> 7666</span> </div><div class="line"><a name="l07667"></a><span class="lineno"> 7667</span> <span class="comment">// Valid only for fast death tests. Indicates the code is running in the</span></div><div class="line"><a name="l07668"></a><span class="lineno"> 7668</span> <span class="comment">// child process of a fast style death test.</span></div><div class="line"><a name="l07669"></a><span class="lineno"> 7669</span> <span class="preprocessor"># if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA</span></div><div class="line"><a name="l07670"></a><span class="lineno"> 7670</span> <span class="keyword">static</span> <span class="keywordtype">bool</span> g_in_fast_death_test_child = <span class="keyword">false</span>;</div><div class="line"><a name="l07671"></a><span class="lineno"> 7671</span> <span class="preprocessor"># endif</span></div><div class="line"><a name="l07672"></a><span class="lineno"> 7672</span> </div><div class="line"><a name="l07673"></a><span class="lineno"> 7673</span> <span class="comment">// Returns a Boolean value indicating whether the caller is currently</span></div><div class="line"><a name="l07674"></a><span class="lineno"> 7674</span> <span class="comment">// executing in the context of the death test child process. Tools such as</span></div><div class="line"><a name="l07675"></a><span class="lineno"> 7675</span> <span class="comment">// Valgrind heap checkers may need this to modify their behavior in death</span></div><div class="line"><a name="l07676"></a><span class="lineno"> 7676</span> <span class="comment">// tests. IMPORTANT: This is an internal utility. Using it may break the</span></div><div class="line"><a name="l07677"></a><span class="lineno"> 7677</span> <span class="comment">// implementation of death tests. User code MUST NOT use it.</span></div><div class="line"><a name="l07678"></a><span class="lineno"> 7678</span> <span class="keywordtype">bool</span> InDeathTestChild() {</div><div class="line"><a name="l07679"></a><span class="lineno"> 7679</span> <span class="preprocessor"># if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA</span></div><div class="line"><a name="l07680"></a><span class="lineno"> 7680</span> </div><div class="line"><a name="l07681"></a><span class="lineno"> 7681</span>  <span class="comment">// On Windows and Fuchsia, death tests are thread-safe regardless of the value</span></div><div class="line"><a name="l07682"></a><span class="lineno"> 7682</span>  <span class="comment">// of the death_test_style flag.</span></div><div class="line"><a name="l07683"></a><span class="lineno"> 7683</span>  <span class="keywordflow">return</span> !<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(internal_run_death_test).empty();</div><div class="line"><a name="l07684"></a><span class="lineno"> 7684</span> </div><div class="line"><a name="l07685"></a><span class="lineno"> 7685</span> <span class="preprocessor"># else</span></div><div class="line"><a name="l07686"></a><span class="lineno"> 7686</span> </div><div class="line"><a name="l07687"></a><span class="lineno"> 7687</span>  <span class="keywordflow">if</span> (<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(death_test_style) == <span class="stringliteral">"threadsafe"</span>)</div><div class="line"><a name="l07688"></a><span class="lineno"> 7688</span>  <span class="keywordflow">return</span> !<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(internal_run_death_test).empty();</div><div class="line"><a name="l07689"></a><span class="lineno"> 7689</span>  <span class="keywordflow">else</span></div><div class="line"><a name="l07690"></a><span class="lineno"> 7690</span>  <span class="keywordflow">return</span> g_in_fast_death_test_child;</div><div class="line"><a name="l07691"></a><span class="lineno"> 7691</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l07692"></a><span class="lineno"> 7692</span> }</div><div class="line"><a name="l07693"></a><span class="lineno"> 7693</span> </div><div class="line"><a name="l07694"></a><span class="lineno"> 7694</span> } <span class="comment">// namespace internal</span></div><div class="line"><a name="l07695"></a><span class="lineno"> 7695</span> </div><div class="line"><a name="l07696"></a><span class="lineno"> 7696</span> <span class="comment">// ExitedWithCode constructor.</span></div><div class="line"><a name="l07697"></a><span class="lineno"> 7697</span> ExitedWithCode::ExitedWithCode(<span class="keywordtype">int</span> exit_code) : exit_code_(exit_code) {</div><div class="line"><a name="l07698"></a><span class="lineno"> 7698</span> }</div><div class="line"><a name="l07699"></a><span class="lineno"> 7699</span> </div><div class="line"><a name="l07700"></a><span class="lineno"> 7700</span> <span class="comment">// ExitedWithCode function-call operator.</span></div><div class="line"><a name="l07701"></a><span class="lineno"> 7701</span> <span class="keywordtype">bool</span> ExitedWithCode::operator()(<span class="keywordtype">int</span> exit_status)<span class="keyword"> const </span>{</div><div class="line"><a name="l07702"></a><span class="lineno"> 7702</span> <span class="preprocessor"># if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA</span></div><div class="line"><a name="l07703"></a><span class="lineno"> 7703</span> </div><div class="line"><a name="l07704"></a><span class="lineno"> 7704</span>  <span class="keywordflow">return</span> exit_status == exit_code_;</div><div class="line"><a name="l07705"></a><span class="lineno"> 7705</span> </div><div class="line"><a name="l07706"></a><span class="lineno"> 7706</span> <span class="preprocessor"># else</span></div><div class="line"><a name="l07707"></a><span class="lineno"> 7707</span> </div><div class="line"><a name="l07708"></a><span class="lineno"> 7708</span>  <span class="keywordflow">return</span> WIFEXITED(exit_status) && WEXITSTATUS(exit_status) == exit_code_;</div><div class="line"><a name="l07709"></a><span class="lineno"> 7709</span> </div><div class="line"><a name="l07710"></a><span class="lineno"> 7710</span> <span class="preprocessor"># endif // GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA</span></div><div class="line"><a name="l07711"></a><span class="lineno"> 7711</span> }</div><div class="line"><a name="l07712"></a><span class="lineno"> 7712</span> </div><div class="line"><a name="l07713"></a><span class="lineno"> 7713</span> <span class="preprocessor"># if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA</span></div><div class="line"><a name="l07714"></a><span class="lineno"> 7714</span> <span class="comment">// KilledBySignal constructor.</span></div><div class="line"><a name="l07715"></a><span class="lineno"> 7715</span> KilledBySignal::KilledBySignal(<span class="keywordtype">int</span> signum) : signum_(signum) {</div><div class="line"><a name="l07716"></a><span class="lineno"> 7716</span> }</div><div class="line"><a name="l07717"></a><span class="lineno"> 7717</span> </div><div class="line"><a name="l07718"></a><span class="lineno"> 7718</span> <span class="comment">// KilledBySignal function-call operator.</span></div><div class="line"><a name="l07719"></a><span class="lineno"> 7719</span> <span class="keywordtype">bool</span> KilledBySignal::operator()(<span class="keywordtype">int</span> exit_status)<span class="keyword"> const </span>{</div><div class="line"><a name="l07720"></a><span class="lineno"> 7720</span> <span class="preprocessor"># if defined(GTEST_KILLED_BY_SIGNAL_OVERRIDE_)</span></div><div class="line"><a name="l07721"></a><span class="lineno"> 7721</span>  {</div><div class="line"><a name="l07722"></a><span class="lineno"> 7722</span>  <span class="keywordtype">bool</span> result;</div><div class="line"><a name="l07723"></a><span class="lineno"> 7723</span>  <span class="keywordflow">if</span> (GTEST_KILLED_BY_SIGNAL_OVERRIDE_(signum_, exit_status, &result)) {</div><div class="line"><a name="l07724"></a><span class="lineno"> 7724</span>  <span class="keywordflow">return</span> result;</div><div class="line"><a name="l07725"></a><span class="lineno"> 7725</span>  }</div><div class="line"><a name="l07726"></a><span class="lineno"> 7726</span>  }</div><div class="line"><a name="l07727"></a><span class="lineno"> 7727</span> <span class="preprocessor"># endif // defined(GTEST_KILLED_BY_SIGNAL_OVERRIDE_)</span></div><div class="line"><a name="l07728"></a><span class="lineno"> 7728</span>  <span class="keywordflow">return</span> WIFSIGNALED(exit_status) && WTERMSIG(exit_status) == signum_;</div><div class="line"><a name="l07729"></a><span class="lineno"> 7729</span> }</div><div class="line"><a name="l07730"></a><span class="lineno"> 7730</span> <span class="preprocessor"># endif // !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA</span></div><div class="line"><a name="l07731"></a><span class="lineno"> 7731</span> </div><div class="line"><a name="l07732"></a><span class="lineno"> 7732</span> <span class="keyword">namespace </span>internal {</div><div class="line"><a name="l07733"></a><span class="lineno"> 7733</span> </div><div class="line"><a name="l07734"></a><span class="lineno"> 7734</span> <span class="comment">// Utilities needed for death tests.</span></div><div class="line"><a name="l07735"></a><span class="lineno"> 7735</span> </div><div class="line"><a name="l07736"></a><span class="lineno"> 7736</span> <span class="comment">// Generates a textual description of a given exit code, in the format</span></div><div class="line"><a name="l07737"></a><span class="lineno"> 7737</span> <span class="comment">// specified by wait(2).</span></div><div class="line"><a name="l07738"></a><span class="lineno"> 7738</span> <span class="keyword">static</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> ExitSummary(<span class="keywordtype">int</span> exit_code) {</div><div class="line"><a name="l07739"></a><span class="lineno"> 7739</span>  Message m;</div><div class="line"><a name="l07740"></a><span class="lineno"> 7740</span> </div><div class="line"><a name="l07741"></a><span class="lineno"> 7741</span> <span class="preprocessor"># if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA</span></div><div class="line"><a name="l07742"></a><span class="lineno"> 7742</span> </div><div class="line"><a name="l07743"></a><span class="lineno"> 7743</span>  m << <span class="stringliteral">"Exited with exit status "</span> << exit_code;</div><div class="line"><a name="l07744"></a><span class="lineno"> 7744</span> </div><div class="line"><a name="l07745"></a><span class="lineno"> 7745</span> <span class="preprocessor"># else</span></div><div class="line"><a name="l07746"></a><span class="lineno"> 7746</span> </div><div class="line"><a name="l07747"></a><span class="lineno"> 7747</span>  <span class="keywordflow">if</span> (WIFEXITED(exit_code)) {</div><div class="line"><a name="l07748"></a><span class="lineno"> 7748</span>  m << <span class="stringliteral">"Exited with exit status "</span> << WEXITSTATUS(exit_code);</div><div class="line"><a name="l07749"></a><span class="lineno"> 7749</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (WIFSIGNALED(exit_code)) {</div><div class="line"><a name="l07750"></a><span class="lineno"> 7750</span>  m << <span class="stringliteral">"Terminated by signal "</span> << WTERMSIG(exit_code);</div><div class="line"><a name="l07751"></a><span class="lineno"> 7751</span>  }</div><div class="line"><a name="l07752"></a><span class="lineno"> 7752</span> <span class="preprocessor"># ifdef WCOREDUMP</span></div><div class="line"><a name="l07753"></a><span class="lineno"> 7753</span>  <span class="keywordflow">if</span> (WCOREDUMP(exit_code)) {</div><div class="line"><a name="l07754"></a><span class="lineno"> 7754</span>  m << <span class="stringliteral">" (core dumped)"</span>;</div><div class="line"><a name="l07755"></a><span class="lineno"> 7755</span>  }</div><div class="line"><a name="l07756"></a><span class="lineno"> 7756</span> <span class="preprocessor"># endif</span></div><div class="line"><a name="l07757"></a><span class="lineno"> 7757</span> <span class="preprocessor"># endif // GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA</span></div><div class="line"><a name="l07758"></a><span class="lineno"> 7758</span> </div><div class="line"><a name="l07759"></a><span class="lineno"> 7759</span>  <span class="keywordflow">return</span> m.GetString();</div><div class="line"><a name="l07760"></a><span class="lineno"> 7760</span> }</div><div class="line"><a name="l07761"></a><span class="lineno"> 7761</span> </div><div class="line"><a name="l07762"></a><span class="lineno"> 7762</span> <span class="comment">// Returns true if exit_status describes a process that was terminated</span></div><div class="line"><a name="l07763"></a><span class="lineno"> 7763</span> <span class="comment">// by a signal, or exited normally with a nonzero exit code.</span></div><div class="line"><a name="l07764"></a><span class="lineno"> 7764</span> <span class="keywordtype">bool</span> ExitedUnsuccessfully(<span class="keywordtype">int</span> exit_status) {</div><div class="line"><a name="l07765"></a><span class="lineno"> 7765</span>  <span class="keywordflow">return</span> !ExitedWithCode(0)(exit_status);</div><div class="line"><a name="l07766"></a><span class="lineno"> 7766</span> }</div><div class="line"><a name="l07767"></a><span class="lineno"> 7767</span> </div><div class="line"><a name="l07768"></a><span class="lineno"> 7768</span> <span class="preprocessor"># if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA</span></div><div class="line"><a name="l07769"></a><span class="lineno"> 7769</span> <span class="comment">// Generates a textual failure message when a death test finds more than</span></div><div class="line"><a name="l07770"></a><span class="lineno"> 7770</span> <span class="comment">// one thread running, or cannot determine the number of threads, prior</span></div><div class="line"><a name="l07771"></a><span class="lineno"> 7771</span> <span class="comment">// to executing the given statement. It is the responsibility of the</span></div><div class="line"><a name="l07772"></a><span class="lineno"> 7772</span> <span class="comment">// caller not to pass a thread_count of 1.</span></div><div class="line"><a name="l07773"></a><span class="lineno"> 7773</span> <span class="keyword">static</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> DeathTestThreadWarning(<span class="keywordtype">size_t</span> thread_count) {</div><div class="line"><a name="l07774"></a><span class="lineno"> 7774</span>  Message msg;</div><div class="line"><a name="l07775"></a><span class="lineno"> 7775</span>  msg << <span class="stringliteral">"Death tests use fork(), which is unsafe particularly"</span></div><div class="line"><a name="l07776"></a><span class="lineno"> 7776</span>  << <span class="stringliteral">" in a threaded context. For this test, "</span> << <a class="code" href="gtest_8h.html#a13d98c217176bd8722c395b9225fc19d">GTEST_NAME_</a> << <span class="stringliteral">" "</span>;</div><div class="line"><a name="l07777"></a><span class="lineno"> 7777</span>  <span class="keywordflow">if</span> (thread_count == 0) {</div><div class="line"><a name="l07778"></a><span class="lineno"> 7778</span>  msg << <span class="stringliteral">"couldn't detect the number of threads."</span>;</div><div class="line"><a name="l07779"></a><span class="lineno"> 7779</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l07780"></a><span class="lineno"> 7780</span>  msg << <span class="stringliteral">"detected "</span> << thread_count << <span class="stringliteral">" threads."</span>;</div><div class="line"><a name="l07781"></a><span class="lineno"> 7781</span>  }</div><div class="line"><a name="l07782"></a><span class="lineno"> 7782</span>  msg << <span class="stringliteral">" See "</span></div><div class="line"><a name="l07783"></a><span class="lineno"> 7783</span>  <span class="stringliteral">"https://github.com/google/googletest/blob/master/googletest/docs/"</span></div><div class="line"><a name="l07784"></a><span class="lineno"> 7784</span>  <span class="stringliteral">"advanced.md#death-tests-and-threads"</span></div><div class="line"><a name="l07785"></a><span class="lineno"> 7785</span>  << <span class="stringliteral">" for more explanation and suggested solutions, especially if"</span></div><div class="line"><a name="l07786"></a><span class="lineno"> 7786</span>  << <span class="stringliteral">" this is the last message you see before your test times out."</span>;</div><div class="line"><a name="l07787"></a><span class="lineno"> 7787</span>  <span class="keywordflow">return</span> msg.GetString();</div><div class="line"><a name="l07788"></a><span class="lineno"> 7788</span> }</div><div class="line"><a name="l07789"></a><span class="lineno"> 7789</span> <span class="preprocessor"># endif // !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA</span></div><div class="line"><a name="l07790"></a><span class="lineno"> 7790</span> </div><div class="line"><a name="l07791"></a><span class="lineno"> 7791</span> <span class="comment">// Flag characters for reporting a death test that did not die.</span></div><div class="line"><a name="l07792"></a><span class="lineno"> 7792</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kDeathTestLived = <span class="charliteral">'L'</span>;</div><div class="line"><a name="l07793"></a><span class="lineno"> 7793</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kDeathTestReturned = <span class="charliteral">'R'</span>;</div><div class="line"><a name="l07794"></a><span class="lineno"> 7794</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kDeathTestThrew = <span class="charliteral">'T'</span>;</div><div class="line"><a name="l07795"></a><span class="lineno"> 7795</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kDeathTestInternalError = <span class="charliteral">'I'</span>;</div><div class="line"><a name="l07796"></a><span class="lineno"> 7796</span> </div><div class="line"><a name="l07797"></a><span class="lineno"> 7797</span> <span class="preprocessor">#if GTEST_OS_FUCHSIA</span></div><div class="line"><a name="l07798"></a><span class="lineno"> 7798</span> </div><div class="line"><a name="l07799"></a><span class="lineno"> 7799</span> <span class="comment">// File descriptor used for the pipe in the child process.</span></div><div class="line"><a name="l07800"></a><span class="lineno"> 7800</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> kFuchsiaReadPipeFd = 3;</div><div class="line"><a name="l07801"></a><span class="lineno"> 7801</span> </div><div class="line"><a name="l07802"></a><span class="lineno"> 7802</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l07803"></a><span class="lineno"> 7803</span> </div><div class="line"><a name="l07804"></a><span class="lineno"> 7804</span> <span class="comment">// An enumeration describing all of the possible ways that a death test can</span></div><div class="line"><a name="l07805"></a><span class="lineno"> 7805</span> <span class="comment">// conclude. DIED means that the process died while executing the test</span></div><div class="line"><a name="l07806"></a><span class="lineno"> 7806</span> <span class="comment">// code; LIVED means that process lived beyond the end of the test code;</span></div><div class="line"><a name="l07807"></a><span class="lineno"> 7807</span> <span class="comment">// RETURNED means that the test statement attempted to execute a return</span></div><div class="line"><a name="l07808"></a><span class="lineno"> 7808</span> <span class="comment">// statement, which is not allowed; THREW means that the test statement</span></div><div class="line"><a name="l07809"></a><span class="lineno"> 7809</span> <span class="comment">// returned control by throwing an exception. IN_PROGRESS means the test</span></div><div class="line"><a name="l07810"></a><span class="lineno"> 7810</span> <span class="comment">// has not yet concluded.</span></div><div class="line"><a name="l07811"></a><span class="lineno"> 7811</span> <span class="keyword">enum</span> DeathTestOutcome { IN_PROGRESS, DIED, LIVED, RETURNED, THREW };</div><div class="line"><a name="l07812"></a><span class="lineno"> 7812</span> </div><div class="line"><a name="l07813"></a><span class="lineno"> 7813</span> <span class="comment">// Routine for aborting the program which is safe to call from an</span></div><div class="line"><a name="l07814"></a><span class="lineno"> 7814</span> <span class="comment">// exec-style death test child process, in which case the error</span></div><div class="line"><a name="l07815"></a><span class="lineno"> 7815</span> <span class="comment">// message is propagated back to the parent process. Otherwise, the</span></div><div class="line"><a name="l07816"></a><span class="lineno"> 7816</span> <span class="comment">// message is simply printed to stderr. In either case, the program</span></div><div class="line"><a name="l07817"></a><span class="lineno"> 7817</span> <span class="comment">// then exits with status 1.</span></div><div class="line"><a name="l07818"></a><span class="lineno"> 7818</span> <span class="keyword">static</span> <span class="keywordtype">void</span> DeathTestAbort(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& message) {</div><div class="line"><a name="l07819"></a><span class="lineno"> 7819</span>  <span class="comment">// On a POSIX system, this function may be called from a threadsafe-style</span></div><div class="line"><a name="l07820"></a><span class="lineno"> 7820</span>  <span class="comment">// death test child process, which operates on a very small stack. Use</span></div><div class="line"><a name="l07821"></a><span class="lineno"> 7821</span>  <span class="comment">// the heap for any additional non-minuscule memory requirements.</span></div><div class="line"><a name="l07822"></a><span class="lineno"> 7822</span>  <span class="keyword">const</span> InternalRunDeathTestFlag* <span class="keyword">const</span> flag =</div><div class="line"><a name="l07823"></a><span class="lineno"> 7823</span>  GetUnitTestImpl()->internal_run_death_test_flag();</div><div class="line"><a name="l07824"></a><span class="lineno"> 7824</span>  <span class="keywordflow">if</span> (flag != <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l07825"></a><span class="lineno"> 7825</span>  FILE* parent = <a class="code" href="namespacetesting_1_1internal_1_1posix.html#af7c268eba32d5a718b36b6b3801302e0">posix::FDOpen</a>(flag->write_fd(), <span class="stringliteral">"w"</span>);</div><div class="line"><a name="l07826"></a><span class="lineno"> 7826</span>  fputc(kDeathTestInternalError, parent);</div><div class="line"><a name="l07827"></a><span class="lineno"> 7827</span>  fprintf(parent, <span class="stringliteral">"%s"</span>, message.c_str());</div><div class="line"><a name="l07828"></a><span class="lineno"> 7828</span>  fflush(parent);</div><div class="line"><a name="l07829"></a><span class="lineno"> 7829</span>  _exit(1);</div><div class="line"><a name="l07830"></a><span class="lineno"> 7830</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l07831"></a><span class="lineno"> 7831</span>  fprintf(stderr, <span class="stringliteral">"%s"</span>, message.c_str());</div><div class="line"><a name="l07832"></a><span class="lineno"> 7832</span>  fflush(stderr);</div><div class="line"><a name="l07833"></a><span class="lineno"> 7833</span>  <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a69b8278c59359dd6a6f941b4643db9fb">posix::Abort</a>();</div><div class="line"><a name="l07834"></a><span class="lineno"> 7834</span>  }</div><div class="line"><a name="l07835"></a><span class="lineno"> 7835</span> }</div><div class="line"><a name="l07836"></a><span class="lineno"> 7836</span> </div><div class="line"><a name="l07837"></a><span class="lineno"> 7837</span> <span class="comment">// A replacement for CHECK that calls DeathTestAbort if the assertion</span></div><div class="line"><a name="l07838"></a><span class="lineno"> 7838</span> <span class="comment">// fails.</span></div><div class="line"><a name="l07839"></a><span class="lineno"> 7839</span> <span class="preprocessor"># define GTEST_DEATH_TEST_CHECK_(expression) \</span></div><div class="line"><a name="l07840"></a><span class="lineno"> 7840</span> <span class="preprocessor"> do { \</span></div><div class="line"><a name="l07841"></a><span class="lineno"> 7841</span> <span class="preprocessor"> if (!::testing::internal::IsTrue(expression)) { \</span></div><div class="line"><a name="l07842"></a><span class="lineno"> 7842</span> <span class="preprocessor"> DeathTestAbort( \</span></div><div class="line"><a name="l07843"></a><span class="lineno"> 7843</span> <span class="preprocessor"> ::std::string("CHECK failed: File ") + __FILE__ + ", line " \</span></div><div class="line"><a name="l07844"></a><span class="lineno"> 7844</span> <span class="preprocessor"> + ::testing::internal::StreamableToString(__LINE__) + ": " \</span></div><div class="line"><a name="l07845"></a><span class="lineno"> 7845</span> <span class="preprocessor"> + #expression); \</span></div><div class="line"><a name="l07846"></a><span class="lineno"> 7846</span> <span class="preprocessor"> } \</span></div><div class="line"><a name="l07847"></a><span class="lineno"> 7847</span> <span class="preprocessor"> } while (::testing::internal::AlwaysFalse())</span></div><div class="line"><a name="l07848"></a><span class="lineno"> 7848</span> </div><div class="line"><a name="l07849"></a><span class="lineno"> 7849</span> <span class="comment">// This macro is similar to GTEST_DEATH_TEST_CHECK_, but it is meant for</span></div><div class="line"><a name="l07850"></a><span class="lineno"> 7850</span> <span class="comment">// evaluating any system call that fulfills two conditions: it must return</span></div><div class="line"><a name="l07851"></a><span class="lineno"> 7851</span> <span class="comment">// -1 on failure, and set errno to EINTR when it is interrupted and</span></div><div class="line"><a name="l07852"></a><span class="lineno"> 7852</span> <span class="comment">// should be tried again. The macro expands to a loop that repeatedly</span></div><div class="line"><a name="l07853"></a><span class="lineno"> 7853</span> <span class="comment">// evaluates the expression as long as it evaluates to -1 and sets</span></div><div class="line"><a name="l07854"></a><span class="lineno"> 7854</span> <span class="comment">// errno to EINTR. If the expression evaluates to -1 but errno is</span></div><div class="line"><a name="l07855"></a><span class="lineno"> 7855</span> <span class="comment">// something other than EINTR, DeathTestAbort is called.</span></div><div class="line"><a name="l07856"></a><span class="lineno"> 7856</span> <span class="preprocessor"># define GTEST_DEATH_TEST_CHECK_SYSCALL_(expression) \</span></div><div class="line"><a name="l07857"></a><span class="lineno"> 7857</span> <span class="preprocessor"> do { \</span></div><div class="line"><a name="l07858"></a><span class="lineno"> 7858</span> <span class="preprocessor"> int gtest_retval; \</span></div><div class="line"><a name="l07859"></a><span class="lineno"> 7859</span> <span class="preprocessor"> do { \</span></div><div class="line"><a name="l07860"></a><span class="lineno"> 7860</span> <span class="preprocessor"> gtest_retval = (expression); \</span></div><div class="line"><a name="l07861"></a><span class="lineno"> 7861</span> <span class="preprocessor"> } while (gtest_retval == -1 && errno == EINTR); \</span></div><div class="line"><a name="l07862"></a><span class="lineno"> 7862</span> <span class="preprocessor"> if (gtest_retval == -1) { \</span></div><div class="line"><a name="l07863"></a><span class="lineno"> 7863</span> <span class="preprocessor"> DeathTestAbort( \</span></div><div class="line"><a name="l07864"></a><span class="lineno"> 7864</span> <span class="preprocessor"> ::std::string("CHECK failed: File ") + __FILE__ + ", line " \</span></div><div class="line"><a name="l07865"></a><span class="lineno"> 7865</span> <span class="preprocessor"> + ::testing::internal::StreamableToString(__LINE__) + ": " \</span></div><div class="line"><a name="l07866"></a><span class="lineno"> 7866</span> <span class="preprocessor"> + #expression + " != -1"); \</span></div><div class="line"><a name="l07867"></a><span class="lineno"> 7867</span> <span class="preprocessor"> } \</span></div><div class="line"><a name="l07868"></a><span class="lineno"> 7868</span> <span class="preprocessor"> } while (::testing::internal::AlwaysFalse())</span></div><div class="line"><a name="l07869"></a><span class="lineno"> 7869</span> </div><div class="line"><a name="l07870"></a><span class="lineno"> 7870</span> <span class="comment">// Returns the message describing the last system error in errno.</span></div><div class="line"><a name="l07871"></a><span class="lineno"> 7871</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> GetLastErrnoDescription() {</div><div class="line"><a name="l07872"></a><span class="lineno"> 7872</span>  <span class="keywordflow">return</span> errno == 0 ? <span class="stringliteral">""</span> : <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a4b77b14af6f4d18f83d303b98e9349c4">posix::StrError</a>(errno);</div><div class="line"><a name="l07873"></a><span class="lineno"> 7873</span> }</div><div class="line"><a name="l07874"></a><span class="lineno"> 7874</span> </div><div class="line"><a name="l07875"></a><span class="lineno"> 7875</span> <span class="comment">// This is called from a death test parent process to read a failure</span></div><div class="line"><a name="l07876"></a><span class="lineno"> 7876</span> <span class="comment">// message from the death test child process and log it with the FATAL</span></div><div class="line"><a name="l07877"></a><span class="lineno"> 7877</span> <span class="comment">// severity. On Windows, the message is read from a pipe handle. On other</span></div><div class="line"><a name="l07878"></a><span class="lineno"> 7878</span> <span class="comment">// platforms, it is read from a file descriptor.</span></div><div class="line"><a name="l07879"></a><span class="lineno"> 7879</span> <span class="keyword">static</span> <span class="keywordtype">void</span> FailFromInternalError(<span class="keywordtype">int</span> fd) {</div><div class="line"><a name="l07880"></a><span class="lineno"> 7880</span>  Message error;</div><div class="line"><a name="l07881"></a><span class="lineno"> 7881</span>  <span class="keywordtype">char</span> buffer[256];</div><div class="line"><a name="l07882"></a><span class="lineno"> 7882</span>  <span class="keywordtype">int</span> num_read;</div><div class="line"><a name="l07883"></a><span class="lineno"> 7883</span> </div><div class="line"><a name="l07884"></a><span class="lineno"> 7884</span>  <span class="keywordflow">do</span> {</div><div class="line"><a name="l07885"></a><span class="lineno"> 7885</span>  <span class="keywordflow">while</span> ((num_read = <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a3c6ab13e581a56f1b02f3eb7536c97fd">posix::Read</a>(fd, buffer, 255)) > 0) {</div><div class="line"><a name="l07886"></a><span class="lineno"> 7886</span>  buffer[num_read] = <span class="charliteral">'\0'</span>;</div><div class="line"><a name="l07887"></a><span class="lineno"> 7887</span>  error << buffer;</div><div class="line"><a name="l07888"></a><span class="lineno"> 7888</span>  }</div><div class="line"><a name="l07889"></a><span class="lineno"> 7889</span>  } <span class="keywordflow">while</span> (num_read == -1 && errno == EINTR);</div><div class="line"><a name="l07890"></a><span class="lineno"> 7890</span> </div><div class="line"><a name="l07891"></a><span class="lineno"> 7891</span>  <span class="keywordflow">if</span> (num_read == 0) {</div><div class="line"><a name="l07892"></a><span class="lineno"> 7892</span>  <a class="code" href="gtest_8h.html#a8ef4cb4c465db8c15464aecc6d9510ef">GTEST_LOG_</a>(FATAL) << error.GetString();</div><div class="line"><a name="l07893"></a><span class="lineno"> 7893</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l07894"></a><span class="lineno"> 7894</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> last_error = errno;</div><div class="line"><a name="l07895"></a><span class="lineno"> 7895</span>  <a class="code" href="gtest_8h.html#a8ef4cb4c465db8c15464aecc6d9510ef">GTEST_LOG_</a>(FATAL) << <span class="stringliteral">"Error while reading death test internal: "</span></div><div class="line"><a name="l07896"></a><span class="lineno"> 7896</span>  << GetLastErrnoDescription() << <span class="stringliteral">" ["</span> << last_error << <span class="stringliteral">"]"</span>;</div><div class="line"><a name="l07897"></a><span class="lineno"> 7897</span>  }</div><div class="line"><a name="l07898"></a><span class="lineno"> 7898</span> }</div><div class="line"><a name="l07899"></a><span class="lineno"> 7899</span> </div><div class="line"><a name="l07900"></a><span class="lineno"> 7900</span> <span class="comment">// Death test constructor. Increments the running death test count</span></div><div class="line"><a name="l07901"></a><span class="lineno"> 7901</span> <span class="comment">// for the current test.</span></div><div class="line"><a name="l07902"></a><span class="lineno"> 7902</span> DeathTest::DeathTest() {</div><div class="line"><a name="l07903"></a><span class="lineno"> 7903</span>  TestInfo* <span class="keyword">const</span> info = GetUnitTestImpl()->current_test_info();</div><div class="line"><a name="l07904"></a><span class="lineno"> 7904</span>  <span class="keywordflow">if</span> (info == <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l07905"></a><span class="lineno"> 7905</span>  DeathTestAbort(<span class="stringliteral">"Cannot run a death test outside of a TEST or "</span></div><div class="line"><a name="l07906"></a><span class="lineno"> 7906</span>  <span class="stringliteral">"TEST_F construct"</span>);</div><div class="line"><a name="l07907"></a><span class="lineno"> 7907</span>  }</div><div class="line"><a name="l07908"></a><span class="lineno"> 7908</span> }</div><div class="line"><a name="l07909"></a><span class="lineno"> 7909</span> </div><div class="line"><a name="l07910"></a><span class="lineno"> 7910</span> <span class="comment">// Creates and returns a death test by dispatching to the current</span></div><div class="line"><a name="l07911"></a><span class="lineno"> 7911</span> <span class="comment">// death test factory.</span></div><div class="line"><a name="l07912"></a><span class="lineno"> 7912</span> <span class="keywordtype">bool</span> DeathTest::Create(<span class="keyword">const</span> <span class="keywordtype">char</span>* statement,</div><div class="line"><a name="l07913"></a><span class="lineno"> 7913</span>  Matcher<const std::string&> matcher, <span class="keyword">const</span> <span class="keywordtype">char</span>* file,</div><div class="line"><a name="l07914"></a><span class="lineno"> 7914</span>  <span class="keywordtype">int</span> line, DeathTest** test) {</div><div class="line"><a name="l07915"></a><span class="lineno"> 7915</span>  <span class="keywordflow">return</span> GetUnitTestImpl()->death_test_factory()->Create(</div><div class="line"><a name="l07916"></a><span class="lineno"> 7916</span>  statement, std::move(matcher), file, line, test);</div><div class="line"><a name="l07917"></a><span class="lineno"> 7917</span> }</div><div class="line"><a name="l07918"></a><span class="lineno"> 7918</span> </div><div class="line"><a name="l07919"></a><span class="lineno"> 7919</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* DeathTest::LastMessage() {</div><div class="line"><a name="l07920"></a><span class="lineno"> 7920</span>  <span class="keywordflow">return</span> last_death_test_message_.c_str();</div><div class="line"><a name="l07921"></a><span class="lineno"> 7921</span> }</div><div class="line"><a name="l07922"></a><span class="lineno"> 7922</span> </div><div class="line"><a name="l07923"></a><span class="lineno"> 7923</span> <span class="keywordtype">void</span> DeathTest::set_last_death_test_message(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& message) {</div><div class="line"><a name="l07924"></a><span class="lineno"> 7924</span>  last_death_test_message_ = message;</div><div class="line"><a name="l07925"></a><span class="lineno"> 7925</span> }</div><div class="line"><a name="l07926"></a><span class="lineno"> 7926</span> </div><div class="line"><a name="l07927"></a><span class="lineno"> 7927</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> DeathTest::last_death_test_message_;</div><div class="line"><a name="l07928"></a><span class="lineno"> 7928</span> </div><div class="line"><a name="l07929"></a><span class="lineno"> 7929</span> <span class="comment">// Provides cross platform implementation for some death functionality.</span></div><div class="line"><a name="l07930"></a><span class="lineno"> 7930</span> <span class="keyword">class </span>DeathTestImpl : <span class="keyword">public</span> DeathTest {</div><div class="line"><a name="l07931"></a><span class="lineno"> 7931</span>  <span class="keyword">protected</span>:</div><div class="line"><a name="l07932"></a><span class="lineno"> 7932</span>  DeathTestImpl(<span class="keyword">const</span> <span class="keywordtype">char</span>* a_statement, Matcher<const std::string&> matcher)</div><div class="line"><a name="l07933"></a><span class="lineno"> 7933</span>  : statement_(a_statement),</div><div class="line"><a name="l07934"></a><span class="lineno"> 7934</span>  matcher_(std::move(matcher)),</div><div class="line"><a name="l07935"></a><span class="lineno"> 7935</span>  spawned_(false),</div><div class="line"><a name="l07936"></a><span class="lineno"> 7936</span>  status_(-1),</div><div class="line"><a name="l07937"></a><span class="lineno"> 7937</span>  outcome_(IN_PROGRESS),</div><div class="line"><a name="l07938"></a><span class="lineno"> 7938</span>  read_fd_(-1),</div><div class="line"><a name="l07939"></a><span class="lineno"> 7939</span>  write_fd_(-1) {}</div><div class="line"><a name="l07940"></a><span class="lineno"> 7940</span> </div><div class="line"><a name="l07941"></a><span class="lineno"> 7941</span>  <span class="comment">// read_fd_ is expected to be closed and cleared by a derived class.</span></div><div class="line"><a name="l07942"></a><span class="lineno"> 7942</span>  ~DeathTestImpl()<span class="keyword"> override </span>{ GTEST_DEATH_TEST_CHECK_(read_fd_ == -1); }</div><div class="line"><a name="l07943"></a><span class="lineno"> 7943</span> </div><div class="line"><a name="l07944"></a><span class="lineno"> 7944</span>  <span class="keywordtype">void</span> <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a69b8278c59359dd6a6f941b4643db9fb">Abort</a>(AbortReason reason) <span class="keyword">override</span>;</div><div class="line"><a name="l07945"></a><span class="lineno"> 7945</span>  <span class="keywordtype">bool</span> Passed(<span class="keywordtype">bool</span> status_ok) <span class="keyword">override</span>;</div><div class="line"><a name="l07946"></a><span class="lineno"> 7946</span> </div><div class="line"><a name="l07947"></a><span class="lineno"> 7947</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* statement()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> statement_; }</div><div class="line"><a name="l07948"></a><span class="lineno"> 7948</span>  <span class="keywordtype">bool</span> spawned()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> spawned_; }</div><div class="line"><a name="l07949"></a><span class="lineno"> 7949</span>  <span class="keywordtype">void</span> set_spawned(<span class="keywordtype">bool</span> is_spawned) { spawned_ = is_spawned; }</div><div class="line"><a name="l07950"></a><span class="lineno"> 7950</span>  <span class="keywordtype">int</span> status()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> status_; }</div><div class="line"><a name="l07951"></a><span class="lineno"> 7951</span>  <span class="keywordtype">void</span> set_status(<span class="keywordtype">int</span> a_status) { status_ = a_status; }</div><div class="line"><a name="l07952"></a><span class="lineno"> 7952</span>  DeathTestOutcome outcome()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> outcome_; }</div><div class="line"><a name="l07953"></a><span class="lineno"> 7953</span>  <span class="keywordtype">void</span> set_outcome(DeathTestOutcome an_outcome) { outcome_ = an_outcome; }</div><div class="line"><a name="l07954"></a><span class="lineno"> 7954</span>  <span class="keywordtype">int</span> read_fd()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> read_fd_; }</div><div class="line"><a name="l07955"></a><span class="lineno"> 7955</span>  <span class="keywordtype">void</span> set_read_fd(<span class="keywordtype">int</span> fd) { read_fd_ = fd; }</div><div class="line"><a name="l07956"></a><span class="lineno"> 7956</span>  <span class="keywordtype">int</span> write_fd()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> write_fd_; }</div><div class="line"><a name="l07957"></a><span class="lineno"> 7957</span>  <span class="keywordtype">void</span> set_write_fd(<span class="keywordtype">int</span> fd) { write_fd_ = fd; }</div><div class="line"><a name="l07958"></a><span class="lineno"> 7958</span> </div><div class="line"><a name="l07959"></a><span class="lineno"> 7959</span>  <span class="comment">// Called in the parent process only. Reads the result code of the death</span></div><div class="line"><a name="l07960"></a><span class="lineno"> 7960</span>  <span class="comment">// test child process via a pipe, interprets it to set the outcome_</span></div><div class="line"><a name="l07961"></a><span class="lineno"> 7961</span>  <span class="comment">// member, and closes read_fd_. Outputs diagnostics and terminates in</span></div><div class="line"><a name="l07962"></a><span class="lineno"> 7962</span>  <span class="comment">// case of unexpected codes.</span></div><div class="line"><a name="l07963"></a><span class="lineno"> 7963</span>  <span class="keywordtype">void</span> ReadAndInterpretStatusByte();</div><div class="line"><a name="l07964"></a><span class="lineno"> 7964</span> </div><div class="line"><a name="l07965"></a><span class="lineno"> 7965</span>  <span class="comment">// Returns stderr output from the child process.</span></div><div class="line"><a name="l07966"></a><span class="lineno"> 7966</span>  <span class="keyword">virtual</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> GetErrorLogs();</div><div class="line"><a name="l07967"></a><span class="lineno"> 7967</span> </div><div class="line"><a name="l07968"></a><span class="lineno"> 7968</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l07969"></a><span class="lineno"> 7969</span>  <span class="comment">// The textual content of the code this object is testing. This class</span></div><div class="line"><a name="l07970"></a><span class="lineno"> 7970</span>  <span class="comment">// doesn't own this string and should not attempt to delete it.</span></div><div class="line"><a name="l07971"></a><span class="lineno"> 7971</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> statement_;</div><div class="line"><a name="l07972"></a><span class="lineno"> 7972</span>  <span class="comment">// A matcher that's expected to match the stderr output by the child process.</span></div><div class="line"><a name="l07973"></a><span class="lineno"> 7973</span>  Matcher<const std::string&> matcher_;</div><div class="line"><a name="l07974"></a><span class="lineno"> 7974</span>  <span class="comment">// True if the death test child process has been successfully spawned.</span></div><div class="line"><a name="l07975"></a><span class="lineno"> 7975</span>  <span class="keywordtype">bool</span> spawned_;</div><div class="line"><a name="l07976"></a><span class="lineno"> 7976</span>  <span class="comment">// The exit status of the child process.</span></div><div class="line"><a name="l07977"></a><span class="lineno"> 7977</span>  <span class="keywordtype">int</span> status_;</div><div class="line"><a name="l07978"></a><span class="lineno"> 7978</span>  <span class="comment">// How the death test concluded.</span></div><div class="line"><a name="l07979"></a><span class="lineno"> 7979</span>  DeathTestOutcome outcome_;</div><div class="line"><a name="l07980"></a><span class="lineno"> 7980</span>  <span class="comment">// Descriptor to the read end of the pipe to the child process. It is</span></div><div class="line"><a name="l07981"></a><span class="lineno"> 7981</span>  <span class="comment">// always -1 in the child process. The child keeps its write end of the</span></div><div class="line"><a name="l07982"></a><span class="lineno"> 7982</span>  <span class="comment">// pipe in write_fd_.</span></div><div class="line"><a name="l07983"></a><span class="lineno"> 7983</span>  <span class="keywordtype">int</span> read_fd_;</div><div class="line"><a name="l07984"></a><span class="lineno"> 7984</span>  <span class="comment">// Descriptor to the child's write end of the pipe to the parent process.</span></div><div class="line"><a name="l07985"></a><span class="lineno"> 7985</span>  <span class="comment">// It is always -1 in the parent process. The parent keeps its end of the</span></div><div class="line"><a name="l07986"></a><span class="lineno"> 7986</span>  <span class="comment">// pipe in read_fd_.</span></div><div class="line"><a name="l07987"></a><span class="lineno"> 7987</span>  <span class="keywordtype">int</span> write_fd_;</div><div class="line"><a name="l07988"></a><span class="lineno"> 7988</span> };</div><div class="line"><a name="l07989"></a><span class="lineno"> 7989</span> </div><div class="line"><a name="l07990"></a><span class="lineno"> 7990</span> <span class="comment">// Called in the parent process only. Reads the result code of the death</span></div><div class="line"><a name="l07991"></a><span class="lineno"> 7991</span> <span class="comment">// test child process via a pipe, interprets it to set the outcome_</span></div><div class="line"><a name="l07992"></a><span class="lineno"> 7992</span> <span class="comment">// member, and closes read_fd_. Outputs diagnostics and terminates in</span></div><div class="line"><a name="l07993"></a><span class="lineno"> 7993</span> <span class="comment">// case of unexpected codes.</span></div><div class="line"><a name="l07994"></a><span class="lineno"> 7994</span> <span class="keywordtype">void</span> DeathTestImpl::ReadAndInterpretStatusByte() {</div><div class="line"><a name="l07995"></a><span class="lineno"> 7995</span>  <span class="keywordtype">char</span> flag;</div><div class="line"><a name="l07996"></a><span class="lineno"> 7996</span>  <span class="keywordtype">int</span> bytes_read;</div><div class="line"><a name="l07997"></a><span class="lineno"> 7997</span> </div><div class="line"><a name="l07998"></a><span class="lineno"> 7998</span>  <span class="comment">// The read() here blocks until data is available (signifying the</span></div><div class="line"><a name="l07999"></a><span class="lineno"> 7999</span>  <span class="comment">// failure of the death test) or until the pipe is closed (signifying</span></div><div class="line"><a name="l08000"></a><span class="lineno"> 8000</span>  <span class="comment">// its success), so it's okay to call this in the parent before</span></div><div class="line"><a name="l08001"></a><span class="lineno"> 8001</span>  <span class="comment">// the child process has exited.</span></div><div class="line"><a name="l08002"></a><span class="lineno"> 8002</span>  <span class="keywordflow">do</span> {</div><div class="line"><a name="l08003"></a><span class="lineno"> 8003</span>  bytes_read = <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a3c6ab13e581a56f1b02f3eb7536c97fd">posix::Read</a>(read_fd(), &flag, 1);</div><div class="line"><a name="l08004"></a><span class="lineno"> 8004</span>  } <span class="keywordflow">while</span> (bytes_read == -1 && errno == EINTR);</div><div class="line"><a name="l08005"></a><span class="lineno"> 8005</span> </div><div class="line"><a name="l08006"></a><span class="lineno"> 8006</span>  <span class="keywordflow">if</span> (bytes_read == 0) {</div><div class="line"><a name="l08007"></a><span class="lineno"> 8007</span>  set_outcome(DIED);</div><div class="line"><a name="l08008"></a><span class="lineno"> 8008</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (bytes_read == 1) {</div><div class="line"><a name="l08009"></a><span class="lineno"> 8009</span>  <span class="keywordflow">switch</span> (flag) {</div><div class="line"><a name="l08010"></a><span class="lineno"> 8010</span>  <span class="keywordflow">case</span> kDeathTestReturned:</div><div class="line"><a name="l08011"></a><span class="lineno"> 8011</span>  set_outcome(RETURNED);</div><div class="line"><a name="l08012"></a><span class="lineno"> 8012</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l08013"></a><span class="lineno"> 8013</span>  <span class="keywordflow">case</span> kDeathTestThrew:</div><div class="line"><a name="l08014"></a><span class="lineno"> 8014</span>  set_outcome(THREW);</div><div class="line"><a name="l08015"></a><span class="lineno"> 8015</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l08016"></a><span class="lineno"> 8016</span>  <span class="keywordflow">case</span> kDeathTestLived:</div><div class="line"><a name="l08017"></a><span class="lineno"> 8017</span>  set_outcome(LIVED);</div><div class="line"><a name="l08018"></a><span class="lineno"> 8018</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l08019"></a><span class="lineno"> 8019</span>  <span class="keywordflow">case</span> kDeathTestInternalError:</div><div class="line"><a name="l08020"></a><span class="lineno"> 8020</span>  FailFromInternalError(read_fd()); <span class="comment">// Does not return.</span></div><div class="line"><a name="l08021"></a><span class="lineno"> 8021</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l08022"></a><span class="lineno"> 8022</span>  <span class="keywordflow">default</span>:</div><div class="line"><a name="l08023"></a><span class="lineno"> 8023</span>  <a class="code" href="gtest_8h.html#a8ef4cb4c465db8c15464aecc6d9510ef">GTEST_LOG_</a>(FATAL) << <span class="stringliteral">"Death test child process reported "</span></div><div class="line"><a name="l08024"></a><span class="lineno"> 8024</span>  << <span class="stringliteral">"unexpected status byte ("</span></div><div class="line"><a name="l08025"></a><span class="lineno"> 8025</span>  << <span class="keyword">static_cast<</span><span class="keywordtype">unsigned</span> <span class="keywordtype">int</span><span class="keyword">></span>(flag) << <span class="stringliteral">")"</span>;</div><div class="line"><a name="l08026"></a><span class="lineno"> 8026</span>  }</div><div class="line"><a name="l08027"></a><span class="lineno"> 8027</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l08028"></a><span class="lineno"> 8028</span>  <a class="code" href="gtest_8h.html#a8ef4cb4c465db8c15464aecc6d9510ef">GTEST_LOG_</a>(FATAL) << <span class="stringliteral">"Read from death test child process failed: "</span></div><div class="line"><a name="l08029"></a><span class="lineno"> 8029</span>  << GetLastErrnoDescription();</div><div class="line"><a name="l08030"></a><span class="lineno"> 8030</span>  }</div><div class="line"><a name="l08031"></a><span class="lineno"> 8031</span>  GTEST_DEATH_TEST_CHECK_SYSCALL_(<a class="code" href="namespacetesting_1_1internal_1_1posix.html#a15e5b8f2a535ef1b2529b85b861e4846">posix::Close</a>(read_fd()));</div><div class="line"><a name="l08032"></a><span class="lineno"> 8032</span>  set_read_fd(-1);</div><div class="line"><a name="l08033"></a><span class="lineno"> 8033</span> }</div><div class="line"><a name="l08034"></a><span class="lineno"> 8034</span> </div><div class="line"><a name="l08035"></a><span class="lineno"> 8035</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> DeathTestImpl::GetErrorLogs() {</div><div class="line"><a name="l08036"></a><span class="lineno"> 8036</span>  <span class="keywordflow">return</span> <a class="code" href="namespacetesting_1_1internal.html#a374156401da17704099d0c33fa53adfb">GetCapturedStderr</a>();</div><div class="line"><a name="l08037"></a><span class="lineno"> 8037</span> }</div><div class="line"><a name="l08038"></a><span class="lineno"> 8038</span> </div><div class="line"><a name="l08039"></a><span class="lineno"> 8039</span> <span class="comment">// Signals that the death test code which should have exited, didn't.</span></div><div class="line"><a name="l08040"></a><span class="lineno"> 8040</span> <span class="comment">// Should be called only in a death test child process.</span></div><div class="line"><a name="l08041"></a><span class="lineno"> 8041</span> <span class="comment">// Writes a status byte to the child's status file descriptor, then</span></div><div class="line"><a name="l08042"></a><span class="lineno"> 8042</span> <span class="comment">// calls _exit(1).</span></div><div class="line"><a name="l08043"></a><span class="lineno"> 8043</span> <span class="keywordtype">void</span> <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a69b8278c59359dd6a6f941b4643db9fb">DeathTestImpl::Abort</a>(AbortReason reason) {</div><div class="line"><a name="l08044"></a><span class="lineno"> 8044</span>  <span class="comment">// The parent process considers the death test to be a failure if</span></div><div class="line"><a name="l08045"></a><span class="lineno"> 8045</span>  <span class="comment">// it finds any data in our pipe. So, here we write a single flag byte</span></div><div class="line"><a name="l08046"></a><span class="lineno"> 8046</span>  <span class="comment">// to the pipe, then exit.</span></div><div class="line"><a name="l08047"></a><span class="lineno"> 8047</span>  <span class="keyword">const</span> <span class="keywordtype">char</span> status_ch =</div><div class="line"><a name="l08048"></a><span class="lineno"> 8048</span>  reason == TEST_DID_NOT_DIE ? kDeathTestLived :</div><div class="line"><a name="l08049"></a><span class="lineno"> 8049</span>  reason == TEST_THREW_EXCEPTION ? kDeathTestThrew : kDeathTestReturned;</div><div class="line"><a name="l08050"></a><span class="lineno"> 8050</span> </div><div class="line"><a name="l08051"></a><span class="lineno"> 8051</span>  GTEST_DEATH_TEST_CHECK_SYSCALL_(<a class="code" href="namespacetesting_1_1internal_1_1posix.html#af4acf9f78d55f815a18b43786511abef">posix::Write</a>(write_fd(), &status_ch, 1));</div><div class="line"><a name="l08052"></a><span class="lineno"> 8052</span>  <span class="comment">// We are leaking the descriptor here because on some platforms (i.e.,</span></div><div class="line"><a name="l08053"></a><span class="lineno"> 8053</span>  <span class="comment">// when built as Windows DLL), destructors of global objects will still</span></div><div class="line"><a name="l08054"></a><span class="lineno"> 8054</span>  <span class="comment">// run after calling _exit(). On such systems, write_fd_ will be</span></div><div class="line"><a name="l08055"></a><span class="lineno"> 8055</span>  <span class="comment">// indirectly closed from the destructor of UnitTestImpl, causing double</span></div><div class="line"><a name="l08056"></a><span class="lineno"> 8056</span>  <span class="comment">// close if it is also closed here. On debug configurations, double close</span></div><div class="line"><a name="l08057"></a><span class="lineno"> 8057</span>  <span class="comment">// may assert. As there are no in-process buffers to flush here, we are</span></div><div class="line"><a name="l08058"></a><span class="lineno"> 8058</span>  <span class="comment">// relying on the OS to close the descriptor after the process terminates</span></div><div class="line"><a name="l08059"></a><span class="lineno"> 8059</span>  <span class="comment">// when the destructors are not run.</span></div><div class="line"><a name="l08060"></a><span class="lineno"> 8060</span>  _exit(1); <span class="comment">// Exits w/o any normal exit hooks (we were supposed to crash)</span></div><div class="line"><a name="l08061"></a><span class="lineno"> 8061</span> }</div><div class="line"><a name="l08062"></a><span class="lineno"> 8062</span> </div><div class="line"><a name="l08063"></a><span class="lineno"> 8063</span> <span class="comment">// Returns an indented copy of stderr output for a death test.</span></div><div class="line"><a name="l08064"></a><span class="lineno"> 8064</span> <span class="comment">// This makes distinguishing death test output lines from regular log lines</span></div><div class="line"><a name="l08065"></a><span class="lineno"> 8065</span> <span class="comment">// much easier.</span></div><div class="line"><a name="l08066"></a><span class="lineno"> 8066</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">static ::std::string</a> FormatDeathTestOutput(<a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">const ::std::string</a>& output) {</div><div class="line"><a name="l08067"></a><span class="lineno"> 8067</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">::std::string</a> ret;</div><div class="line"><a name="l08068"></a><span class="lineno"> 8068</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> <a class="code" href="namespaceutl_1_1meta.html#a67329ec425c857dcaf4cde9044674c90">at</a> = 0; ; ) {</div><div class="line"><a name="l08069"></a><span class="lineno"> 8069</span>  <span class="keyword">const</span> <span class="keywordtype">size_t</span> line_end = output.find(<span class="charliteral">'\n'</span>, <a class="code" href="namespaceutl_1_1meta.html#a67329ec425c857dcaf4cde9044674c90">at</a>);</div><div class="line"><a name="l08070"></a><span class="lineno"> 8070</span>  ret += <span class="stringliteral">"[ DEATH ] "</span>;</div><div class="line"><a name="l08071"></a><span class="lineno"> 8071</span>  <span class="keywordflow">if</span> (line_end == ::std::string::npos) {</div><div class="line"><a name="l08072"></a><span class="lineno"> 8072</span>  ret += output.substr(<a class="code" href="namespaceutl_1_1meta.html#a67329ec425c857dcaf4cde9044674c90">at</a>);</div><div class="line"><a name="l08073"></a><span class="lineno"> 8073</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l08074"></a><span class="lineno"> 8074</span>  }</div><div class="line"><a name="l08075"></a><span class="lineno"> 8075</span>  ret += output.substr(<a class="code" href="namespaceutl_1_1meta.html#a67329ec425c857dcaf4cde9044674c90">at</a>, line_end + 1 - <a class="code" href="namespaceutl_1_1meta.html#a67329ec425c857dcaf4cde9044674c90">at</a>);</div><div class="line"><a name="l08076"></a><span class="lineno"> 8076</span>  <a class="code" href="namespaceutl_1_1meta.html#a67329ec425c857dcaf4cde9044674c90">at</a> = line_end + 1;</div><div class="line"><a name="l08077"></a><span class="lineno"> 8077</span>  }</div><div class="line"><a name="l08078"></a><span class="lineno"> 8078</span>  <span class="keywordflow">return</span> ret;</div><div class="line"><a name="l08079"></a><span class="lineno"> 8079</span> }</div><div class="line"><a name="l08080"></a><span class="lineno"> 8080</span> </div><div class="line"><a name="l08081"></a><span class="lineno"> 8081</span> <span class="comment">// Assesses the success or failure of a death test, using both private</span></div><div class="line"><a name="l08082"></a><span class="lineno"> 8082</span> <span class="comment">// members which have previously been set, and one argument:</span></div><div class="line"><a name="l08083"></a><span class="lineno"> 8083</span> <span class="comment">//</span></div><div class="line"><a name="l08084"></a><span class="lineno"> 8084</span> <span class="comment">// Private data members:</span></div><div class="line"><a name="l08085"></a><span class="lineno"> 8085</span> <span class="comment">// outcome: An enumeration describing how the death test</span></div><div class="line"><a name="l08086"></a><span class="lineno"> 8086</span> <span class="comment">// concluded: DIED, LIVED, THREW, or RETURNED. The death test</span></div><div class="line"><a name="l08087"></a><span class="lineno"> 8087</span> <span class="comment">// fails in the latter three cases.</span></div><div class="line"><a name="l08088"></a><span class="lineno"> 8088</span> <span class="comment">// status: The exit status of the child process. On *nix, it is in the</span></div><div class="line"><a name="l08089"></a><span class="lineno"> 8089</span> <span class="comment">// in the format specified by wait(2). On Windows, this is the</span></div><div class="line"><a name="l08090"></a><span class="lineno"> 8090</span> <span class="comment">// value supplied to the ExitProcess() API or a numeric code</span></div><div class="line"><a name="l08091"></a><span class="lineno"> 8091</span> <span class="comment">// of the exception that terminated the program.</span></div><div class="line"><a name="l08092"></a><span class="lineno"> 8092</span> <span class="comment">// matcher_: A matcher that's expected to match the stderr output by the child</span></div><div class="line"><a name="l08093"></a><span class="lineno"> 8093</span> <span class="comment">// process.</span></div><div class="line"><a name="l08094"></a><span class="lineno"> 8094</span> <span class="comment">//</span></div><div class="line"><a name="l08095"></a><span class="lineno"> 8095</span> <span class="comment">// Argument:</span></div><div class="line"><a name="l08096"></a><span class="lineno"> 8096</span> <span class="comment">// status_ok: true if exit_status is acceptable in the context of</span></div><div class="line"><a name="l08097"></a><span class="lineno"> 8097</span> <span class="comment">// this particular death test, which fails if it is false</span></div><div class="line"><a name="l08098"></a><span class="lineno"> 8098</span> <span class="comment">//</span></div><div class="line"><a name="l08099"></a><span class="lineno"> 8099</span> <span class="comment">// Returns true iff all of the above conditions are met. Otherwise, the</span></div><div class="line"><a name="l08100"></a><span class="lineno"> 8100</span> <span class="comment">// first failing condition, in the order given above, is the one that is</span></div><div class="line"><a name="l08101"></a><span class="lineno"> 8101</span> <span class="comment">// reported. Also sets the last death test message string.</span></div><div class="line"><a name="l08102"></a><span class="lineno"> 8102</span> <span class="keywordtype">bool</span> DeathTestImpl::Passed(<span class="keywordtype">bool</span> status_ok) {</div><div class="line"><a name="l08103"></a><span class="lineno"> 8103</span>  <span class="keywordflow">if</span> (!spawned())</div><div class="line"><a name="l08104"></a><span class="lineno"> 8104</span>  <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l08105"></a><span class="lineno"> 8105</span> </div><div class="line"><a name="l08106"></a><span class="lineno"> 8106</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> error_message = GetErrorLogs();</div><div class="line"><a name="l08107"></a><span class="lineno"> 8107</span> </div><div class="line"><a name="l08108"></a><span class="lineno"> 8108</span>  <span class="keywordtype">bool</span> success = <span class="keyword">false</span>;</div><div class="line"><a name="l08109"></a><span class="lineno"> 8109</span>  Message buffer;</div><div class="line"><a name="l08110"></a><span class="lineno"> 8110</span> </div><div class="line"><a name="l08111"></a><span class="lineno"> 8111</span>  buffer << <span class="stringliteral">"Death test: "</span> << statement() << <span class="stringliteral">"\n"</span>;</div><div class="line"><a name="l08112"></a><span class="lineno"> 8112</span>  <span class="keywordflow">switch</span> (outcome()) {</div><div class="line"><a name="l08113"></a><span class="lineno"> 8113</span>  <span class="keywordflow">case</span> LIVED:</div><div class="line"><a name="l08114"></a><span class="lineno"> 8114</span>  buffer << <span class="stringliteral">" Result: failed to die.\n"</span></div><div class="line"><a name="l08115"></a><span class="lineno"> 8115</span>  << <span class="stringliteral">" Error msg:\n"</span> << FormatDeathTestOutput(error_message);</div><div class="line"><a name="l08116"></a><span class="lineno"> 8116</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l08117"></a><span class="lineno"> 8117</span>  <span class="keywordflow">case</span> THREW:</div><div class="line"><a name="l08118"></a><span class="lineno"> 8118</span>  buffer << <span class="stringliteral">" Result: threw an exception.\n"</span></div><div class="line"><a name="l08119"></a><span class="lineno"> 8119</span>  << <span class="stringliteral">" Error msg:\n"</span> << FormatDeathTestOutput(error_message);</div><div class="line"><a name="l08120"></a><span class="lineno"> 8120</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l08121"></a><span class="lineno"> 8121</span>  <span class="keywordflow">case</span> RETURNED:</div><div class="line"><a name="l08122"></a><span class="lineno"> 8122</span>  buffer << <span class="stringliteral">" Result: illegal return in test statement.\n"</span></div><div class="line"><a name="l08123"></a><span class="lineno"> 8123</span>  << <span class="stringliteral">" Error msg:\n"</span> << FormatDeathTestOutput(error_message);</div><div class="line"><a name="l08124"></a><span class="lineno"> 8124</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l08125"></a><span class="lineno"> 8125</span>  <span class="keywordflow">case</span> DIED:</div><div class="line"><a name="l08126"></a><span class="lineno"> 8126</span>  <span class="keywordflow">if</span> (status_ok) {</div><div class="line"><a name="l08127"></a><span class="lineno"> 8127</span>  <span class="keywordflow">if</span> (matcher_.Matches(error_message)) {</div><div class="line"><a name="l08128"></a><span class="lineno"> 8128</span>  success = <span class="keyword">true</span>;</div><div class="line"><a name="l08129"></a><span class="lineno"> 8129</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l08130"></a><span class="lineno"> 8130</span>  std::ostringstream stream;</div><div class="line"><a name="l08131"></a><span class="lineno"> 8131</span>  matcher_.DescribeTo(&stream);</div><div class="line"><a name="l08132"></a><span class="lineno"> 8132</span>  buffer << <span class="stringliteral">" Result: died but not with expected error.\n"</span></div><div class="line"><a name="l08133"></a><span class="lineno"> 8133</span>  << <span class="stringliteral">" Expected: "</span> << stream.str() << <span class="stringliteral">"\n"</span></div><div class="line"><a name="l08134"></a><span class="lineno"> 8134</span>  << <span class="stringliteral">"Actual msg:\n"</span></div><div class="line"><a name="l08135"></a><span class="lineno"> 8135</span>  << FormatDeathTestOutput(error_message);</div><div class="line"><a name="l08136"></a><span class="lineno"> 8136</span>  }</div><div class="line"><a name="l08137"></a><span class="lineno"> 8137</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l08138"></a><span class="lineno"> 8138</span>  buffer << <span class="stringliteral">" Result: died but not with expected exit code:\n"</span></div><div class="line"><a name="l08139"></a><span class="lineno"> 8139</span>  << <span class="stringliteral">" "</span> << ExitSummary(status()) << <span class="stringliteral">"\n"</span></div><div class="line"><a name="l08140"></a><span class="lineno"> 8140</span>  << <span class="stringliteral">"Actual msg:\n"</span> << FormatDeathTestOutput(error_message);</div><div class="line"><a name="l08141"></a><span class="lineno"> 8141</span>  }</div><div class="line"><a name="l08142"></a><span class="lineno"> 8142</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l08143"></a><span class="lineno"> 8143</span>  <span class="keywordflow">case</span> IN_PROGRESS:</div><div class="line"><a name="l08144"></a><span class="lineno"> 8144</span>  <span class="keywordflow">default</span>:</div><div class="line"><a name="l08145"></a><span class="lineno"> 8145</span>  <a class="code" href="gtest_8h.html#a8ef4cb4c465db8c15464aecc6d9510ef">GTEST_LOG_</a>(FATAL)</div><div class="line"><a name="l08146"></a><span class="lineno"> 8146</span>  << <span class="stringliteral">"DeathTest::Passed somehow called before conclusion of test"</span>;</div><div class="line"><a name="l08147"></a><span class="lineno"> 8147</span>  }</div><div class="line"><a name="l08148"></a><span class="lineno"> 8148</span> </div><div class="line"><a name="l08149"></a><span class="lineno"> 8149</span>  DeathTest::set_last_death_test_message(buffer.GetString());</div><div class="line"><a name="l08150"></a><span class="lineno"> 8150</span>  <span class="keywordflow">return</span> success;</div><div class="line"><a name="l08151"></a><span class="lineno"> 8151</span> }</div><div class="line"><a name="l08152"></a><span class="lineno"> 8152</span> </div><div class="line"><a name="l08153"></a><span class="lineno"> 8153</span> <span class="preprocessor"># if GTEST_OS_WINDOWS</span></div><div class="line"><a name="l08154"></a><span class="lineno"> 8154</span> <span class="comment">// WindowsDeathTest implements death tests on Windows. Due to the</span></div><div class="line"><a name="l08155"></a><span class="lineno"> 8155</span> <span class="comment">// specifics of starting new processes on Windows, death tests there are</span></div><div class="line"><a name="l08156"></a><span class="lineno"> 8156</span> <span class="comment">// always threadsafe, and Google Test considers the</span></div><div class="line"><a name="l08157"></a><span class="lineno"> 8157</span> <span class="comment">// --gtest_death_test_style=fast setting to be equivalent to</span></div><div class="line"><a name="l08158"></a><span class="lineno"> 8158</span> <span class="comment">// --gtest_death_test_style=threadsafe there.</span></div><div class="line"><a name="l08159"></a><span class="lineno"> 8159</span> <span class="comment">//</span></div><div class="line"><a name="l08160"></a><span class="lineno"> 8160</span> <span class="comment">// A few implementation notes: Like the Linux version, the Windows</span></div><div class="line"><a name="l08161"></a><span class="lineno"> 8161</span> <span class="comment">// implementation uses pipes for child-to-parent communication. But due to</span></div><div class="line"><a name="l08162"></a><span class="lineno"> 8162</span> <span class="comment">// the specifics of pipes on Windows, some extra steps are required:</span></div><div class="line"><a name="l08163"></a><span class="lineno"> 8163</span> <span class="comment">//</span></div><div class="line"><a name="l08164"></a><span class="lineno"> 8164</span> <span class="comment">// 1. The parent creates a communication pipe and stores handles to both</span></div><div class="line"><a name="l08165"></a><span class="lineno"> 8165</span> <span class="comment">// ends of it.</span></div><div class="line"><a name="l08166"></a><span class="lineno"> 8166</span> <span class="comment">// 2. The parent starts the child and provides it with the information</span></div><div class="line"><a name="l08167"></a><span class="lineno"> 8167</span> <span class="comment">// necessary to acquire the handle to the write end of the pipe.</span></div><div class="line"><a name="l08168"></a><span class="lineno"> 8168</span> <span class="comment">// 3. The child acquires the write end of the pipe and signals the parent</span></div><div class="line"><a name="l08169"></a><span class="lineno"> 8169</span> <span class="comment">// using a Windows event.</span></div><div class="line"><a name="l08170"></a><span class="lineno"> 8170</span> <span class="comment">// 4. Now the parent can release the write end of the pipe on its side. If</span></div><div class="line"><a name="l08171"></a><span class="lineno"> 8171</span> <span class="comment">// this is done before step 3, the object's reference count goes down to</span></div><div class="line"><a name="l08172"></a><span class="lineno"> 8172</span> <span class="comment">// 0 and it is destroyed, preventing the child from acquiring it. The</span></div><div class="line"><a name="l08173"></a><span class="lineno"> 8173</span> <span class="comment">// parent now has to release it, or read operations on the read end of</span></div><div class="line"><a name="l08174"></a><span class="lineno"> 8174</span> <span class="comment">// the pipe will not return when the child terminates.</span></div><div class="line"><a name="l08175"></a><span class="lineno"> 8175</span> <span class="comment">// 5. The parent reads child's output through the pipe (outcome code and</span></div><div class="line"><a name="l08176"></a><span class="lineno"> 8176</span> <span class="comment">// any possible error messages) from the pipe, and its stderr and then</span></div><div class="line"><a name="l08177"></a><span class="lineno"> 8177</span> <span class="comment">// determines whether to fail the test.</span></div><div class="line"><a name="l08178"></a><span class="lineno"> 8178</span> <span class="comment">//</span></div><div class="line"><a name="l08179"></a><span class="lineno"> 8179</span> <span class="comment">// Note: to distinguish Win32 API calls from the local method and function</span></div><div class="line"><a name="l08180"></a><span class="lineno"> 8180</span> <span class="comment">// calls, the former are explicitly resolved in the global namespace.</span></div><div class="line"><a name="l08181"></a><span class="lineno"> 8181</span> <span class="comment">//</span></div><div class="line"><a name="l08182"></a><span class="lineno"> 8182</span> <span class="keyword">class </span>WindowsDeathTest : <span class="keyword">public</span> DeathTestImpl {</div><div class="line"><a name="l08183"></a><span class="lineno"> 8183</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l08184"></a><span class="lineno"> 8184</span>  WindowsDeathTest(<span class="keyword">const</span> <span class="keywordtype">char</span>* a_statement, Matcher<const std::string&> matcher,</div><div class="line"><a name="l08185"></a><span class="lineno"> 8185</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* file, <span class="keywordtype">int</span> line)</div><div class="line"><a name="l08186"></a><span class="lineno"> 8186</span>  : DeathTestImpl(a_statement, std::move(matcher)),</div><div class="line"><a name="l08187"></a><span class="lineno"> 8187</span>  file_(file),</div><div class="line"><a name="l08188"></a><span class="lineno"> 8188</span>  line_(line) {}</div><div class="line"><a name="l08189"></a><span class="lineno"> 8189</span> </div><div class="line"><a name="l08190"></a><span class="lineno"> 8190</span>  <span class="comment">// All of these virtual functions are inherited from DeathTest.</span></div><div class="line"><a name="l08191"></a><span class="lineno"> 8191</span>  <span class="keyword">virtual</span> <span class="keywordtype">int</span> Wait();</div><div class="line"><a name="l08192"></a><span class="lineno"> 8192</span>  <span class="keyword">virtual</span> TestRole AssumeRole();</div><div class="line"><a name="l08193"></a><span class="lineno"> 8193</span> </div><div class="line"><a name="l08194"></a><span class="lineno"> 8194</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l08195"></a><span class="lineno"> 8195</span>  <span class="comment">// The name of the file in which the death test is located.</span></div><div class="line"><a name="l08196"></a><span class="lineno"> 8196</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> file_;</div><div class="line"><a name="l08197"></a><span class="lineno"> 8197</span>  <span class="comment">// The line number on which the death test is located.</span></div><div class="line"><a name="l08198"></a><span class="lineno"> 8198</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> line_;</div><div class="line"><a name="l08199"></a><span class="lineno"> 8199</span>  <span class="comment">// Handle to the write end of the pipe to the child process.</span></div><div class="line"><a name="l08200"></a><span class="lineno"> 8200</span>  AutoHandle write_handle_;</div><div class="line"><a name="l08201"></a><span class="lineno"> 8201</span>  <span class="comment">// Child process handle.</span></div><div class="line"><a name="l08202"></a><span class="lineno"> 8202</span>  AutoHandle child_handle_;</div><div class="line"><a name="l08203"></a><span class="lineno"> 8203</span>  <span class="comment">// Event the child process uses to signal the parent that it has</span></div><div class="line"><a name="l08204"></a><span class="lineno"> 8204</span>  <span class="comment">// acquired the handle to the write end of the pipe. After seeing this</span></div><div class="line"><a name="l08205"></a><span class="lineno"> 8205</span>  <span class="comment">// event the parent can release its own handles to make sure its</span></div><div class="line"><a name="l08206"></a><span class="lineno"> 8206</span>  <span class="comment">// ReadFile() calls return when the child terminates.</span></div><div class="line"><a name="l08207"></a><span class="lineno"> 8207</span>  AutoHandle event_handle_;</div><div class="line"><a name="l08208"></a><span class="lineno"> 8208</span> };</div><div class="line"><a name="l08209"></a><span class="lineno"> 8209</span> </div><div class="line"><a name="l08210"></a><span class="lineno"> 8210</span> <span class="comment">// Waits for the child in a death test to exit, returning its exit</span></div><div class="line"><a name="l08211"></a><span class="lineno"> 8211</span> <span class="comment">// status, or 0 if no child process exists. As a side effect, sets the</span></div><div class="line"><a name="l08212"></a><span class="lineno"> 8212</span> <span class="comment">// outcome data member.</span></div><div class="line"><a name="l08213"></a><span class="lineno"> 8213</span> <span class="keywordtype">int</span> WindowsDeathTest::Wait() {</div><div class="line"><a name="l08214"></a><span class="lineno"> 8214</span>  <span class="keywordflow">if</span> (!spawned())</div><div class="line"><a name="l08215"></a><span class="lineno"> 8215</span>  <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l08216"></a><span class="lineno"> 8216</span> </div><div class="line"><a name="l08217"></a><span class="lineno"> 8217</span>  <span class="comment">// Wait until the child either signals that it has acquired the write end</span></div><div class="line"><a name="l08218"></a><span class="lineno"> 8218</span>  <span class="comment">// of the pipe or it dies.</span></div><div class="line"><a name="l08219"></a><span class="lineno"> 8219</span>  <span class="keyword">const</span> HANDLE wait_handles[2] = { child_handle_.Get(), event_handle_.Get() };</div><div class="line"><a name="l08220"></a><span class="lineno"> 8220</span>  <span class="keywordflow">switch</span> (::WaitForMultipleObjects(2,</div><div class="line"><a name="l08221"></a><span class="lineno"> 8221</span>  wait_handles,</div><div class="line"><a name="l08222"></a><span class="lineno"> 8222</span>  FALSE, <span class="comment">// Waits for any of the handles.</span></div><div class="line"><a name="l08223"></a><span class="lineno"> 8223</span>  INFINITE)) {</div><div class="line"><a name="l08224"></a><span class="lineno"> 8224</span>  <span class="keywordflow">case</span> WAIT_OBJECT_0:</div><div class="line"><a name="l08225"></a><span class="lineno"> 8225</span>  <span class="keywordflow">case</span> WAIT_OBJECT_0 + 1:</div><div class="line"><a name="l08226"></a><span class="lineno"> 8226</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l08227"></a><span class="lineno"> 8227</span>  <span class="keywordflow">default</span>:</div><div class="line"><a name="l08228"></a><span class="lineno"> 8228</span>  GTEST_DEATH_TEST_CHECK_(<span class="keyword">false</span>); <span class="comment">// Should not get here.</span></div><div class="line"><a name="l08229"></a><span class="lineno"> 8229</span>  }</div><div class="line"><a name="l08230"></a><span class="lineno"> 8230</span> </div><div class="line"><a name="l08231"></a><span class="lineno"> 8231</span>  <span class="comment">// The child has acquired the write end of the pipe or exited.</span></div><div class="line"><a name="l08232"></a><span class="lineno"> 8232</span>  <span class="comment">// We release the handle on our side and continue.</span></div><div class="line"><a name="l08233"></a><span class="lineno"> 8233</span>  write_handle_.Reset();</div><div class="line"><a name="l08234"></a><span class="lineno"> 8234</span>  event_handle_.Reset();</div><div class="line"><a name="l08235"></a><span class="lineno"> 8235</span> </div><div class="line"><a name="l08236"></a><span class="lineno"> 8236</span>  ReadAndInterpretStatusByte();</div><div class="line"><a name="l08237"></a><span class="lineno"> 8237</span> </div><div class="line"><a name="l08238"></a><span class="lineno"> 8238</span>  <span class="comment">// Waits for the child process to exit if it haven't already. This</span></div><div class="line"><a name="l08239"></a><span class="lineno"> 8239</span>  <span class="comment">// returns immediately if the child has already exited, regardless of</span></div><div class="line"><a name="l08240"></a><span class="lineno"> 8240</span>  <span class="comment">// whether previous calls to WaitForMultipleObjects synchronized on this</span></div><div class="line"><a name="l08241"></a><span class="lineno"> 8241</span>  <span class="comment">// handle or not.</span></div><div class="line"><a name="l08242"></a><span class="lineno"> 8242</span>  GTEST_DEATH_TEST_CHECK_(</div><div class="line"><a name="l08243"></a><span class="lineno"> 8243</span>  WAIT_OBJECT_0 == ::WaitForSingleObject(child_handle_.Get(),</div><div class="line"><a name="l08244"></a><span class="lineno"> 8244</span>  INFINITE));</div><div class="line"><a name="l08245"></a><span class="lineno"> 8245</span>  DWORD status_code;</div><div class="line"><a name="l08246"></a><span class="lineno"> 8246</span>  GTEST_DEATH_TEST_CHECK_(</div><div class="line"><a name="l08247"></a><span class="lineno"> 8247</span>  ::GetExitCodeProcess(child_handle_.Get(), &status_code) != FALSE);</div><div class="line"><a name="l08248"></a><span class="lineno"> 8248</span>  child_handle_.Reset();</div><div class="line"><a name="l08249"></a><span class="lineno"> 8249</span>  set_status(static_cast<int>(status_code));</div><div class="line"><a name="l08250"></a><span class="lineno"> 8250</span>  <span class="keywordflow">return</span> status();</div><div class="line"><a name="l08251"></a><span class="lineno"> 8251</span> }</div><div class="line"><a name="l08252"></a><span class="lineno"> 8252</span> </div><div class="line"><a name="l08253"></a><span class="lineno"> 8253</span> <span class="comment">// The AssumeRole process for a Windows death test. It creates a child</span></div><div class="line"><a name="l08254"></a><span class="lineno"> 8254</span> <span class="comment">// process with the same executable as the current process to run the</span></div><div class="line"><a name="l08255"></a><span class="lineno"> 8255</span> <span class="comment">// death test. The child process is given the --gtest_filter and</span></div><div class="line"><a name="l08256"></a><span class="lineno"> 8256</span> <span class="comment">// --gtest_internal_run_death_test flags such that it knows to run the</span></div><div class="line"><a name="l08257"></a><span class="lineno"> 8257</span> <span class="comment">// current death test only.</span></div><div class="line"><a name="l08258"></a><span class="lineno"> 8258</span> DeathTest::TestRole WindowsDeathTest::AssumeRole() {</div><div class="line"><a name="l08259"></a><span class="lineno"> 8259</span>  <span class="keyword">const</span> UnitTestImpl* <span class="keyword">const</span> impl = GetUnitTestImpl();</div><div class="line"><a name="l08260"></a><span class="lineno"> 8260</span>  <span class="keyword">const</span> InternalRunDeathTestFlag* <span class="keyword">const</span> flag =</div><div class="line"><a name="l08261"></a><span class="lineno"> 8261</span>  impl->internal_run_death_test_flag();</div><div class="line"><a name="l08262"></a><span class="lineno"> 8262</span>  <span class="keyword">const</span> TestInfo* <span class="keyword">const</span> info = impl->current_test_info();</div><div class="line"><a name="l08263"></a><span class="lineno"> 8263</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> death_test_index = info->result()->death_test_count();</div><div class="line"><a name="l08264"></a><span class="lineno"> 8264</span> </div><div class="line"><a name="l08265"></a><span class="lineno"> 8265</span>  <span class="keywordflow">if</span> (flag != <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l08266"></a><span class="lineno"> 8266</span>  <span class="comment">// ParseInternalRunDeathTestFlag() has performed all the necessary</span></div><div class="line"><a name="l08267"></a><span class="lineno"> 8267</span>  <span class="comment">// processing.</span></div><div class="line"><a name="l08268"></a><span class="lineno"> 8268</span>  set_write_fd(flag->write_fd());</div><div class="line"><a name="l08269"></a><span class="lineno"> 8269</span>  <span class="keywordflow">return</span> EXECUTE_TEST;</div><div class="line"><a name="l08270"></a><span class="lineno"> 8270</span>  }</div><div class="line"><a name="l08271"></a><span class="lineno"> 8271</span> </div><div class="line"><a name="l08272"></a><span class="lineno"> 8272</span>  <span class="comment">// WindowsDeathTest uses an anonymous pipe to communicate results of</span></div><div class="line"><a name="l08273"></a><span class="lineno"> 8273</span>  <span class="comment">// a death test.</span></div><div class="line"><a name="l08274"></a><span class="lineno"> 8274</span>  SECURITY_ATTRIBUTES handles_are_inheritable = {<span class="keyword">sizeof</span>(SECURITY_ATTRIBUTES),</div><div class="line"><a name="l08275"></a><span class="lineno"> 8275</span>  <span class="keyword">nullptr</span>, TRUE};</div><div class="line"><a name="l08276"></a><span class="lineno"> 8276</span>  HANDLE read_handle, write_handle;</div><div class="line"><a name="l08277"></a><span class="lineno"> 8277</span>  GTEST_DEATH_TEST_CHECK_(</div><div class="line"><a name="l08278"></a><span class="lineno"> 8278</span>  ::CreatePipe(&read_handle, &write_handle, &handles_are_inheritable,</div><div class="line"><a name="l08279"></a><span class="lineno"> 8279</span>  0) <span class="comment">// Default buffer size.</span></div><div class="line"><a name="l08280"></a><span class="lineno"> 8280</span>  != FALSE);</div><div class="line"><a name="l08281"></a><span class="lineno"> 8281</span>  set_read_fd(::_open_osfhandle(reinterpret_cast<intptr_t>(read_handle),</div><div class="line"><a name="l08282"></a><span class="lineno"> 8282</span>  O_RDONLY));</div><div class="line"><a name="l08283"></a><span class="lineno"> 8283</span>  write_handle_.Reset(write_handle);</div><div class="line"><a name="l08284"></a><span class="lineno"> 8284</span>  event_handle_.Reset(::CreateEvent(</div><div class="line"><a name="l08285"></a><span class="lineno"> 8285</span>  &handles_are_inheritable,</div><div class="line"><a name="l08286"></a><span class="lineno"> 8286</span>  TRUE, <span class="comment">// The event will automatically reset to non-signaled state.</span></div><div class="line"><a name="l08287"></a><span class="lineno"> 8287</span>  FALSE, <span class="comment">// The initial state is non-signalled.</span></div><div class="line"><a name="l08288"></a><span class="lineno"> 8288</span>  <span class="keyword">nullptr</span>)); <span class="comment">// The even is unnamed.</span></div><div class="line"><a name="l08289"></a><span class="lineno"> 8289</span>  GTEST_DEATH_TEST_CHECK_(event_handle_.Get() != <span class="keyword">nullptr</span>);</div><div class="line"><a name="l08290"></a><span class="lineno"> 8290</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> filter_flag = <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(<span class="stringliteral">"--"</span>) + <a class="code" href="gtest_8h.html#a088e84784c589ba9b1fc48602ad8eabf">GTEST_FLAG_PREFIX_</a> +</div><div class="line"><a name="l08291"></a><span class="lineno"> 8291</span>  kFilterFlag + <span class="stringliteral">"="</span> + info->test_suite_name() +</div><div class="line"><a name="l08292"></a><span class="lineno"> 8292</span>  <span class="stringliteral">"."</span> + info->name();</div><div class="line"><a name="l08293"></a><span class="lineno"> 8293</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> internal_flag =</div><div class="line"><a name="l08294"></a><span class="lineno"> 8294</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(<span class="stringliteral">"--"</span>) + <a class="code" href="gtest_8h.html#a088e84784c589ba9b1fc48602ad8eabf">GTEST_FLAG_PREFIX_</a> + kInternalRunDeathTestFlag +</div><div class="line"><a name="l08295"></a><span class="lineno"> 8295</span>  <span class="stringliteral">"="</span> + file_ + <span class="stringliteral">"|"</span> + <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(line_) + <span class="stringliteral">"|"</span> +</div><div class="line"><a name="l08296"></a><span class="lineno"> 8296</span>  <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(death_test_index) + <span class="stringliteral">"|"</span> +</div><div class="line"><a name="l08297"></a><span class="lineno"> 8297</span>  <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(static_cast<unsigned int>(::GetCurrentProcessId())) +</div><div class="line"><a name="l08298"></a><span class="lineno"> 8298</span>  <span class="comment">// size_t has the same width as pointers on both 32-bit and 64-bit</span></div><div class="line"><a name="l08299"></a><span class="lineno"> 8299</span>  <span class="comment">// Windows platforms.</span></div><div class="line"><a name="l08300"></a><span class="lineno"> 8300</span>  <span class="comment">// See http://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx.</span></div><div class="line"><a name="l08301"></a><span class="lineno"> 8301</span>  <span class="stringliteral">"|"</span> + <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(reinterpret_cast<size_t>(write_handle)) +</div><div class="line"><a name="l08302"></a><span class="lineno"> 8302</span>  <span class="stringliteral">"|"</span> + <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(reinterpret_cast<size_t>(event_handle_.Get()));</div><div class="line"><a name="l08303"></a><span class="lineno"> 8303</span> </div><div class="line"><a name="l08304"></a><span class="lineno"> 8304</span>  <span class="keywordtype">char</span> executable_path[_MAX_PATH + 1]; <span class="comment">// NOLINT</span></div><div class="line"><a name="l08305"></a><span class="lineno"> 8305</span>  GTEST_DEATH_TEST_CHECK_(_MAX_PATH + 1 != ::GetModuleFileNameA(<span class="keyword">nullptr</span>,</div><div class="line"><a name="l08306"></a><span class="lineno"> 8306</span>  executable_path,</div><div class="line"><a name="l08307"></a><span class="lineno"> 8307</span>  _MAX_PATH));</div><div class="line"><a name="l08308"></a><span class="lineno"> 8308</span> </div><div class="line"><a name="l08309"></a><span class="lineno"> 8309</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> command_line =</div><div class="line"><a name="l08310"></a><span class="lineno"> 8310</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(::GetCommandLineA()) + <span class="stringliteral">" "</span> + filter_flag + <span class="stringliteral">" \""</span> +</div><div class="line"><a name="l08311"></a><span class="lineno"> 8311</span>  internal_flag + <span class="stringliteral">"\""</span>;</div><div class="line"><a name="l08312"></a><span class="lineno"> 8312</span> </div><div class="line"><a name="l08313"></a><span class="lineno"> 8313</span>  DeathTest::set_last_death_test_message(<span class="stringliteral">""</span>);</div><div class="line"><a name="l08314"></a><span class="lineno"> 8314</span> </div><div class="line"><a name="l08315"></a><span class="lineno"> 8315</span>  <a class="code" href="namespacetesting_1_1internal.html#a8ec00d458d0d442bd64af7b5f9c22dda">CaptureStderr</a>();</div><div class="line"><a name="l08316"></a><span class="lineno"> 8316</span>  <span class="comment">// Flush the log buffers since the log streams are shared with the child.</span></div><div class="line"><a name="l08317"></a><span class="lineno"> 8317</span>  <a class="code" href="namespacetesting_1_1internal.html#a2135f223bf6b527729aeaa651115183b">FlushInfoLog</a>();</div><div class="line"><a name="l08318"></a><span class="lineno"> 8318</span> </div><div class="line"><a name="l08319"></a><span class="lineno"> 8319</span>  <span class="comment">// The child process will share the standard handles with the parent.</span></div><div class="line"><a name="l08320"></a><span class="lineno"> 8320</span>  STARTUPINFOA startup_info;</div><div class="line"><a name="l08321"></a><span class="lineno"> 8321</span>  memset(&startup_info, 0, <span class="keyword">sizeof</span>(STARTUPINFO));</div><div class="line"><a name="l08322"></a><span class="lineno"> 8322</span>  startup_info.dwFlags = STARTF_USESTDHANDLES;</div><div class="line"><a name="l08323"></a><span class="lineno"> 8323</span>  startup_info.hStdInput = ::GetStdHandle(STD_INPUT_HANDLE);</div><div class="line"><a name="l08324"></a><span class="lineno"> 8324</span>  startup_info.hStdOutput = ::GetStdHandle(STD_OUTPUT_HANDLE);</div><div class="line"><a name="l08325"></a><span class="lineno"> 8325</span>  startup_info.hStdError = ::GetStdHandle(STD_ERROR_HANDLE);</div><div class="line"><a name="l08326"></a><span class="lineno"> 8326</span> </div><div class="line"><a name="l08327"></a><span class="lineno"> 8327</span>  PROCESS_INFORMATION process_info;</div><div class="line"><a name="l08328"></a><span class="lineno"> 8328</span>  GTEST_DEATH_TEST_CHECK_(</div><div class="line"><a name="l08329"></a><span class="lineno"> 8329</span>  ::CreateProcessA(</div><div class="line"><a name="l08330"></a><span class="lineno"> 8330</span>  executable_path, const_cast<char*>(command_line.c_str()),</div><div class="line"><a name="l08331"></a><span class="lineno"> 8331</span>  <span class="keyword">nullptr</span>, <span class="comment">// Retuned process handle is not inheritable.</span></div><div class="line"><a name="l08332"></a><span class="lineno"> 8332</span>  <span class="keyword">nullptr</span>, <span class="comment">// Retuned thread handle is not inheritable.</span></div><div class="line"><a name="l08333"></a><span class="lineno"> 8333</span>  TRUE, <span class="comment">// Child inherits all inheritable handles (for write_handle_).</span></div><div class="line"><a name="l08334"></a><span class="lineno"> 8334</span>  0x0, <span class="comment">// Default creation flags.</span></div><div class="line"><a name="l08335"></a><span class="lineno"> 8335</span>  <span class="keyword">nullptr</span>, <span class="comment">// Inherit the parent's environment.</span></div><div class="line"><a name="l08336"></a><span class="lineno"> 8336</span>  <a class="code" href="classtesting_1_1_unit_test.html#af254e2e695471eb9f128bc556bae3668">UnitTest::GetInstance</a>()-><a class="code" href="classtesting_1_1_unit_test.html#af35839566385e14f6b31232489112621">original_working_dir</a>(), &startup_info,</div><div class="line"><a name="l08337"></a><span class="lineno"> 8337</span>  &process_info) != FALSE);</div><div class="line"><a name="l08338"></a><span class="lineno"> 8338</span>  child_handle_.Reset(process_info.hProcess);</div><div class="line"><a name="l08339"></a><span class="lineno"> 8339</span>  ::CloseHandle(process_info.hThread);</div><div class="line"><a name="l08340"></a><span class="lineno"> 8340</span>  set_spawned(<span class="keyword">true</span>);</div><div class="line"><a name="l08341"></a><span class="lineno"> 8341</span>  <span class="keywordflow">return</span> OVERSEE_TEST;</div><div class="line"><a name="l08342"></a><span class="lineno"> 8342</span> }</div><div class="line"><a name="l08343"></a><span class="lineno"> 8343</span> </div><div class="line"><a name="l08344"></a><span class="lineno"> 8344</span> <span class="preprocessor"># elif GTEST_OS_FUCHSIA</span></div><div class="line"><a name="l08345"></a><span class="lineno"> 8345</span> </div><div class="line"><a name="l08346"></a><span class="lineno"> 8346</span> <span class="keyword">class </span>FuchsiaDeathTest : <span class="keyword">public</span> DeathTestImpl {</div><div class="line"><a name="l08347"></a><span class="lineno"> 8347</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l08348"></a><span class="lineno"> 8348</span>  FuchsiaDeathTest(<span class="keyword">const</span> <span class="keywordtype">char</span>* a_statement, Matcher<const std::string&> matcher,</div><div class="line"><a name="l08349"></a><span class="lineno"> 8349</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* file, <span class="keywordtype">int</span> line)</div><div class="line"><a name="l08350"></a><span class="lineno"> 8350</span>  : DeathTestImpl(a_statement, std::move(matcher)),</div><div class="line"><a name="l08351"></a><span class="lineno"> 8351</span>  file_(file),</div><div class="line"><a name="l08352"></a><span class="lineno"> 8352</span>  line_(line) {}</div><div class="line"><a name="l08353"></a><span class="lineno"> 8353</span> </div><div class="line"><a name="l08354"></a><span class="lineno"> 8354</span>  <span class="comment">// All of these virtual functions are inherited from DeathTest.</span></div><div class="line"><a name="l08355"></a><span class="lineno"> 8355</span>  <span class="keywordtype">int</span> Wait() <span class="keyword">override</span>;</div><div class="line"><a name="l08356"></a><span class="lineno"> 8356</span>  TestRole AssumeRole() <span class="keyword">override</span>;</div><div class="line"><a name="l08357"></a><span class="lineno"> 8357</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> GetErrorLogs() <span class="keyword">override</span>;</div><div class="line"><a name="l08358"></a><span class="lineno"> 8358</span> </div><div class="line"><a name="l08359"></a><span class="lineno"> 8359</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l08360"></a><span class="lineno"> 8360</span>  <span class="comment">// The name of the file in which the death test is located.</span></div><div class="line"><a name="l08361"></a><span class="lineno"> 8361</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> file_;</div><div class="line"><a name="l08362"></a><span class="lineno"> 8362</span>  <span class="comment">// The line number on which the death test is located.</span></div><div class="line"><a name="l08363"></a><span class="lineno"> 8363</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> line_;</div><div class="line"><a name="l08364"></a><span class="lineno"> 8364</span>  <span class="comment">// The stderr data captured by the child process.</span></div><div class="line"><a name="l08365"></a><span class="lineno"> 8365</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> captured_stderr_;</div><div class="line"><a name="l08366"></a><span class="lineno"> 8366</span> </div><div class="line"><a name="l08367"></a><span class="lineno"> 8367</span>  zx::process child_process_;</div><div class="line"><a name="l08368"></a><span class="lineno"> 8368</span>  zx::port port_;</div><div class="line"><a name="l08369"></a><span class="lineno"> 8369</span>  zx::socket stderr_socket_;</div><div class="line"><a name="l08370"></a><span class="lineno"> 8370</span> };</div><div class="line"><a name="l08371"></a><span class="lineno"> 8371</span> </div><div class="line"><a name="l08372"></a><span class="lineno"> 8372</span> <span class="comment">// Utility class for accumulating command-line arguments.</span></div><div class="line"><a name="l08373"></a><span class="lineno"> 8373</span> <span class="keyword">class </span>Arguments {</div><div class="line"><a name="l08374"></a><span class="lineno"> 8374</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l08375"></a><span class="lineno"> 8375</span>  Arguments() { args_.push_back(<span class="keyword">nullptr</span>); }</div><div class="line"><a name="l08376"></a><span class="lineno"> 8376</span> </div><div class="line"><a name="l08377"></a><span class="lineno"> 8377</span>  ~Arguments() {</div><div class="line"><a name="l08378"></a><span class="lineno"> 8378</span>  <span class="keywordflow">for</span> (std::vector<char*>::iterator i = args_.begin(); i != args_.end();</div><div class="line"><a name="l08379"></a><span class="lineno"> 8379</span>  ++i) {</div><div class="line"><a name="l08380"></a><span class="lineno"> 8380</span>  free(*i);</div><div class="line"><a name="l08381"></a><span class="lineno"> 8381</span>  }</div><div class="line"><a name="l08382"></a><span class="lineno"> 8382</span>  }</div><div class="line"><a name="l08383"></a><span class="lineno"> 8383</span>  <span class="keywordtype">void</span> AddArgument(<span class="keyword">const</span> <span class="keywordtype">char</span>* argument) {</div><div class="line"><a name="l08384"></a><span class="lineno"> 8384</span>  args_.insert(args_.end() - 1, <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a8e352884793a65ae8be144676f1a9136">posix::StrDup</a>(argument));</div><div class="line"><a name="l08385"></a><span class="lineno"> 8385</span>  }</div><div class="line"><a name="l08386"></a><span class="lineno"> 8386</span> </div><div class="line"><a name="l08387"></a><span class="lineno"> 8387</span>  <span class="keyword">template</span> <<span class="keyword">typename</span> Str></div><div class="line"><a name="l08388"></a><span class="lineno"> 8388</span>  <span class="keywordtype">void</span> AddArguments(const ::std::vector<Str>& arguments) {</div><div class="line"><a name="l08389"></a><span class="lineno"> 8389</span>  <span class="keywordflow">for</span> (typename ::std::vector<Str>::const_iterator i = arguments.begin();</div><div class="line"><a name="l08390"></a><span class="lineno"> 8390</span>  i != arguments.end();</div><div class="line"><a name="l08391"></a><span class="lineno"> 8391</span>  ++i) {</div><div class="line"><a name="l08392"></a><span class="lineno"> 8392</span>  args_.insert(args_.end() - 1, <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a8e352884793a65ae8be144676f1a9136">posix::StrDup</a>(i->c_str()));</div><div class="line"><a name="l08393"></a><span class="lineno"> 8393</span>  }</div><div class="line"><a name="l08394"></a><span class="lineno"> 8394</span>  }</div><div class="line"><a name="l08395"></a><span class="lineno"> 8395</span>  <span class="keywordtype">char</span>* <span class="keyword">const</span>* Argv() {</div><div class="line"><a name="l08396"></a><span class="lineno"> 8396</span>  <span class="keywordflow">return</span> &args_[0];</div><div class="line"><a name="l08397"></a><span class="lineno"> 8397</span>  }</div><div class="line"><a name="l08398"></a><span class="lineno"> 8398</span> </div><div class="line"><a name="l08399"></a><span class="lineno"> 8399</span>  <span class="keywordtype">int</span> <a class="code" href="namespaceutl_1_1meta.html#a0edfc2c15e42531e53c0822264d220ec">size</a>() {</div><div class="line"><a name="l08400"></a><span class="lineno"> 8400</span>  <span class="keywordflow">return</span> args_.size() - 1;</div><div class="line"><a name="l08401"></a><span class="lineno"> 8401</span>  }</div><div class="line"><a name="l08402"></a><span class="lineno"> 8402</span> </div><div class="line"><a name="l08403"></a><span class="lineno"> 8403</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l08404"></a><span class="lineno"> 8404</span>  std::vector<char*> args_;</div><div class="line"><a name="l08405"></a><span class="lineno"> 8405</span> };</div><div class="line"><a name="l08406"></a><span class="lineno"> 8406</span> </div><div class="line"><a name="l08407"></a><span class="lineno"> 8407</span> <span class="comment">// Waits for the child in a death test to exit, returning its exit</span></div><div class="line"><a name="l08408"></a><span class="lineno"> 8408</span> <span class="comment">// status, or 0 if no child process exists. As a side effect, sets the</span></div><div class="line"><a name="l08409"></a><span class="lineno"> 8409</span> <span class="comment">// outcome data member.</span></div><div class="line"><a name="l08410"></a><span class="lineno"> 8410</span> <span class="keywordtype">int</span> FuchsiaDeathTest::Wait() {</div><div class="line"><a name="l08411"></a><span class="lineno"> 8411</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> kProcessKey = 0;</div><div class="line"><a name="l08412"></a><span class="lineno"> 8412</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> kSocketKey = 1;</div><div class="line"><a name="l08413"></a><span class="lineno"> 8413</span> </div><div class="line"><a name="l08414"></a><span class="lineno"> 8414</span>  <span class="keywordflow">if</span> (!spawned())</div><div class="line"><a name="l08415"></a><span class="lineno"> 8415</span>  <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l08416"></a><span class="lineno"> 8416</span> </div><div class="line"><a name="l08417"></a><span class="lineno"> 8417</span>  <span class="comment">// Register to wait for the child process to terminate.</span></div><div class="line"><a name="l08418"></a><span class="lineno"> 8418</span>  zx_status_t status_zx;</div><div class="line"><a name="l08419"></a><span class="lineno"> 8419</span>  status_zx = child_process_.wait_async(</div><div class="line"><a name="l08420"></a><span class="lineno"> 8420</span>  port_, kProcessKey, ZX_PROCESS_TERMINATED, ZX_WAIT_ASYNC_ONCE);</div><div class="line"><a name="l08421"></a><span class="lineno"> 8421</span>  GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK);</div><div class="line"><a name="l08422"></a><span class="lineno"> 8422</span>  <span class="comment">// Register to wait for the socket to be readable or closed.</span></div><div class="line"><a name="l08423"></a><span class="lineno"> 8423</span>  status_zx = stderr_socket_.wait_async(</div><div class="line"><a name="l08424"></a><span class="lineno"> 8424</span>  port_, kSocketKey, ZX_SOCKET_READABLE | ZX_SOCKET_PEER_CLOSED,</div><div class="line"><a name="l08425"></a><span class="lineno"> 8425</span>  ZX_WAIT_ASYNC_REPEATING);</div><div class="line"><a name="l08426"></a><span class="lineno"> 8426</span>  GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK);</div><div class="line"><a name="l08427"></a><span class="lineno"> 8427</span> </div><div class="line"><a name="l08428"></a><span class="lineno"> 8428</span>  <span class="keywordtype">bool</span> process_terminated = <span class="keyword">false</span>;</div><div class="line"><a name="l08429"></a><span class="lineno"> 8429</span>  <span class="keywordtype">bool</span> socket_closed = <span class="keyword">false</span>;</div><div class="line"><a name="l08430"></a><span class="lineno"> 8430</span>  <span class="keywordflow">do</span> {</div><div class="line"><a name="l08431"></a><span class="lineno"> 8431</span>  zx_port_packet_t packet = {};</div><div class="line"><a name="l08432"></a><span class="lineno"> 8432</span>  status_zx = port_.wait(zx::time::infinite(), &packet);</div><div class="line"><a name="l08433"></a><span class="lineno"> 8433</span>  GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK);</div><div class="line"><a name="l08434"></a><span class="lineno"> 8434</span> </div><div class="line"><a name="l08435"></a><span class="lineno"> 8435</span>  <span class="keywordflow">if</span> (packet.key == kProcessKey) {</div><div class="line"><a name="l08436"></a><span class="lineno"> 8436</span>  <span class="keywordflow">if</span> (ZX_PKT_IS_EXCEPTION(packet.type)) {</div><div class="line"><a name="l08437"></a><span class="lineno"> 8437</span>  <span class="comment">// Process encountered an exception. Kill it directly rather than</span></div><div class="line"><a name="l08438"></a><span class="lineno"> 8438</span>  <span class="comment">// letting other handlers process the event. We will get a second</span></div><div class="line"><a name="l08439"></a><span class="lineno"> 8439</span>  <span class="comment">// kProcessKey event when the process actually terminates.</span></div><div class="line"><a name="l08440"></a><span class="lineno"> 8440</span>  status_zx = child_process_.kill();</div><div class="line"><a name="l08441"></a><span class="lineno"> 8441</span>  GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK);</div><div class="line"><a name="l08442"></a><span class="lineno"> 8442</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l08443"></a><span class="lineno"> 8443</span>  <span class="comment">// Process terminated.</span></div><div class="line"><a name="l08444"></a><span class="lineno"> 8444</span>  GTEST_DEATH_TEST_CHECK_(ZX_PKT_IS_SIGNAL_ONE(packet.type));</div><div class="line"><a name="l08445"></a><span class="lineno"> 8445</span>  GTEST_DEATH_TEST_CHECK_(packet.signal.observed & ZX_PROCESS_TERMINATED);</div><div class="line"><a name="l08446"></a><span class="lineno"> 8446</span>  process_terminated = <span class="keyword">true</span>;</div><div class="line"><a name="l08447"></a><span class="lineno"> 8447</span>  }</div><div class="line"><a name="l08448"></a><span class="lineno"> 8448</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (packet.key == kSocketKey) {</div><div class="line"><a name="l08449"></a><span class="lineno"> 8449</span>  GTEST_DEATH_TEST_CHECK_(ZX_PKT_IS_SIGNAL_REP(packet.type));</div><div class="line"><a name="l08450"></a><span class="lineno"> 8450</span>  <span class="keywordflow">if</span> (packet.signal.observed & ZX_SOCKET_READABLE) {</div><div class="line"><a name="l08451"></a><span class="lineno"> 8451</span>  <span class="comment">// Read data from the socket.</span></div><div class="line"><a name="l08452"></a><span class="lineno"> 8452</span>  constexpr <span class="keywordtype">size_t</span> kBufferSize = 1024;</div><div class="line"><a name="l08453"></a><span class="lineno"> 8453</span>  <span class="keywordflow">do</span> {</div><div class="line"><a name="l08454"></a><span class="lineno"> 8454</span>  <span class="keywordtype">size_t</span> old_length = captured_stderr_.length();</div><div class="line"><a name="l08455"></a><span class="lineno"> 8455</span>  <span class="keywordtype">size_t</span> bytes_read = 0;</div><div class="line"><a name="l08456"></a><span class="lineno"> 8456</span>  captured_stderr_.resize(old_length + kBufferSize);</div><div class="line"><a name="l08457"></a><span class="lineno"> 8457</span>  status_zx = stderr_socket_.read(</div><div class="line"><a name="l08458"></a><span class="lineno"> 8458</span>  0, &captured_stderr_.front() + old_length, kBufferSize,</div><div class="line"><a name="l08459"></a><span class="lineno"> 8459</span>  &bytes_read);</div><div class="line"><a name="l08460"></a><span class="lineno"> 8460</span>  captured_stderr_.resize(old_length + bytes_read);</div><div class="line"><a name="l08461"></a><span class="lineno"> 8461</span>  } <span class="keywordflow">while</span> (status_zx == ZX_OK);</div><div class="line"><a name="l08462"></a><span class="lineno"> 8462</span>  <span class="keywordflow">if</span> (status_zx == ZX_ERR_PEER_CLOSED) {</div><div class="line"><a name="l08463"></a><span class="lineno"> 8463</span>  socket_closed = <span class="keyword">true</span>;</div><div class="line"><a name="l08464"></a><span class="lineno"> 8464</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l08465"></a><span class="lineno"> 8465</span>  GTEST_DEATH_TEST_CHECK_(status_zx == ZX_ERR_SHOULD_WAIT);</div><div class="line"><a name="l08466"></a><span class="lineno"> 8466</span>  }</div><div class="line"><a name="l08467"></a><span class="lineno"> 8467</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l08468"></a><span class="lineno"> 8468</span>  GTEST_DEATH_TEST_CHECK_(packet.signal.observed & ZX_SOCKET_PEER_CLOSED);</div><div class="line"><a name="l08469"></a><span class="lineno"> 8469</span>  socket_closed = <span class="keyword">true</span>;</div><div class="line"><a name="l08470"></a><span class="lineno"> 8470</span>  }</div><div class="line"><a name="l08471"></a><span class="lineno"> 8471</span>  }</div><div class="line"><a name="l08472"></a><span class="lineno"> 8472</span>  } <span class="keywordflow">while</span> (!process_terminated && !socket_closed);</div><div class="line"><a name="l08473"></a><span class="lineno"> 8473</span> </div><div class="line"><a name="l08474"></a><span class="lineno"> 8474</span>  ReadAndInterpretStatusByte();</div><div class="line"><a name="l08475"></a><span class="lineno"> 8475</span> </div><div class="line"><a name="l08476"></a><span class="lineno"> 8476</span>  zx_info_process_t buffer;</div><div class="line"><a name="l08477"></a><span class="lineno"> 8477</span>  status_zx = child_process_.get_info(</div><div class="line"><a name="l08478"></a><span class="lineno"> 8478</span>  ZX_INFO_PROCESS, &buffer, <span class="keyword">sizeof</span>(buffer), <span class="keyword">nullptr</span>, <span class="keyword">nullptr</span>);</div><div class="line"><a name="l08479"></a><span class="lineno"> 8479</span>  GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK);</div><div class="line"><a name="l08480"></a><span class="lineno"> 8480</span> </div><div class="line"><a name="l08481"></a><span class="lineno"> 8481</span>  GTEST_DEATH_TEST_CHECK_(buffer.exited);</div><div class="line"><a name="l08482"></a><span class="lineno"> 8482</span>  set_status(buffer.return_code);</div><div class="line"><a name="l08483"></a><span class="lineno"> 8483</span>  <span class="keywordflow">return</span> status();</div><div class="line"><a name="l08484"></a><span class="lineno"> 8484</span> }</div><div class="line"><a name="l08485"></a><span class="lineno"> 8485</span> </div><div class="line"><a name="l08486"></a><span class="lineno"> 8486</span> <span class="comment">// The AssumeRole process for a Fuchsia death test. It creates a child</span></div><div class="line"><a name="l08487"></a><span class="lineno"> 8487</span> <span class="comment">// process with the same executable as the current process to run the</span></div><div class="line"><a name="l08488"></a><span class="lineno"> 8488</span> <span class="comment">// death test. The child process is given the --gtest_filter and</span></div><div class="line"><a name="l08489"></a><span class="lineno"> 8489</span> <span class="comment">// --gtest_internal_run_death_test flags such that it knows to run the</span></div><div class="line"><a name="l08490"></a><span class="lineno"> 8490</span> <span class="comment">// current death test only.</span></div><div class="line"><a name="l08491"></a><span class="lineno"> 8491</span> DeathTest::TestRole FuchsiaDeathTest::AssumeRole() {</div><div class="line"><a name="l08492"></a><span class="lineno"> 8492</span>  <span class="keyword">const</span> UnitTestImpl* <span class="keyword">const</span> impl = GetUnitTestImpl();</div><div class="line"><a name="l08493"></a><span class="lineno"> 8493</span>  <span class="keyword">const</span> InternalRunDeathTestFlag* <span class="keyword">const</span> flag =</div><div class="line"><a name="l08494"></a><span class="lineno"> 8494</span>  impl->internal_run_death_test_flag();</div><div class="line"><a name="l08495"></a><span class="lineno"> 8495</span>  <span class="keyword">const</span> TestInfo* <span class="keyword">const</span> info = impl->current_test_info();</div><div class="line"><a name="l08496"></a><span class="lineno"> 8496</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> death_test_index = info->result()->death_test_count();</div><div class="line"><a name="l08497"></a><span class="lineno"> 8497</span> </div><div class="line"><a name="l08498"></a><span class="lineno"> 8498</span>  <span class="keywordflow">if</span> (flag != <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l08499"></a><span class="lineno"> 8499</span>  <span class="comment">// ParseInternalRunDeathTestFlag() has performed all the necessary</span></div><div class="line"><a name="l08500"></a><span class="lineno"> 8500</span>  <span class="comment">// processing.</span></div><div class="line"><a name="l08501"></a><span class="lineno"> 8501</span>  set_write_fd(kFuchsiaReadPipeFd);</div><div class="line"><a name="l08502"></a><span class="lineno"> 8502</span>  <span class="keywordflow">return</span> EXECUTE_TEST;</div><div class="line"><a name="l08503"></a><span class="lineno"> 8503</span>  }</div><div class="line"><a name="l08504"></a><span class="lineno"> 8504</span> </div><div class="line"><a name="l08505"></a><span class="lineno"> 8505</span>  <span class="comment">// Flush the log buffers since the log streams are shared with the child.</span></div><div class="line"><a name="l08506"></a><span class="lineno"> 8506</span>  <a class="code" href="namespacetesting_1_1internal.html#a2135f223bf6b527729aeaa651115183b">FlushInfoLog</a>();</div><div class="line"><a name="l08507"></a><span class="lineno"> 8507</span> </div><div class="line"><a name="l08508"></a><span class="lineno"> 8508</span>  <span class="comment">// Build the child process command line.</span></div><div class="line"><a name="l08509"></a><span class="lineno"> 8509</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> filter_flag = <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(<span class="stringliteral">"--"</span>) + <a class="code" href="gtest_8h.html#a088e84784c589ba9b1fc48602ad8eabf">GTEST_FLAG_PREFIX_</a> +</div><div class="line"><a name="l08510"></a><span class="lineno"> 8510</span>  kFilterFlag + <span class="stringliteral">"="</span> + info->test_suite_name() +</div><div class="line"><a name="l08511"></a><span class="lineno"> 8511</span>  <span class="stringliteral">"."</span> + info->name();</div><div class="line"><a name="l08512"></a><span class="lineno"> 8512</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> internal_flag =</div><div class="line"><a name="l08513"></a><span class="lineno"> 8513</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(<span class="stringliteral">"--"</span>) + <a class="code" href="gtest_8h.html#a088e84784c589ba9b1fc48602ad8eabf">GTEST_FLAG_PREFIX_</a> + kInternalRunDeathTestFlag + <span class="stringliteral">"="</span></div><div class="line"><a name="l08514"></a><span class="lineno"> 8514</span>  + file_ + <span class="stringliteral">"|"</span></div><div class="line"><a name="l08515"></a><span class="lineno"> 8515</span>  + <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(line_) + <span class="stringliteral">"|"</span></div><div class="line"><a name="l08516"></a><span class="lineno"> 8516</span>  + <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(death_test_index);</div><div class="line"><a name="l08517"></a><span class="lineno"> 8517</span>  Arguments args;</div><div class="line"><a name="l08518"></a><span class="lineno"> 8518</span>  args.AddArguments(GetInjectableArgvs());</div><div class="line"><a name="l08519"></a><span class="lineno"> 8519</span>  args.AddArgument(filter_flag.c_str());</div><div class="line"><a name="l08520"></a><span class="lineno"> 8520</span>  args.AddArgument(internal_flag.c_str());</div><div class="line"><a name="l08521"></a><span class="lineno"> 8521</span> </div><div class="line"><a name="l08522"></a><span class="lineno"> 8522</span>  <span class="comment">// Build the pipe for communication with the child.</span></div><div class="line"><a name="l08523"></a><span class="lineno"> 8523</span>  zx_status_t status;</div><div class="line"><a name="l08524"></a><span class="lineno"> 8524</span>  zx_handle_t child_pipe_handle;</div><div class="line"><a name="l08525"></a><span class="lineno"> 8525</span>  uint32_t type;</div><div class="line"><a name="l08526"></a><span class="lineno"> 8526</span>  status = fdio_pipe_half(&child_pipe_handle, &type);</div><div class="line"><a name="l08527"></a><span class="lineno"> 8527</span>  GTEST_DEATH_TEST_CHECK_(status >= 0);</div><div class="line"><a name="l08528"></a><span class="lineno"> 8528</span>  set_read_fd(status);</div><div class="line"><a name="l08529"></a><span class="lineno"> 8529</span> </div><div class="line"><a name="l08530"></a><span class="lineno"> 8530</span>  <span class="comment">// Set the pipe handle for the child.</span></div><div class="line"><a name="l08531"></a><span class="lineno"> 8531</span>  fdio_spawn_action_t spawn_actions[2] = {};</div><div class="line"><a name="l08532"></a><span class="lineno"> 8532</span>  fdio_spawn_action_t* add_handle_action = &spawn_actions[0];</div><div class="line"><a name="l08533"></a><span class="lineno"> 8533</span>  add_handle_action->action = FDIO_SPAWN_ACTION_ADD_HANDLE;</div><div class="line"><a name="l08534"></a><span class="lineno"> 8534</span>  add_handle_action->h.id = PA_HND(type, kFuchsiaReadPipeFd);</div><div class="line"><a name="l08535"></a><span class="lineno"> 8535</span>  add_handle_action->h.handle = child_pipe_handle;</div><div class="line"><a name="l08536"></a><span class="lineno"> 8536</span> </div><div class="line"><a name="l08537"></a><span class="lineno"> 8537</span>  <span class="comment">// Create a socket pair will be used to receive the child process' stderr.</span></div><div class="line"><a name="l08538"></a><span class="lineno"> 8538</span>  zx::socket stderr_producer_socket;</div><div class="line"><a name="l08539"></a><span class="lineno"> 8539</span>  status =</div><div class="line"><a name="l08540"></a><span class="lineno"> 8540</span>  zx::socket::create(0, &stderr_producer_socket, &stderr_socket_);</div><div class="line"><a name="l08541"></a><span class="lineno"> 8541</span>  GTEST_DEATH_TEST_CHECK_(status >= 0);</div><div class="line"><a name="l08542"></a><span class="lineno"> 8542</span>  <span class="keywordtype">int</span> stderr_producer_fd = -1;</div><div class="line"><a name="l08543"></a><span class="lineno"> 8543</span>  zx_handle_t producer_handle[1] = { stderr_producer_socket.release() };</div><div class="line"><a name="l08544"></a><span class="lineno"> 8544</span>  uint32_t producer_handle_type[1] = { PA_FDIO_SOCKET };</div><div class="line"><a name="l08545"></a><span class="lineno"> 8545</span>  status = fdio_create_fd(</div><div class="line"><a name="l08546"></a><span class="lineno"> 8546</span>  producer_handle, producer_handle_type, 1, &stderr_producer_fd);</div><div class="line"><a name="l08547"></a><span class="lineno"> 8547</span>  GTEST_DEATH_TEST_CHECK_(status >= 0);</div><div class="line"><a name="l08548"></a><span class="lineno"> 8548</span> </div><div class="line"><a name="l08549"></a><span class="lineno"> 8549</span>  <span class="comment">// Make the stderr socket nonblocking.</span></div><div class="line"><a name="l08550"></a><span class="lineno"> 8550</span>  GTEST_DEATH_TEST_CHECK_(fcntl(stderr_producer_fd, F_SETFL, 0) == 0);</div><div class="line"><a name="l08551"></a><span class="lineno"> 8551</span> </div><div class="line"><a name="l08552"></a><span class="lineno"> 8552</span>  fdio_spawn_action_t* add_stderr_action = &spawn_actions[1];</div><div class="line"><a name="l08553"></a><span class="lineno"> 8553</span>  add_stderr_action->action = FDIO_SPAWN_ACTION_CLONE_FD;</div><div class="line"><a name="l08554"></a><span class="lineno"> 8554</span>  add_stderr_action->fd.local_fd = stderr_producer_fd;</div><div class="line"><a name="l08555"></a><span class="lineno"> 8555</span>  add_stderr_action->fd.target_fd = STDERR_FILENO;</div><div class="line"><a name="l08556"></a><span class="lineno"> 8556</span> </div><div class="line"><a name="l08557"></a><span class="lineno"> 8557</span>  <span class="comment">// Create a child job.</span></div><div class="line"><a name="l08558"></a><span class="lineno"> 8558</span>  zx_handle_t child_job = ZX_HANDLE_INVALID;</div><div class="line"><a name="l08559"></a><span class="lineno"> 8559</span>  status = zx_job_create(zx_job_default(), 0, & child_job);</div><div class="line"><a name="l08560"></a><span class="lineno"> 8560</span>  GTEST_DEATH_TEST_CHECK_(status == ZX_OK);</div><div class="line"><a name="l08561"></a><span class="lineno"> 8561</span>  zx_policy_basic_t policy;</div><div class="line"><a name="l08562"></a><span class="lineno"> 8562</span>  policy.condition = ZX_POL_NEW_ANY;</div><div class="line"><a name="l08563"></a><span class="lineno"> 8563</span>  policy.policy = ZX_POL_ACTION_ALLOW;</div><div class="line"><a name="l08564"></a><span class="lineno"> 8564</span>  status = zx_job_set_policy(</div><div class="line"><a name="l08565"></a><span class="lineno"> 8565</span>  child_job, ZX_JOB_POL_RELATIVE, ZX_JOB_POL_BASIC, &policy, 1);</div><div class="line"><a name="l08566"></a><span class="lineno"> 8566</span>  GTEST_DEATH_TEST_CHECK_(status == ZX_OK);</div><div class="line"><a name="l08567"></a><span class="lineno"> 8567</span> </div><div class="line"><a name="l08568"></a><span class="lineno"> 8568</span>  <span class="comment">// Create an exception port and attach it to the |child_job|, to allow</span></div><div class="line"><a name="l08569"></a><span class="lineno"> 8569</span>  <span class="comment">// us to suppress the system default exception handler from firing.</span></div><div class="line"><a name="l08570"></a><span class="lineno"> 8570</span>  status = zx::port::create(0, &port_);</div><div class="line"><a name="l08571"></a><span class="lineno"> 8571</span>  GTEST_DEATH_TEST_CHECK_(status == ZX_OK);</div><div class="line"><a name="l08572"></a><span class="lineno"> 8572</span>  status = zx_task_bind_exception_port(</div><div class="line"><a name="l08573"></a><span class="lineno"> 8573</span>  child_job, port_.get(), 0 <span class="comment">/* key */</span>, 0 <span class="comment">/*options */</span>);</div><div class="line"><a name="l08574"></a><span class="lineno"> 8574</span>  GTEST_DEATH_TEST_CHECK_(status == ZX_OK);</div><div class="line"><a name="l08575"></a><span class="lineno"> 8575</span> </div><div class="line"><a name="l08576"></a><span class="lineno"> 8576</span>  <span class="comment">// Spawn the child process.</span></div><div class="line"><a name="l08577"></a><span class="lineno"> 8577</span>  status = fdio_spawn_etc(</div><div class="line"><a name="l08578"></a><span class="lineno"> 8578</span>  child_job, FDIO_SPAWN_CLONE_ALL, args.Argv()[0], args.Argv(), <span class="keyword">nullptr</span>,</div><div class="line"><a name="l08579"></a><span class="lineno"> 8579</span>  2, spawn_actions, child_process_.reset_and_get_address(), <span class="keyword">nullptr</span>);</div><div class="line"><a name="l08580"></a><span class="lineno"> 8580</span>  GTEST_DEATH_TEST_CHECK_(status == ZX_OK);</div><div class="line"><a name="l08581"></a><span class="lineno"> 8581</span> </div><div class="line"><a name="l08582"></a><span class="lineno"> 8582</span>  set_spawned(<span class="keyword">true</span>);</div><div class="line"><a name="l08583"></a><span class="lineno"> 8583</span>  <span class="keywordflow">return</span> OVERSEE_TEST;</div><div class="line"><a name="l08584"></a><span class="lineno"> 8584</span> }</div><div class="line"><a name="l08585"></a><span class="lineno"> 8585</span> </div><div class="line"><a name="l08586"></a><span class="lineno"> 8586</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> FuchsiaDeathTest::GetErrorLogs() {</div><div class="line"><a name="l08587"></a><span class="lineno"> 8587</span>  <span class="keywordflow">return</span> captured_stderr_;</div><div class="line"><a name="l08588"></a><span class="lineno"> 8588</span> }</div><div class="line"><a name="l08589"></a><span class="lineno"> 8589</span> </div><div class="line"><a name="l08590"></a><span class="lineno"> 8590</span> <span class="preprocessor">#else // We are neither on Windows, nor on Fuchsia.</span></div><div class="line"><a name="l08591"></a><span class="lineno"> 8591</span> </div><div class="line"><a name="l08592"></a><span class="lineno"> 8592</span> <span class="comment">// ForkingDeathTest provides implementations for most of the abstract</span></div><div class="line"><a name="l08593"></a><span class="lineno"> 8593</span> <span class="comment">// methods of the DeathTest interface. Only the AssumeRole method is</span></div><div class="line"><a name="l08594"></a><span class="lineno"> 8594</span> <span class="comment">// left undefined.</span></div><div class="line"><a name="l08595"></a><span class="lineno"> 8595</span> <span class="keyword">class </span>ForkingDeathTest : <span class="keyword">public</span> DeathTestImpl {</div><div class="line"><a name="l08596"></a><span class="lineno"> 8596</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l08597"></a><span class="lineno"> 8597</span>  ForkingDeathTest(<span class="keyword">const</span> <span class="keywordtype">char</span>* statement, Matcher<const std::string&> matcher);</div><div class="line"><a name="l08598"></a><span class="lineno"> 8598</span> </div><div class="line"><a name="l08599"></a><span class="lineno"> 8599</span>  <span class="comment">// All of these virtual functions are inherited from DeathTest.</span></div><div class="line"><a name="l08600"></a><span class="lineno"> 8600</span>  <span class="keywordtype">int</span> Wait() <span class="keyword">override</span>;</div><div class="line"><a name="l08601"></a><span class="lineno"> 8601</span> </div><div class="line"><a name="l08602"></a><span class="lineno"> 8602</span>  <span class="keyword">protected</span>:</div><div class="line"><a name="l08603"></a><span class="lineno"> 8603</span>  <span class="keywordtype">void</span> set_child_pid(pid_t child_pid) { child_pid_ = child_pid; }</div><div class="line"><a name="l08604"></a><span class="lineno"> 8604</span> </div><div class="line"><a name="l08605"></a><span class="lineno"> 8605</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l08606"></a><span class="lineno"> 8606</span>  <span class="comment">// PID of child process during death test; 0 in the child process itself.</span></div><div class="line"><a name="l08607"></a><span class="lineno"> 8607</span>  pid_t child_pid_;</div><div class="line"><a name="l08608"></a><span class="lineno"> 8608</span> };</div><div class="line"><a name="l08609"></a><span class="lineno"> 8609</span> </div><div class="line"><a name="l08610"></a><span class="lineno"> 8610</span> <span class="comment">// Constructs a ForkingDeathTest.</span></div><div class="line"><a name="l08611"></a><span class="lineno"> 8611</span> ForkingDeathTest::ForkingDeathTest(<span class="keyword">const</span> <span class="keywordtype">char</span>* a_statement,</div><div class="line"><a name="l08612"></a><span class="lineno"> 8612</span>  Matcher<const std::string&> matcher)</div><div class="line"><a name="l08613"></a><span class="lineno"> 8613</span>  : DeathTestImpl(a_statement, std::move(matcher)), child_pid_(-1) {}</div><div class="line"><a name="l08614"></a><span class="lineno"> 8614</span> </div><div class="line"><a name="l08615"></a><span class="lineno"> 8615</span> <span class="comment">// Waits for the child in a death test to exit, returning its exit</span></div><div class="line"><a name="l08616"></a><span class="lineno"> 8616</span> <span class="comment">// status, or 0 if no child process exists. As a side effect, sets the</span></div><div class="line"><a name="l08617"></a><span class="lineno"> 8617</span> <span class="comment">// outcome data member.</span></div><div class="line"><a name="l08618"></a><span class="lineno"> 8618</span> <span class="keywordtype">int</span> ForkingDeathTest::Wait() {</div><div class="line"><a name="l08619"></a><span class="lineno"> 8619</span>  <span class="keywordflow">if</span> (!spawned())</div><div class="line"><a name="l08620"></a><span class="lineno"> 8620</span>  <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l08621"></a><span class="lineno"> 8621</span> </div><div class="line"><a name="l08622"></a><span class="lineno"> 8622</span>  ReadAndInterpretStatusByte();</div><div class="line"><a name="l08623"></a><span class="lineno"> 8623</span> </div><div class="line"><a name="l08624"></a><span class="lineno"> 8624</span>  <span class="keywordtype">int</span> status_value;</div><div class="line"><a name="l08625"></a><span class="lineno"> 8625</span>  GTEST_DEATH_TEST_CHECK_SYSCALL_(waitpid(child_pid_, &status_value, 0));</div><div class="line"><a name="l08626"></a><span class="lineno"> 8626</span>  set_status(status_value);</div><div class="line"><a name="l08627"></a><span class="lineno"> 8627</span>  <span class="keywordflow">return</span> status_value;</div><div class="line"><a name="l08628"></a><span class="lineno"> 8628</span> }</div><div class="line"><a name="l08629"></a><span class="lineno"> 8629</span> </div><div class="line"><a name="l08630"></a><span class="lineno"> 8630</span> <span class="comment">// A concrete death test class that forks, then immediately runs the test</span></div><div class="line"><a name="l08631"></a><span class="lineno"> 8631</span> <span class="comment">// in the child process.</span></div><div class="line"><a name="l08632"></a><span class="lineno"> 8632</span> <span class="keyword">class </span>NoExecDeathTest : <span class="keyword">public</span> ForkingDeathTest {</div><div class="line"><a name="l08633"></a><span class="lineno"> 8633</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l08634"></a><span class="lineno"> 8634</span>  NoExecDeathTest(<span class="keyword">const</span> <span class="keywordtype">char</span>* a_statement, Matcher<const std::string&> matcher)</div><div class="line"><a name="l08635"></a><span class="lineno"> 8635</span>  : ForkingDeathTest(a_statement, std::move(matcher)) {}</div><div class="line"><a name="l08636"></a><span class="lineno"> 8636</span>  TestRole AssumeRole() <span class="keyword">override</span>;</div><div class="line"><a name="l08637"></a><span class="lineno"> 8637</span> };</div><div class="line"><a name="l08638"></a><span class="lineno"> 8638</span> </div><div class="line"><a name="l08639"></a><span class="lineno"> 8639</span> <span class="comment">// The AssumeRole process for a fork-and-run death test. It implements a</span></div><div class="line"><a name="l08640"></a><span class="lineno"> 8640</span> <span class="comment">// straightforward fork, with a simple pipe to transmit the status byte.</span></div><div class="line"><a name="l08641"></a><span class="lineno"> 8641</span> DeathTest::TestRole NoExecDeathTest::AssumeRole() {</div><div class="line"><a name="l08642"></a><span class="lineno"> 8642</span>  <span class="keyword">const</span> <span class="keywordtype">size_t</span> thread_count = <a class="code" href="namespacetesting_1_1internal.html#a8cbd8bf820517923d7f3c4477b3af5fa">GetThreadCount</a>();</div><div class="line"><a name="l08643"></a><span class="lineno"> 8643</span>  <span class="keywordflow">if</span> (thread_count != 1) {</div><div class="line"><a name="l08644"></a><span class="lineno"> 8644</span>  <a class="code" href="gtest_8h.html#a8ef4cb4c465db8c15464aecc6d9510ef">GTEST_LOG_</a>(WARNING) << DeathTestThreadWarning(thread_count);</div><div class="line"><a name="l08645"></a><span class="lineno"> 8645</span>  }</div><div class="line"><a name="l08646"></a><span class="lineno"> 8646</span> </div><div class="line"><a name="l08647"></a><span class="lineno"> 8647</span>  <span class="keywordtype">int</span> pipe_fd[2];</div><div class="line"><a name="l08648"></a><span class="lineno"> 8648</span>  GTEST_DEATH_TEST_CHECK_(pipe(pipe_fd) != -1);</div><div class="line"><a name="l08649"></a><span class="lineno"> 8649</span> </div><div class="line"><a name="l08650"></a><span class="lineno"> 8650</span>  DeathTest::set_last_death_test_message(<span class="stringliteral">""</span>);</div><div class="line"><a name="l08651"></a><span class="lineno"> 8651</span>  <a class="code" href="namespacetesting_1_1internal.html#a8ec00d458d0d442bd64af7b5f9c22dda">CaptureStderr</a>();</div><div class="line"><a name="l08652"></a><span class="lineno"> 8652</span>  <span class="comment">// When we fork the process below, the log file buffers are copied, but the</span></div><div class="line"><a name="l08653"></a><span class="lineno"> 8653</span>  <span class="comment">// file descriptors are shared. We flush all log files here so that closing</span></div><div class="line"><a name="l08654"></a><span class="lineno"> 8654</span>  <span class="comment">// the file descriptors in the child process doesn't throw off the</span></div><div class="line"><a name="l08655"></a><span class="lineno"> 8655</span>  <span class="comment">// synchronization between descriptors and buffers in the parent process.</span></div><div class="line"><a name="l08656"></a><span class="lineno"> 8656</span>  <span class="comment">// This is as close to the fork as possible to avoid a race condition in case</span></div><div class="line"><a name="l08657"></a><span class="lineno"> 8657</span>  <span class="comment">// there are multiple threads running before the death test, and another</span></div><div class="line"><a name="l08658"></a><span class="lineno"> 8658</span>  <span class="comment">// thread writes to the log file.</span></div><div class="line"><a name="l08659"></a><span class="lineno"> 8659</span>  <a class="code" href="namespacetesting_1_1internal.html#a2135f223bf6b527729aeaa651115183b">FlushInfoLog</a>();</div><div class="line"><a name="l08660"></a><span class="lineno"> 8660</span> </div><div class="line"><a name="l08661"></a><span class="lineno"> 8661</span>  <span class="keyword">const</span> pid_t child_pid = fork();</div><div class="line"><a name="l08662"></a><span class="lineno"> 8662</span>  GTEST_DEATH_TEST_CHECK_(child_pid != -1);</div><div class="line"><a name="l08663"></a><span class="lineno"> 8663</span>  set_child_pid(child_pid);</div><div class="line"><a name="l08664"></a><span class="lineno"> 8664</span>  <span class="keywordflow">if</span> (child_pid == 0) {</div><div class="line"><a name="l08665"></a><span class="lineno"> 8665</span>  GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[0]));</div><div class="line"><a name="l08666"></a><span class="lineno"> 8666</span>  set_write_fd(pipe_fd[1]);</div><div class="line"><a name="l08667"></a><span class="lineno"> 8667</span>  <span class="comment">// Redirects all logging to stderr in the child process to prevent</span></div><div class="line"><a name="l08668"></a><span class="lineno"> 8668</span>  <span class="comment">// concurrent writes to the log files. We capture stderr in the parent</span></div><div class="line"><a name="l08669"></a><span class="lineno"> 8669</span>  <span class="comment">// process and append the child process' output to a log.</span></div><div class="line"><a name="l08670"></a><span class="lineno"> 8670</span>  <a class="code" href="namespacetesting_1_1internal.html#a06b1b20029fbd1dbeb59752f914fab84">LogToStderr</a>();</div><div class="line"><a name="l08671"></a><span class="lineno"> 8671</span>  <span class="comment">// Event forwarding to the listeners of event listener API mush be shut</span></div><div class="line"><a name="l08672"></a><span class="lineno"> 8672</span>  <span class="comment">// down in death test subprocesses.</span></div><div class="line"><a name="l08673"></a><span class="lineno"> 8673</span>  GetUnitTestImpl()->listeners()->SuppressEventForwarding();</div><div class="line"><a name="l08674"></a><span class="lineno"> 8674</span>  g_in_fast_death_test_child = <span class="keyword">true</span>;</div><div class="line"><a name="l08675"></a><span class="lineno"> 8675</span>  <span class="keywordflow">return</span> EXECUTE_TEST;</div><div class="line"><a name="l08676"></a><span class="lineno"> 8676</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l08677"></a><span class="lineno"> 8677</span>  GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1]));</div><div class="line"><a name="l08678"></a><span class="lineno"> 8678</span>  set_read_fd(pipe_fd[0]);</div><div class="line"><a name="l08679"></a><span class="lineno"> 8679</span>  set_spawned(<span class="keyword">true</span>);</div><div class="line"><a name="l08680"></a><span class="lineno"> 8680</span>  <span class="keywordflow">return</span> OVERSEE_TEST;</div><div class="line"><a name="l08681"></a><span class="lineno"> 8681</span>  }</div><div class="line"><a name="l08682"></a><span class="lineno"> 8682</span> }</div><div class="line"><a name="l08683"></a><span class="lineno"> 8683</span> </div><div class="line"><a name="l08684"></a><span class="lineno"> 8684</span> <span class="comment">// A concrete death test class that forks and re-executes the main</span></div><div class="line"><a name="l08685"></a><span class="lineno"> 8685</span> <span class="comment">// program from the beginning, with command-line flags set that cause</span></div><div class="line"><a name="l08686"></a><span class="lineno"> 8686</span> <span class="comment">// only this specific death test to be run.</span></div><div class="line"><a name="l08687"></a><span class="lineno"> 8687</span> <span class="keyword">class </span>ExecDeathTest : <span class="keyword">public</span> ForkingDeathTest {</div><div class="line"><a name="l08688"></a><span class="lineno"> 8688</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l08689"></a><span class="lineno"> 8689</span>  ExecDeathTest(<span class="keyword">const</span> <span class="keywordtype">char</span>* a_statement, Matcher<const std::string&> matcher,</div><div class="line"><a name="l08690"></a><span class="lineno"> 8690</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* file, <span class="keywordtype">int</span> line)</div><div class="line"><a name="l08691"></a><span class="lineno"> 8691</span>  : ForkingDeathTest(a_statement, std::move(matcher)),</div><div class="line"><a name="l08692"></a><span class="lineno"> 8692</span>  file_(file),</div><div class="line"><a name="l08693"></a><span class="lineno"> 8693</span>  line_(line) {}</div><div class="line"><a name="l08694"></a><span class="lineno"> 8694</span>  TestRole AssumeRole() <span class="keyword">override</span>;</div><div class="line"><a name="l08695"></a><span class="lineno"> 8695</span> </div><div class="line"><a name="l08696"></a><span class="lineno"> 8696</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l08697"></a><span class="lineno"> 8697</span>  static ::std::vector<std::string> GetArgvsForDeathTestChildProcess() {</div><div class="line"><a name="l08698"></a><span class="lineno"> 8698</span>  ::std::vector<std::string> args = GetInjectableArgvs();</div><div class="line"><a name="l08699"></a><span class="lineno"> 8699</span> <span class="preprocessor"># if defined(GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_)</span></div><div class="line"><a name="l08700"></a><span class="lineno"> 8700</span>  ::std::vector<std::string> extra_args =</div><div class="line"><a name="l08701"></a><span class="lineno"> 8701</span>  GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_();</div><div class="line"><a name="l08702"></a><span class="lineno"> 8702</span>  args.insert(args.end(), extra_args.begin(), extra_args.end());</div><div class="line"><a name="l08703"></a><span class="lineno"> 8703</span> <span class="preprocessor"># endif // defined(GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_)</span></div><div class="line"><a name="l08704"></a><span class="lineno"> 8704</span>  <span class="keywordflow">return</span> args;</div><div class="line"><a name="l08705"></a><span class="lineno"> 8705</span>  }</div><div class="line"><a name="l08706"></a><span class="lineno"> 8706</span>  <span class="comment">// The name of the file in which the death test is located.</span></div><div class="line"><a name="l08707"></a><span class="lineno"> 8707</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> file_;</div><div class="line"><a name="l08708"></a><span class="lineno"> 8708</span>  <span class="comment">// The line number on which the death test is located.</span></div><div class="line"><a name="l08709"></a><span class="lineno"> 8709</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> line_;</div><div class="line"><a name="l08710"></a><span class="lineno"> 8710</span> };</div><div class="line"><a name="l08711"></a><span class="lineno"> 8711</span> </div><div class="line"><a name="l08712"></a><span class="lineno"> 8712</span> <span class="comment">// Utility class for accumulating command-line arguments.</span></div><div class="line"><a name="l08713"></a><span class="lineno"> 8713</span> <span class="keyword">class </span>Arguments {</div><div class="line"><a name="l08714"></a><span class="lineno"> 8714</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l08715"></a><span class="lineno"> 8715</span>  Arguments() { args_.push_back(<span class="keyword">nullptr</span>); }</div><div class="line"><a name="l08716"></a><span class="lineno"> 8716</span> </div><div class="line"><a name="l08717"></a><span class="lineno"> 8717</span>  ~Arguments() {</div><div class="line"><a name="l08718"></a><span class="lineno"> 8718</span>  <span class="keywordflow">for</span> (std::vector<char*>::iterator i = args_.begin(); i != args_.end();</div><div class="line"><a name="l08719"></a><span class="lineno"> 8719</span>  ++i) {</div><div class="line"><a name="l08720"></a><span class="lineno"> 8720</span>  free(*i);</div><div class="line"><a name="l08721"></a><span class="lineno"> 8721</span>  }</div><div class="line"><a name="l08722"></a><span class="lineno"> 8722</span>  }</div><div class="line"><a name="l08723"></a><span class="lineno"> 8723</span>  <span class="keywordtype">void</span> AddArgument(<span class="keyword">const</span> <span class="keywordtype">char</span>* argument) {</div><div class="line"><a name="l08724"></a><span class="lineno"> 8724</span>  args_.insert(args_.end() - 1, <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a8e352884793a65ae8be144676f1a9136">posix::StrDup</a>(argument));</div><div class="line"><a name="l08725"></a><span class="lineno"> 8725</span>  }</div><div class="line"><a name="l08726"></a><span class="lineno"> 8726</span> </div><div class="line"><a name="l08727"></a><span class="lineno"> 8727</span>  <span class="keyword">template</span> <<span class="keyword">typename</span> Str></div><div class="line"><a name="l08728"></a><span class="lineno"> 8728</span>  <span class="keywordtype">void</span> AddArguments(const ::std::vector<Str>& arguments) {</div><div class="line"><a name="l08729"></a><span class="lineno"> 8729</span>  <span class="keywordflow">for</span> (typename ::std::vector<Str>::const_iterator i = arguments.begin();</div><div class="line"><a name="l08730"></a><span class="lineno"> 8730</span>  i != arguments.end();</div><div class="line"><a name="l08731"></a><span class="lineno"> 8731</span>  ++i) {</div><div class="line"><a name="l08732"></a><span class="lineno"> 8732</span>  args_.insert(args_.end() - 1, <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a8e352884793a65ae8be144676f1a9136">posix::StrDup</a>(i->c_str()));</div><div class="line"><a name="l08733"></a><span class="lineno"> 8733</span>  }</div><div class="line"><a name="l08734"></a><span class="lineno"> 8734</span>  }</div><div class="line"><a name="l08735"></a><span class="lineno"> 8735</span>  <span class="keywordtype">char</span>* <span class="keyword">const</span>* Argv() {</div><div class="line"><a name="l08736"></a><span class="lineno"> 8736</span>  <span class="keywordflow">return</span> &args_[0];</div><div class="line"><a name="l08737"></a><span class="lineno"> 8737</span>  }</div><div class="line"><a name="l08738"></a><span class="lineno"> 8738</span> </div><div class="line"><a name="l08739"></a><span class="lineno"> 8739</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l08740"></a><span class="lineno"> 8740</span>  std::vector<char*> args_;</div><div class="line"><a name="l08741"></a><span class="lineno"> 8741</span> };</div><div class="line"><a name="l08742"></a><span class="lineno"> 8742</span> </div><div class="line"><a name="l08743"></a><span class="lineno"> 8743</span> <span class="comment">// A struct that encompasses the arguments to the child process of a</span></div><div class="line"><a name="l08744"></a><span class="lineno"> 8744</span> <span class="comment">// threadsafe-style death test process.</span></div><div class="line"><a name="l08745"></a><span class="lineno"> 8745</span> <span class="keyword">struct </span>ExecDeathTestArgs {</div><div class="line"><a name="l08746"></a><span class="lineno"> 8746</span>  <span class="keywordtype">char</span>* <span class="keyword">const</span>* argv; <span class="comment">// Command-line arguments for the child's call to exec</span></div><div class="line"><a name="l08747"></a><span class="lineno"> 8747</span>  <span class="keywordtype">int</span> close_fd; <span class="comment">// File descriptor to close; the read end of a pipe</span></div><div class="line"><a name="l08748"></a><span class="lineno"> 8748</span> };</div><div class="line"><a name="l08749"></a><span class="lineno"> 8749</span> </div><div class="line"><a name="l08750"></a><span class="lineno"> 8750</span> <span class="preprocessor"># if GTEST_OS_MAC</span></div><div class="line"><a name="l08751"></a><span class="lineno"> 8751</span> <span class="keyword">inline</span> <span class="keywordtype">char</span>** GetEnviron() {</div><div class="line"><a name="l08752"></a><span class="lineno"> 8752</span>  <span class="comment">// When Google Test is built as a framework on MacOS X, the environ variable</span></div><div class="line"><a name="l08753"></a><span class="lineno"> 8753</span>  <span class="comment">// is unavailable. Apple's documentation (man environ) recommends using</span></div><div class="line"><a name="l08754"></a><span class="lineno"> 8754</span>  <span class="comment">// _NSGetEnviron() instead.</span></div><div class="line"><a name="l08755"></a><span class="lineno"> 8755</span>  <span class="keywordflow">return</span> *_NSGetEnviron();</div><div class="line"><a name="l08756"></a><span class="lineno"> 8756</span> }</div><div class="line"><a name="l08757"></a><span class="lineno"> 8757</span> <span class="preprocessor"># else</span></div><div class="line"><a name="l08758"></a><span class="lineno"> 8758</span> <span class="comment">// Some POSIX platforms expect you to declare environ. extern "C" makes</span></div><div class="line"><a name="l08759"></a><span class="lineno"> 8759</span> <span class="comment">// it reside in the global namespace.</span></div><div class="line"><a name="l08760"></a><span class="lineno"> 8760</span> <span class="keyword">extern</span> <span class="stringliteral">"C"</span> <span class="keywordtype">char</span>** environ;</div><div class="line"><a name="l08761"></a><span class="lineno"> 8761</span> <span class="keyword">inline</span> <span class="keywordtype">char</span>** GetEnviron() { <span class="keywordflow">return</span> environ; }</div><div class="line"><a name="l08762"></a><span class="lineno"> 8762</span> <span class="preprocessor"># endif // GTEST_OS_MAC</span></div><div class="line"><a name="l08763"></a><span class="lineno"> 8763</span> </div><div class="line"><a name="l08764"></a><span class="lineno"> 8764</span> <span class="preprocessor"># if !GTEST_OS_QNX</span></div><div class="line"><a name="l08765"></a><span class="lineno"> 8765</span> <span class="comment">// The main function for a threadsafe-style death test child process.</span></div><div class="line"><a name="l08766"></a><span class="lineno"> 8766</span> <span class="comment">// This function is called in a clone()-ed process and thus must avoid</span></div><div class="line"><a name="l08767"></a><span class="lineno"> 8767</span> <span class="comment">// any potentially unsafe operations like malloc or libc functions.</span></div><div class="line"><a name="l08768"></a><span class="lineno"> 8768</span> <span class="keyword">static</span> <span class="keywordtype">int</span> ExecDeathTestChildMain(<span class="keywordtype">void</span>* child_arg) {</div><div class="line"><a name="l08769"></a><span class="lineno"> 8769</span>  ExecDeathTestArgs* <span class="keyword">const</span> args = <span class="keyword">static_cast<</span>ExecDeathTestArgs*<span class="keyword">></span>(child_arg);</div><div class="line"><a name="l08770"></a><span class="lineno"> 8770</span>  GTEST_DEATH_TEST_CHECK_SYSCALL_(close(args->close_fd));</div><div class="line"><a name="l08771"></a><span class="lineno"> 8771</span> </div><div class="line"><a name="l08772"></a><span class="lineno"> 8772</span>  <span class="comment">// We need to execute the test program in the same environment where</span></div><div class="line"><a name="l08773"></a><span class="lineno"> 8773</span>  <span class="comment">// it was originally invoked. Therefore we change to the original</span></div><div class="line"><a name="l08774"></a><span class="lineno"> 8774</span>  <span class="comment">// working directory first.</span></div><div class="line"><a name="l08775"></a><span class="lineno"> 8775</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> original_dir =</div><div class="line"><a name="l08776"></a><span class="lineno"> 8776</span>  <a class="code" href="classtesting_1_1_unit_test.html#af254e2e695471eb9f128bc556bae3668">UnitTest::GetInstance</a>()-><a class="code" href="classtesting_1_1_unit_test.html#af35839566385e14f6b31232489112621">original_working_dir</a>();</div><div class="line"><a name="l08777"></a><span class="lineno"> 8777</span>  <span class="comment">// We can safely call chdir() as it's a direct system call.</span></div><div class="line"><a name="l08778"></a><span class="lineno"> 8778</span>  <span class="keywordflow">if</span> (chdir(original_dir) != 0) {</div><div class="line"><a name="l08779"></a><span class="lineno"> 8779</span>  DeathTestAbort(<a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(<span class="stringliteral">"chdir(\""</span>) + original_dir + <span class="stringliteral">"\") failed: "</span> +</div><div class="line"><a name="l08780"></a><span class="lineno"> 8780</span>  GetLastErrnoDescription());</div><div class="line"><a name="l08781"></a><span class="lineno"> 8781</span>  <span class="keywordflow">return</span> EXIT_FAILURE;</div><div class="line"><a name="l08782"></a><span class="lineno"> 8782</span>  }</div><div class="line"><a name="l08783"></a><span class="lineno"> 8783</span> </div><div class="line"><a name="l08784"></a><span class="lineno"> 8784</span>  <span class="comment">// We can safely call execve() as it's a direct system call. We</span></div><div class="line"><a name="l08785"></a><span class="lineno"> 8785</span>  <span class="comment">// cannot use execvp() as it's a libc function and thus potentially</span></div><div class="line"><a name="l08786"></a><span class="lineno"> 8786</span>  <span class="comment">// unsafe. Since execve() doesn't search the PATH, the user must</span></div><div class="line"><a name="l08787"></a><span class="lineno"> 8787</span>  <span class="comment">// invoke the test program via a valid path that contains at least</span></div><div class="line"><a name="l08788"></a><span class="lineno"> 8788</span>  <span class="comment">// one path separator.</span></div><div class="line"><a name="l08789"></a><span class="lineno"> 8789</span>  execve(args->argv[0], args->argv, GetEnviron());</div><div class="line"><a name="l08790"></a><span class="lineno"> 8790</span>  DeathTestAbort(<a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(<span class="stringliteral">"execve("</span>) + args->argv[0] + <span class="stringliteral">", ...) in "</span> +</div><div class="line"><a name="l08791"></a><span class="lineno"> 8791</span>  original_dir + <span class="stringliteral">" failed: "</span> +</div><div class="line"><a name="l08792"></a><span class="lineno"> 8792</span>  GetLastErrnoDescription());</div><div class="line"><a name="l08793"></a><span class="lineno"> 8793</span>  <span class="keywordflow">return</span> EXIT_FAILURE;</div><div class="line"><a name="l08794"></a><span class="lineno"> 8794</span> }</div><div class="line"><a name="l08795"></a><span class="lineno"> 8795</span> <span class="preprocessor"># endif // !GTEST_OS_QNX</span></div><div class="line"><a name="l08796"></a><span class="lineno"> 8796</span> </div><div class="line"><a name="l08797"></a><span class="lineno"> 8797</span> <span class="preprocessor"># if GTEST_HAS_CLONE</span></div><div class="line"><a name="l08798"></a><span class="lineno"> 8798</span> <span class="comment">// Two utility routines that together determine the direction the stack</span></div><div class="line"><a name="l08799"></a><span class="lineno"> 8799</span> <span class="comment">// grows.</span></div><div class="line"><a name="l08800"></a><span class="lineno"> 8800</span> <span class="comment">// This could be accomplished more elegantly by a single recursive</span></div><div class="line"><a name="l08801"></a><span class="lineno"> 8801</span> <span class="comment">// function, but we want to guard against the unlikely possibility of</span></div><div class="line"><a name="l08802"></a><span class="lineno"> 8802</span> <span class="comment">// a smart compiler optimizing the recursion away.</span></div><div class="line"><a name="l08803"></a><span class="lineno"> 8803</span> <span class="comment">//</span></div><div class="line"><a name="l08804"></a><span class="lineno"> 8804</span> <span class="comment">// GTEST_NO_INLINE_ is required to prevent GCC 4.6 from inlining</span></div><div class="line"><a name="l08805"></a><span class="lineno"> 8805</span> <span class="comment">// StackLowerThanAddress into StackGrowsDown, which then doesn't give</span></div><div class="line"><a name="l08806"></a><span class="lineno"> 8806</span> <span class="comment">// correct answer.</span></div><div class="line"><a name="l08807"></a><span class="lineno"> 8807</span> <span class="keyword">static</span> <span class="keywordtype">void</span> StackLowerThanAddress(<span class="keyword">const</span> <span class="keywordtype">void</span>* ptr,</div><div class="line"><a name="l08808"></a><span class="lineno"> 8808</span>  <span class="keywordtype">bool</span>* result) <a class="code" href="gtest_8h.html#a9945cbd967fbccb15f8de711f58955c7">GTEST_NO_INLINE_</a>;</div><div class="line"><a name="l08809"></a><span class="lineno"> 8809</span> <span class="keyword">static</span> <span class="keywordtype">void</span> StackLowerThanAddress(<span class="keyword">const</span> <span class="keywordtype">void</span>* ptr, <span class="keywordtype">bool</span>* result) {</div><div class="line"><a name="l08810"></a><span class="lineno"> 8810</span>  <span class="keywordtype">int</span> dummy;</div><div class="line"><a name="l08811"></a><span class="lineno"> 8811</span>  *result = (&dummy < ptr);</div><div class="line"><a name="l08812"></a><span class="lineno"> 8812</span> }</div><div class="line"><a name="l08813"></a><span class="lineno"> 8813</span> </div><div class="line"><a name="l08814"></a><span class="lineno"> 8814</span> <span class="comment">// Make sure AddressSanitizer does not tamper with the stack here.</span></div><div class="line"><a name="l08815"></a><span class="lineno"> 8815</span> <a class="code" href="gtest_8h.html#af18b465f4ba6e36eea7a8d2d79521873">GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_</a></div><div class="line"><a name="l08816"></a><span class="lineno"> 8816</span> <span class="keyword">static</span> <span class="keywordtype">bool</span> StackGrowsDown() {</div><div class="line"><a name="l08817"></a><span class="lineno"> 8817</span>  <span class="keywordtype">int</span> dummy;</div><div class="line"><a name="l08818"></a><span class="lineno"> 8818</span>  <span class="keywordtype">bool</span> result;</div><div class="line"><a name="l08819"></a><span class="lineno"> 8819</span>  StackLowerThanAddress(&dummy, &result);</div><div class="line"><a name="l08820"></a><span class="lineno"> 8820</span>  <span class="keywordflow">return</span> result;</div><div class="line"><a name="l08821"></a><span class="lineno"> 8821</span> }</div><div class="line"><a name="l08822"></a><span class="lineno"> 8822</span> <span class="preprocessor"># endif // GTEST_HAS_CLONE</span></div><div class="line"><a name="l08823"></a><span class="lineno"> 8823</span> </div><div class="line"><a name="l08824"></a><span class="lineno"> 8824</span> <span class="comment">// Spawns a child process with the same executable as the current process in</span></div><div class="line"><a name="l08825"></a><span class="lineno"> 8825</span> <span class="comment">// a thread-safe manner and instructs it to run the death test. The</span></div><div class="line"><a name="l08826"></a><span class="lineno"> 8826</span> <span class="comment">// implementation uses fork(2) + exec. On systems where clone(2) is</span></div><div class="line"><a name="l08827"></a><span class="lineno"> 8827</span> <span class="comment">// available, it is used instead, being slightly more thread-safe. On QNX,</span></div><div class="line"><a name="l08828"></a><span class="lineno"> 8828</span> <span class="comment">// fork supports only single-threaded environments, so this function uses</span></div><div class="line"><a name="l08829"></a><span class="lineno"> 8829</span> <span class="comment">// spawn(2) there instead. The function dies with an error message if</span></div><div class="line"><a name="l08830"></a><span class="lineno"> 8830</span> <span class="comment">// anything goes wrong.</span></div><div class="line"><a name="l08831"></a><span class="lineno"> 8831</span> <span class="keyword">static</span> pid_t ExecDeathTestSpawnChild(<span class="keywordtype">char</span>* <span class="keyword">const</span>* argv, <span class="keywordtype">int</span> close_fd) {</div><div class="line"><a name="l08832"></a><span class="lineno"> 8832</span>  ExecDeathTestArgs args = { argv, close_fd };</div><div class="line"><a name="l08833"></a><span class="lineno"> 8833</span>  pid_t child_pid = -1;</div><div class="line"><a name="l08834"></a><span class="lineno"> 8834</span> </div><div class="line"><a name="l08835"></a><span class="lineno"> 8835</span> <span class="preprocessor"># if GTEST_OS_QNX</span></div><div class="line"><a name="l08836"></a><span class="lineno"> 8836</span>  <span class="comment">// Obtains the current directory and sets it to be closed in the child</span></div><div class="line"><a name="l08837"></a><span class="lineno"> 8837</span>  <span class="comment">// process.</span></div><div class="line"><a name="l08838"></a><span class="lineno"> 8838</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> cwd_fd = open(<span class="stringliteral">"."</span>, O_RDONLY);</div><div class="line"><a name="l08839"></a><span class="lineno"> 8839</span>  GTEST_DEATH_TEST_CHECK_(cwd_fd != -1);</div><div class="line"><a name="l08840"></a><span class="lineno"> 8840</span>  GTEST_DEATH_TEST_CHECK_SYSCALL_(fcntl(cwd_fd, F_SETFD, FD_CLOEXEC));</div><div class="line"><a name="l08841"></a><span class="lineno"> 8841</span>  <span class="comment">// We need to execute the test program in the same environment where</span></div><div class="line"><a name="l08842"></a><span class="lineno"> 8842</span>  <span class="comment">// it was originally invoked. Therefore we change to the original</span></div><div class="line"><a name="l08843"></a><span class="lineno"> 8843</span>  <span class="comment">// working directory first.</span></div><div class="line"><a name="l08844"></a><span class="lineno"> 8844</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> original_dir =</div><div class="line"><a name="l08845"></a><span class="lineno"> 8845</span>  <a class="code" href="classtesting_1_1_unit_test.html#af254e2e695471eb9f128bc556bae3668">UnitTest::GetInstance</a>()-><a class="code" href="classtesting_1_1_unit_test.html#af35839566385e14f6b31232489112621">original_working_dir</a>();</div><div class="line"><a name="l08846"></a><span class="lineno"> 8846</span>  <span class="comment">// We can safely call chdir() as it's a direct system call.</span></div><div class="line"><a name="l08847"></a><span class="lineno"> 8847</span>  <span class="keywordflow">if</span> (chdir(original_dir) != 0) {</div><div class="line"><a name="l08848"></a><span class="lineno"> 8848</span>  DeathTestAbort(<a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(<span class="stringliteral">"chdir(\""</span>) + original_dir + <span class="stringliteral">"\") failed: "</span> +</div><div class="line"><a name="l08849"></a><span class="lineno"> 8849</span>  GetLastErrnoDescription());</div><div class="line"><a name="l08850"></a><span class="lineno"> 8850</span>  <span class="keywordflow">return</span> EXIT_FAILURE;</div><div class="line"><a name="l08851"></a><span class="lineno"> 8851</span>  }</div><div class="line"><a name="l08852"></a><span class="lineno"> 8852</span> </div><div class="line"><a name="l08853"></a><span class="lineno"> 8853</span>  <span class="keywordtype">int</span> fd_flags;</div><div class="line"><a name="l08854"></a><span class="lineno"> 8854</span>  <span class="comment">// Set close_fd to be closed after spawn.</span></div><div class="line"><a name="l08855"></a><span class="lineno"> 8855</span>  GTEST_DEATH_TEST_CHECK_SYSCALL_(fd_flags = fcntl(close_fd, F_GETFD));</div><div class="line"><a name="l08856"></a><span class="lineno"> 8856</span>  GTEST_DEATH_TEST_CHECK_SYSCALL_(fcntl(close_fd, F_SETFD,</div><div class="line"><a name="l08857"></a><span class="lineno"> 8857</span>  fd_flags | FD_CLOEXEC));</div><div class="line"><a name="l08858"></a><span class="lineno"> 8858</span>  <span class="keyword">struct </span>inheritance inherit = {0};</div><div class="line"><a name="l08859"></a><span class="lineno"> 8859</span>  <span class="comment">// spawn is a system call.</span></div><div class="line"><a name="l08860"></a><span class="lineno"> 8860</span>  child_pid =</div><div class="line"><a name="l08861"></a><span class="lineno"> 8861</span>  spawn(args.argv[0], 0, <span class="keyword">nullptr</span>, &inherit, args.argv, GetEnviron());</div><div class="line"><a name="l08862"></a><span class="lineno"> 8862</span>  <span class="comment">// Restores the current working directory.</span></div><div class="line"><a name="l08863"></a><span class="lineno"> 8863</span>  GTEST_DEATH_TEST_CHECK_(fchdir(cwd_fd) != -1);</div><div class="line"><a name="l08864"></a><span class="lineno"> 8864</span>  GTEST_DEATH_TEST_CHECK_SYSCALL_(close(cwd_fd));</div><div class="line"><a name="l08865"></a><span class="lineno"> 8865</span> </div><div class="line"><a name="l08866"></a><span class="lineno"> 8866</span> <span class="preprocessor"># else // GTEST_OS_QNX</span></div><div class="line"><a name="l08867"></a><span class="lineno"> 8867</span> <span class="preprocessor"># if GTEST_OS_LINUX</span></div><div class="line"><a name="l08868"></a><span class="lineno"> 8868</span>  <span class="comment">// When a SIGPROF signal is received while fork() or clone() are executing,</span></div><div class="line"><a name="l08869"></a><span class="lineno"> 8869</span>  <span class="comment">// the process may hang. To avoid this, we ignore SIGPROF here and re-enable</span></div><div class="line"><a name="l08870"></a><span class="lineno"> 8870</span>  <span class="comment">// it after the call to fork()/clone() is complete.</span></div><div class="line"><a name="l08871"></a><span class="lineno"> 8871</span>  <span class="keyword">struct </span>sigaction saved_sigprof_action;</div><div class="line"><a name="l08872"></a><span class="lineno"> 8872</span>  <span class="keyword">struct </span>sigaction ignore_sigprof_action;</div><div class="line"><a name="l08873"></a><span class="lineno"> 8873</span>  memset(&ignore_sigprof_action, 0, <span class="keyword">sizeof</span>(ignore_sigprof_action));</div><div class="line"><a name="l08874"></a><span class="lineno"> 8874</span>  sigemptyset(&ignore_sigprof_action.sa_mask);</div><div class="line"><a name="l08875"></a><span class="lineno"> 8875</span>  ignore_sigprof_action.sa_handler = SIG_IGN;</div><div class="line"><a name="l08876"></a><span class="lineno"> 8876</span>  GTEST_DEATH_TEST_CHECK_SYSCALL_(sigaction(</div><div class="line"><a name="l08877"></a><span class="lineno"> 8877</span>  SIGPROF, &ignore_sigprof_action, &saved_sigprof_action));</div><div class="line"><a name="l08878"></a><span class="lineno"> 8878</span> <span class="preprocessor"># endif // GTEST_OS_LINUX</span></div><div class="line"><a name="l08879"></a><span class="lineno"> 8879</span> </div><div class="line"><a name="l08880"></a><span class="lineno"> 8880</span> <span class="preprocessor"># if GTEST_HAS_CLONE</span></div><div class="line"><a name="l08881"></a><span class="lineno"> 8881</span>  <span class="keyword">const</span> <span class="keywordtype">bool</span> use_fork = <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(death_test_use_fork);</div><div class="line"><a name="l08882"></a><span class="lineno"> 8882</span> </div><div class="line"><a name="l08883"></a><span class="lineno"> 8883</span>  <span class="keywordflow">if</span> (!use_fork) {</div><div class="line"><a name="l08884"></a><span class="lineno"> 8884</span>  <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">bool</span> stack_grows_down = StackGrowsDown();</div><div class="line"><a name="l08885"></a><span class="lineno"> 8885</span>  <span class="keyword">const</span> <span class="keywordtype">size_t</span> stack_size = getpagesize();</div><div class="line"><a name="l08886"></a><span class="lineno"> 8886</span>  <span class="comment">// MMAP_ANONYMOUS is not defined on Mac, so we use MAP_ANON instead.</span></div><div class="line"><a name="l08887"></a><span class="lineno"> 8887</span>  <span class="keywordtype">void</span>* <span class="keyword">const</span> stack = mmap(<span class="keyword">nullptr</span>, stack_size, PROT_READ | PROT_WRITE,</div><div class="line"><a name="l08888"></a><span class="lineno"> 8888</span>  MAP_ANON | MAP_PRIVATE, -1, 0);</div><div class="line"><a name="l08889"></a><span class="lineno"> 8889</span>  GTEST_DEATH_TEST_CHECK_(stack != MAP_FAILED);</div><div class="line"><a name="l08890"></a><span class="lineno"> 8890</span> </div><div class="line"><a name="l08891"></a><span class="lineno"> 8891</span>  <span class="comment">// Maximum stack alignment in bytes: For a downward-growing stack, this</span></div><div class="line"><a name="l08892"></a><span class="lineno"> 8892</span>  <span class="comment">// amount is subtracted from size of the stack space to get an address</span></div><div class="line"><a name="l08893"></a><span class="lineno"> 8893</span>  <span class="comment">// that is within the stack space and is aligned on all systems we care</span></div><div class="line"><a name="l08894"></a><span class="lineno"> 8894</span>  <span class="comment">// about. As far as I know there is no ABI with stack alignment greater</span></div><div class="line"><a name="l08895"></a><span class="lineno"> 8895</span>  <span class="comment">// than 64. We assume stack and stack_size already have alignment of</span></div><div class="line"><a name="l08896"></a><span class="lineno"> 8896</span>  <span class="comment">// kMaxStackAlignment.</span></div><div class="line"><a name="l08897"></a><span class="lineno"> 8897</span>  <span class="keyword">const</span> <span class="keywordtype">size_t</span> kMaxStackAlignment = 64;</div><div class="line"><a name="l08898"></a><span class="lineno"> 8898</span>  <span class="keywordtype">void</span>* <span class="keyword">const</span> stack_top =</div><div class="line"><a name="l08899"></a><span class="lineno"> 8899</span>  <span class="keyword">static_cast<</span><span class="keywordtype">char</span>*<span class="keyword">></span>(stack) +</div><div class="line"><a name="l08900"></a><span class="lineno"> 8900</span>  (stack_grows_down ? stack_size - kMaxStackAlignment : 0);</div><div class="line"><a name="l08901"></a><span class="lineno"> 8901</span>  GTEST_DEATH_TEST_CHECK_(stack_size > kMaxStackAlignment &&</div><div class="line"><a name="l08902"></a><span class="lineno"> 8902</span>  reinterpret_cast<intptr_t>(stack_top) % kMaxStackAlignment == 0);</div><div class="line"><a name="l08903"></a><span class="lineno"> 8903</span> </div><div class="line"><a name="l08904"></a><span class="lineno"> 8904</span>  child_pid = clone(&ExecDeathTestChildMain, stack_top, SIGCHLD, &args);</div><div class="line"><a name="l08905"></a><span class="lineno"> 8905</span> </div><div class="line"><a name="l08906"></a><span class="lineno"> 8906</span>  GTEST_DEATH_TEST_CHECK_(munmap(stack, stack_size) != -1);</div><div class="line"><a name="l08907"></a><span class="lineno"> 8907</span>  }</div><div class="line"><a name="l08908"></a><span class="lineno"> 8908</span> <span class="preprocessor"># else</span></div><div class="line"><a name="l08909"></a><span class="lineno"> 8909</span>  <span class="keyword">const</span> <span class="keywordtype">bool</span> use_fork = <span class="keyword">true</span>;</div><div class="line"><a name="l08910"></a><span class="lineno"> 8910</span> <span class="preprocessor"># endif // GTEST_HAS_CLONE</span></div><div class="line"><a name="l08911"></a><span class="lineno"> 8911</span> </div><div class="line"><a name="l08912"></a><span class="lineno"> 8912</span>  <span class="keywordflow">if</span> (use_fork && (child_pid = fork()) == 0) {</div><div class="line"><a name="l08913"></a><span class="lineno"> 8913</span>  ExecDeathTestChildMain(&args);</div><div class="line"><a name="l08914"></a><span class="lineno"> 8914</span>  _exit(0);</div><div class="line"><a name="l08915"></a><span class="lineno"> 8915</span>  }</div><div class="line"><a name="l08916"></a><span class="lineno"> 8916</span> <span class="preprocessor"># endif // GTEST_OS_QNX</span></div><div class="line"><a name="l08917"></a><span class="lineno"> 8917</span> <span class="preprocessor"># if GTEST_OS_LINUX</span></div><div class="line"><a name="l08918"></a><span class="lineno"> 8918</span>  GTEST_DEATH_TEST_CHECK_SYSCALL_(</div><div class="line"><a name="l08919"></a><span class="lineno"> 8919</span>  sigaction(SIGPROF, &saved_sigprof_action, <span class="keyword">nullptr</span>));</div><div class="line"><a name="l08920"></a><span class="lineno"> 8920</span> <span class="preprocessor"># endif // GTEST_OS_LINUX</span></div><div class="line"><a name="l08921"></a><span class="lineno"> 8921</span> </div><div class="line"><a name="l08922"></a><span class="lineno"> 8922</span>  GTEST_DEATH_TEST_CHECK_(child_pid != -1);</div><div class="line"><a name="l08923"></a><span class="lineno"> 8923</span>  <span class="keywordflow">return</span> child_pid;</div><div class="line"><a name="l08924"></a><span class="lineno"> 8924</span> }</div><div class="line"><a name="l08925"></a><span class="lineno"> 8925</span> </div><div class="line"><a name="l08926"></a><span class="lineno"> 8926</span> <span class="comment">// The AssumeRole process for a fork-and-exec death test. It re-executes the</span></div><div class="line"><a name="l08927"></a><span class="lineno"> 8927</span> <span class="comment">// main program from the beginning, setting the --gtest_filter</span></div><div class="line"><a name="l08928"></a><span class="lineno"> 8928</span> <span class="comment">// and --gtest_internal_run_death_test flags to cause only the current</span></div><div class="line"><a name="l08929"></a><span class="lineno"> 8929</span> <span class="comment">// death test to be re-run.</span></div><div class="line"><a name="l08930"></a><span class="lineno"> 8930</span> DeathTest::TestRole ExecDeathTest::AssumeRole() {</div><div class="line"><a name="l08931"></a><span class="lineno"> 8931</span>  <span class="keyword">const</span> UnitTestImpl* <span class="keyword">const</span> impl = GetUnitTestImpl();</div><div class="line"><a name="l08932"></a><span class="lineno"> 8932</span>  <span class="keyword">const</span> InternalRunDeathTestFlag* <span class="keyword">const</span> flag =</div><div class="line"><a name="l08933"></a><span class="lineno"> 8933</span>  impl->internal_run_death_test_flag();</div><div class="line"><a name="l08934"></a><span class="lineno"> 8934</span>  <span class="keyword">const</span> TestInfo* <span class="keyword">const</span> info = impl->current_test_info();</div><div class="line"><a name="l08935"></a><span class="lineno"> 8935</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> death_test_index = info->result()->death_test_count();</div><div class="line"><a name="l08936"></a><span class="lineno"> 8936</span> </div><div class="line"><a name="l08937"></a><span class="lineno"> 8937</span>  <span class="keywordflow">if</span> (flag != <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l08938"></a><span class="lineno"> 8938</span>  set_write_fd(flag->write_fd());</div><div class="line"><a name="l08939"></a><span class="lineno"> 8939</span>  <span class="keywordflow">return</span> EXECUTE_TEST;</div><div class="line"><a name="l08940"></a><span class="lineno"> 8940</span>  }</div><div class="line"><a name="l08941"></a><span class="lineno"> 8941</span> </div><div class="line"><a name="l08942"></a><span class="lineno"> 8942</span>  <span class="keywordtype">int</span> pipe_fd[2];</div><div class="line"><a name="l08943"></a><span class="lineno"> 8943</span>  GTEST_DEATH_TEST_CHECK_(pipe(pipe_fd) != -1);</div><div class="line"><a name="l08944"></a><span class="lineno"> 8944</span>  <span class="comment">// Clear the close-on-exec flag on the write end of the pipe, lest</span></div><div class="line"><a name="l08945"></a><span class="lineno"> 8945</span>  <span class="comment">// it be closed when the child process does an exec:</span></div><div class="line"><a name="l08946"></a><span class="lineno"> 8946</span>  GTEST_DEATH_TEST_CHECK_(fcntl(pipe_fd[1], F_SETFD, 0) != -1);</div><div class="line"><a name="l08947"></a><span class="lineno"> 8947</span> </div><div class="line"><a name="l08948"></a><span class="lineno"> 8948</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> filter_flag = <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(<span class="stringliteral">"--"</span>) + <a class="code" href="gtest_8h.html#a088e84784c589ba9b1fc48602ad8eabf">GTEST_FLAG_PREFIX_</a> +</div><div class="line"><a name="l08949"></a><span class="lineno"> 8949</span>  kFilterFlag + <span class="stringliteral">"="</span> + info->test_suite_name() +</div><div class="line"><a name="l08950"></a><span class="lineno"> 8950</span>  <span class="stringliteral">"."</span> + info->name();</div><div class="line"><a name="l08951"></a><span class="lineno"> 8951</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> internal_flag =</div><div class="line"><a name="l08952"></a><span class="lineno"> 8952</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(<span class="stringliteral">"--"</span>) + <a class="code" href="gtest_8h.html#a088e84784c589ba9b1fc48602ad8eabf">GTEST_FLAG_PREFIX_</a> + kInternalRunDeathTestFlag + <span class="stringliteral">"="</span></div><div class="line"><a name="l08953"></a><span class="lineno"> 8953</span>  + file_ + <span class="stringliteral">"|"</span> + <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(line_) + <span class="stringliteral">"|"</span></div><div class="line"><a name="l08954"></a><span class="lineno"> 8954</span>  + <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(death_test_index) + <span class="stringliteral">"|"</span></div><div class="line"><a name="l08955"></a><span class="lineno"> 8955</span>  + <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(pipe_fd[1]);</div><div class="line"><a name="l08956"></a><span class="lineno"> 8956</span>  Arguments args;</div><div class="line"><a name="l08957"></a><span class="lineno"> 8957</span>  args.AddArguments(GetArgvsForDeathTestChildProcess());</div><div class="line"><a name="l08958"></a><span class="lineno"> 8958</span>  args.AddArgument(filter_flag.c_str());</div><div class="line"><a name="l08959"></a><span class="lineno"> 8959</span>  args.AddArgument(internal_flag.c_str());</div><div class="line"><a name="l08960"></a><span class="lineno"> 8960</span> </div><div class="line"><a name="l08961"></a><span class="lineno"> 8961</span>  DeathTest::set_last_death_test_message(<span class="stringliteral">""</span>);</div><div class="line"><a name="l08962"></a><span class="lineno"> 8962</span> </div><div class="line"><a name="l08963"></a><span class="lineno"> 8963</span>  <a class="code" href="namespacetesting_1_1internal.html#a8ec00d458d0d442bd64af7b5f9c22dda">CaptureStderr</a>();</div><div class="line"><a name="l08964"></a><span class="lineno"> 8964</span>  <span class="comment">// See the comment in NoExecDeathTest::AssumeRole for why the next line</span></div><div class="line"><a name="l08965"></a><span class="lineno"> 8965</span>  <span class="comment">// is necessary.</span></div><div class="line"><a name="l08966"></a><span class="lineno"> 8966</span>  <a class="code" href="namespacetesting_1_1internal.html#a2135f223bf6b527729aeaa651115183b">FlushInfoLog</a>();</div><div class="line"><a name="l08967"></a><span class="lineno"> 8967</span> </div><div class="line"><a name="l08968"></a><span class="lineno"> 8968</span>  <span class="keyword">const</span> pid_t child_pid = ExecDeathTestSpawnChild(args.Argv(), pipe_fd[0]);</div><div class="line"><a name="l08969"></a><span class="lineno"> 8969</span>  GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1]));</div><div class="line"><a name="l08970"></a><span class="lineno"> 8970</span>  set_child_pid(child_pid);</div><div class="line"><a name="l08971"></a><span class="lineno"> 8971</span>  set_read_fd(pipe_fd[0]);</div><div class="line"><a name="l08972"></a><span class="lineno"> 8972</span>  set_spawned(<span class="keyword">true</span>);</div><div class="line"><a name="l08973"></a><span class="lineno"> 8973</span>  <span class="keywordflow">return</span> OVERSEE_TEST;</div><div class="line"><a name="l08974"></a><span class="lineno"> 8974</span> }</div><div class="line"><a name="l08975"></a><span class="lineno"> 8975</span> </div><div class="line"><a name="l08976"></a><span class="lineno"> 8976</span> <span class="preprocessor"># endif // !GTEST_OS_WINDOWS</span></div><div class="line"><a name="l08977"></a><span class="lineno"> 8977</span> </div><div class="line"><a name="l08978"></a><span class="lineno"> 8978</span> <span class="comment">// Creates a concrete DeathTest-derived class that depends on the</span></div><div class="line"><a name="l08979"></a><span class="lineno"> 8979</span> <span class="comment">// --gtest_death_test_style flag, and sets the pointer pointed to</span></div><div class="line"><a name="l08980"></a><span class="lineno"> 8980</span> <span class="comment">// by the "test" argument to its address. If the test should be</span></div><div class="line"><a name="l08981"></a><span class="lineno"> 8981</span> <span class="comment">// skipped, sets that pointer to NULL. Returns true, unless the</span></div><div class="line"><a name="l08982"></a><span class="lineno"> 8982</span> <span class="comment">// flag is set to an invalid value.</span></div><div class="line"><a name="l08983"></a><span class="lineno"> 8983</span> <span class="keywordtype">bool</span> DefaultDeathTestFactory::Create(<span class="keyword">const</span> <span class="keywordtype">char</span>* statement,</div><div class="line"><a name="l08984"></a><span class="lineno"> 8984</span>  Matcher<const std::string&> matcher,</div><div class="line"><a name="l08985"></a><span class="lineno"> 8985</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* file, <span class="keywordtype">int</span> line,</div><div class="line"><a name="l08986"></a><span class="lineno"> 8986</span>  DeathTest** test) {</div><div class="line"><a name="l08987"></a><span class="lineno"> 8987</span>  UnitTestImpl* <span class="keyword">const</span> impl = GetUnitTestImpl();</div><div class="line"><a name="l08988"></a><span class="lineno"> 8988</span>  <span class="keyword">const</span> InternalRunDeathTestFlag* <span class="keyword">const</span> flag =</div><div class="line"><a name="l08989"></a><span class="lineno"> 8989</span>  impl->internal_run_death_test_flag();</div><div class="line"><a name="l08990"></a><span class="lineno"> 8990</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> death_test_index = impl->current_test_info()</div><div class="line"><a name="l08991"></a><span class="lineno"> 8991</span>  ->increment_death_test_count();</div><div class="line"><a name="l08992"></a><span class="lineno"> 8992</span> </div><div class="line"><a name="l08993"></a><span class="lineno"> 8993</span>  <span class="keywordflow">if</span> (flag != <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l08994"></a><span class="lineno"> 8994</span>  <span class="keywordflow">if</span> (death_test_index > flag->index()) {</div><div class="line"><a name="l08995"></a><span class="lineno"> 8995</span>  DeathTest::set_last_death_test_message(</div><div class="line"><a name="l08996"></a><span class="lineno"> 8996</span>  <span class="stringliteral">"Death test count ("</span> + <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(death_test_index)</div><div class="line"><a name="l08997"></a><span class="lineno"> 8997</span>  + <span class="stringliteral">") somehow exceeded expected maximum ("</span></div><div class="line"><a name="l08998"></a><span class="lineno"> 8998</span>  + <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(flag->index()) + <span class="stringliteral">")"</span>);</div><div class="line"><a name="l08999"></a><span class="lineno"> 8999</span>  <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l09000"></a><span class="lineno"> 9000</span>  }</div><div class="line"><a name="l09001"></a><span class="lineno"> 9001</span> </div><div class="line"><a name="l09002"></a><span class="lineno"> 9002</span>  <span class="keywordflow">if</span> (!(flag->file() == file && flag->line() == line &&</div><div class="line"><a name="l09003"></a><span class="lineno"> 9003</span>  flag->index() == death_test_index)) {</div><div class="line"><a name="l09004"></a><span class="lineno"> 9004</span>  *test = <span class="keyword">nullptr</span>;</div><div class="line"><a name="l09005"></a><span class="lineno"> 9005</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l09006"></a><span class="lineno"> 9006</span>  }</div><div class="line"><a name="l09007"></a><span class="lineno"> 9007</span>  }</div><div class="line"><a name="l09008"></a><span class="lineno"> 9008</span> </div><div class="line"><a name="l09009"></a><span class="lineno"> 9009</span> <span class="preprocessor"># if GTEST_OS_WINDOWS</span></div><div class="line"><a name="l09010"></a><span class="lineno"> 9010</span> </div><div class="line"><a name="l09011"></a><span class="lineno"> 9011</span>  <span class="keywordflow">if</span> (<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(death_test_style) == <span class="stringliteral">"threadsafe"</span> ||</div><div class="line"><a name="l09012"></a><span class="lineno"> 9012</span>  <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(death_test_style) == <span class="stringliteral">"fast"</span>) {</div><div class="line"><a name="l09013"></a><span class="lineno"> 9013</span>  *test = <span class="keyword">new</span> WindowsDeathTest(statement, std::move(matcher), file, line);</div><div class="line"><a name="l09014"></a><span class="lineno"> 9014</span>  }</div><div class="line"><a name="l09015"></a><span class="lineno"> 9015</span> </div><div class="line"><a name="l09016"></a><span class="lineno"> 9016</span> <span class="preprocessor"># elif GTEST_OS_FUCHSIA</span></div><div class="line"><a name="l09017"></a><span class="lineno"> 9017</span> </div><div class="line"><a name="l09018"></a><span class="lineno"> 9018</span>  <span class="keywordflow">if</span> (<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(death_test_style) == <span class="stringliteral">"threadsafe"</span> ||</div><div class="line"><a name="l09019"></a><span class="lineno"> 9019</span>  <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(death_test_style) == <span class="stringliteral">"fast"</span>) {</div><div class="line"><a name="l09020"></a><span class="lineno"> 9020</span>  *test = <span class="keyword">new</span> FuchsiaDeathTest(statement, std::move(matcher), file, line);</div><div class="line"><a name="l09021"></a><span class="lineno"> 9021</span>  }</div><div class="line"><a name="l09022"></a><span class="lineno"> 9022</span> </div><div class="line"><a name="l09023"></a><span class="lineno"> 9023</span> <span class="preprocessor"># else</span></div><div class="line"><a name="l09024"></a><span class="lineno"> 9024</span> </div><div class="line"><a name="l09025"></a><span class="lineno"> 9025</span>  <span class="keywordflow">if</span> (<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(death_test_style) == <span class="stringliteral">"threadsafe"</span>) {</div><div class="line"><a name="l09026"></a><span class="lineno"> 9026</span>  *test = <span class="keyword">new</span> ExecDeathTest(statement, std::move(matcher), file, line);</div><div class="line"><a name="l09027"></a><span class="lineno"> 9027</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(death_test_style) == <span class="stringliteral">"fast"</span>) {</div><div class="line"><a name="l09028"></a><span class="lineno"> 9028</span>  *test = <span class="keyword">new</span> NoExecDeathTest(statement, std::move(matcher));</div><div class="line"><a name="l09029"></a><span class="lineno"> 9029</span>  }</div><div class="line"><a name="l09030"></a><span class="lineno"> 9030</span> </div><div class="line"><a name="l09031"></a><span class="lineno"> 9031</span> <span class="preprocessor"># endif // GTEST_OS_WINDOWS</span></div><div class="line"><a name="l09032"></a><span class="lineno"> 9032</span> </div><div class="line"><a name="l09033"></a><span class="lineno"> 9033</span>  <span class="keywordflow">else</span> { <span class="comment">// NOLINT - this is more readable than unbalanced brackets inside #if.</span></div><div class="line"><a name="l09034"></a><span class="lineno"> 9034</span>  DeathTest::set_last_death_test_message(</div><div class="line"><a name="l09035"></a><span class="lineno"> 9035</span>  <span class="stringliteral">"Unknown death test style \""</span> + <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(death_test_style)</div><div class="line"><a name="l09036"></a><span class="lineno"> 9036</span>  + <span class="stringliteral">"\" encountered"</span>);</div><div class="line"><a name="l09037"></a><span class="lineno"> 9037</span>  <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l09038"></a><span class="lineno"> 9038</span>  }</div><div class="line"><a name="l09039"></a><span class="lineno"> 9039</span> </div><div class="line"><a name="l09040"></a><span class="lineno"> 9040</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l09041"></a><span class="lineno"> 9041</span> }</div><div class="line"><a name="l09042"></a><span class="lineno"> 9042</span> </div><div class="line"><a name="l09043"></a><span class="lineno"> 9043</span> <span class="preprocessor"># if GTEST_OS_WINDOWS</span></div><div class="line"><a name="l09044"></a><span class="lineno"> 9044</span> <span class="comment">// Recreates the pipe and event handles from the provided parameters,</span></div><div class="line"><a name="l09045"></a><span class="lineno"> 9045</span> <span class="comment">// signals the event, and returns a file descriptor wrapped around the pipe</span></div><div class="line"><a name="l09046"></a><span class="lineno"> 9046</span> <span class="comment">// handle. This function is called in the child process only.</span></div><div class="line"><a name="l09047"></a><span class="lineno"> 9047</span> <span class="keyword">static</span> <span class="keywordtype">int</span> GetStatusFileDescriptor(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> parent_process_id,</div><div class="line"><a name="l09048"></a><span class="lineno"> 9048</span>  <span class="keywordtype">size_t</span> write_handle_as_size_t,</div><div class="line"><a name="l09049"></a><span class="lineno"> 9049</span>  <span class="keywordtype">size_t</span> event_handle_as_size_t) {</div><div class="line"><a name="l09050"></a><span class="lineno"> 9050</span>  AutoHandle parent_process_handle(::OpenProcess(PROCESS_DUP_HANDLE,</div><div class="line"><a name="l09051"></a><span class="lineno"> 9051</span>  FALSE, <span class="comment">// Non-inheritable.</span></div><div class="line"><a name="l09052"></a><span class="lineno"> 9052</span>  parent_process_id));</div><div class="line"><a name="l09053"></a><span class="lineno"> 9053</span>  <span class="keywordflow">if</span> (parent_process_handle.Get() == INVALID_HANDLE_VALUE) {</div><div class="line"><a name="l09054"></a><span class="lineno"> 9054</span>  DeathTestAbort(<span class="stringliteral">"Unable to open parent process "</span> +</div><div class="line"><a name="l09055"></a><span class="lineno"> 9055</span>  <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(parent_process_id));</div><div class="line"><a name="l09056"></a><span class="lineno"> 9056</span>  }</div><div class="line"><a name="l09057"></a><span class="lineno"> 9057</span> </div><div class="line"><a name="l09058"></a><span class="lineno"> 9058</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(<span class="keyword">sizeof</span>(HANDLE) <= <span class="keyword">sizeof</span>(<span class="keywordtype">size_t</span>));</div><div class="line"><a name="l09059"></a><span class="lineno"> 9059</span> </div><div class="line"><a name="l09060"></a><span class="lineno"> 9060</span>  <span class="keyword">const</span> HANDLE write_handle =</div><div class="line"><a name="l09061"></a><span class="lineno"> 9061</span>  <span class="keyword">reinterpret_cast<</span>HANDLE<span class="keyword">></span>(write_handle_as_size_t);</div><div class="line"><a name="l09062"></a><span class="lineno"> 9062</span>  HANDLE dup_write_handle;</div><div class="line"><a name="l09063"></a><span class="lineno"> 9063</span> </div><div class="line"><a name="l09064"></a><span class="lineno"> 9064</span>  <span class="comment">// The newly initialized handle is accessible only in the parent</span></div><div class="line"><a name="l09065"></a><span class="lineno"> 9065</span>  <span class="comment">// process. To obtain one accessible within the child, we need to use</span></div><div class="line"><a name="l09066"></a><span class="lineno"> 9066</span>  <span class="comment">// DuplicateHandle.</span></div><div class="line"><a name="l09067"></a><span class="lineno"> 9067</span>  <span class="keywordflow">if</span> (!::DuplicateHandle(parent_process_handle.Get(), write_handle,</div><div class="line"><a name="l09068"></a><span class="lineno"> 9068</span>  ::GetCurrentProcess(), &dup_write_handle,</div><div class="line"><a name="l09069"></a><span class="lineno"> 9069</span>  0x0, <span class="comment">// Requested privileges ignored since</span></div><div class="line"><a name="l09070"></a><span class="lineno"> 9070</span>  <span class="comment">// DUPLICATE_SAME_ACCESS is used.</span></div><div class="line"><a name="l09071"></a><span class="lineno"> 9071</span>  FALSE, <span class="comment">// Request non-inheritable handler.</span></div><div class="line"><a name="l09072"></a><span class="lineno"> 9072</span>  DUPLICATE_SAME_ACCESS)) {</div><div class="line"><a name="l09073"></a><span class="lineno"> 9073</span>  DeathTestAbort(<span class="stringliteral">"Unable to duplicate the pipe handle "</span> +</div><div class="line"><a name="l09074"></a><span class="lineno"> 9074</span>  <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(write_handle_as_size_t) +</div><div class="line"><a name="l09075"></a><span class="lineno"> 9075</span>  <span class="stringliteral">" from the parent process "</span> +</div><div class="line"><a name="l09076"></a><span class="lineno"> 9076</span>  <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(parent_process_id));</div><div class="line"><a name="l09077"></a><span class="lineno"> 9077</span>  }</div><div class="line"><a name="l09078"></a><span class="lineno"> 9078</span> </div><div class="line"><a name="l09079"></a><span class="lineno"> 9079</span>  <span class="keyword">const</span> HANDLE event_handle = <span class="keyword">reinterpret_cast<</span>HANDLE<span class="keyword">></span>(event_handle_as_size_t);</div><div class="line"><a name="l09080"></a><span class="lineno"> 9080</span>  HANDLE dup_event_handle;</div><div class="line"><a name="l09081"></a><span class="lineno"> 9081</span> </div><div class="line"><a name="l09082"></a><span class="lineno"> 9082</span>  <span class="keywordflow">if</span> (!::DuplicateHandle(parent_process_handle.Get(), event_handle,</div><div class="line"><a name="l09083"></a><span class="lineno"> 9083</span>  ::GetCurrentProcess(), &dup_event_handle,</div><div class="line"><a name="l09084"></a><span class="lineno"> 9084</span>  0x0,</div><div class="line"><a name="l09085"></a><span class="lineno"> 9085</span>  FALSE,</div><div class="line"><a name="l09086"></a><span class="lineno"> 9086</span>  DUPLICATE_SAME_ACCESS)) {</div><div class="line"><a name="l09087"></a><span class="lineno"> 9087</span>  DeathTestAbort(<span class="stringliteral">"Unable to duplicate the event handle "</span> +</div><div class="line"><a name="l09088"></a><span class="lineno"> 9088</span>  <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(event_handle_as_size_t) +</div><div class="line"><a name="l09089"></a><span class="lineno"> 9089</span>  <span class="stringliteral">" from the parent process "</span> +</div><div class="line"><a name="l09090"></a><span class="lineno"> 9090</span>  <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(parent_process_id));</div><div class="line"><a name="l09091"></a><span class="lineno"> 9091</span>  }</div><div class="line"><a name="l09092"></a><span class="lineno"> 9092</span> </div><div class="line"><a name="l09093"></a><span class="lineno"> 9093</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> write_fd =</div><div class="line"><a name="l09094"></a><span class="lineno"> 9094</span>  ::_open_osfhandle(reinterpret_cast<intptr_t>(dup_write_handle), O_APPEND);</div><div class="line"><a name="l09095"></a><span class="lineno"> 9095</span>  <span class="keywordflow">if</span> (write_fd == -1) {</div><div class="line"><a name="l09096"></a><span class="lineno"> 9096</span>  DeathTestAbort(<span class="stringliteral">"Unable to convert pipe handle "</span> +</div><div class="line"><a name="l09097"></a><span class="lineno"> 9097</span>  <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(write_handle_as_size_t) +</div><div class="line"><a name="l09098"></a><span class="lineno"> 9098</span>  <span class="stringliteral">" to a file descriptor"</span>);</div><div class="line"><a name="l09099"></a><span class="lineno"> 9099</span>  }</div><div class="line"><a name="l09100"></a><span class="lineno"> 9100</span> </div><div class="line"><a name="l09101"></a><span class="lineno"> 9101</span>  <span class="comment">// Signals the parent that the write end of the pipe has been acquired</span></div><div class="line"><a name="l09102"></a><span class="lineno"> 9102</span>  <span class="comment">// so the parent can release its own write end.</span></div><div class="line"><a name="l09103"></a><span class="lineno"> 9103</span>  ::SetEvent(dup_event_handle);</div><div class="line"><a name="l09104"></a><span class="lineno"> 9104</span> </div><div class="line"><a name="l09105"></a><span class="lineno"> 9105</span>  <span class="keywordflow">return</span> write_fd;</div><div class="line"><a name="l09106"></a><span class="lineno"> 9106</span> }</div><div class="line"><a name="l09107"></a><span class="lineno"> 9107</span> <span class="preprocessor"># endif // GTEST_OS_WINDOWS</span></div><div class="line"><a name="l09108"></a><span class="lineno"> 9108</span> </div><div class="line"><a name="l09109"></a><span class="lineno"> 9109</span> <span class="comment">// Returns a newly created InternalRunDeathTestFlag object with fields</span></div><div class="line"><a name="l09110"></a><span class="lineno"> 9110</span> <span class="comment">// initialized from the GTEST_FLAG(internal_run_death_test) flag if</span></div><div class="line"><a name="l09111"></a><span class="lineno"> 9111</span> <span class="comment">// the flag is specified; otherwise returns NULL.</span></div><div class="line"><a name="l09112"></a><span class="lineno"> 9112</span> InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {</div><div class="line"><a name="l09113"></a><span class="lineno"> 9113</span>  <span class="keywordflow">if</span> (<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(internal_run_death_test) == <span class="stringliteral">""</span>) <span class="keywordflow">return</span> <span class="keyword">nullptr</span>;</div><div class="line"><a name="l09114"></a><span class="lineno"> 9114</span> </div><div class="line"><a name="l09115"></a><span class="lineno"> 9115</span>  <span class="comment">// GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we</span></div><div class="line"><a name="l09116"></a><span class="lineno"> 9116</span>  <span class="comment">// can use it here.</span></div><div class="line"><a name="l09117"></a><span class="lineno"> 9117</span>  <span class="keywordtype">int</span> line = -1;</div><div class="line"><a name="l09118"></a><span class="lineno"> 9118</span>  <span class="keywordtype">int</span> index = -1;</div><div class="line"><a name="l09119"></a><span class="lineno"> 9119</span>  ::std::vector< ::std::string> fields;</div><div class="line"><a name="l09120"></a><span class="lineno"> 9120</span>  SplitString(<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(internal_run_death_test).c_str(), <span class="charliteral">'|'</span>, &fields);</div><div class="line"><a name="l09121"></a><span class="lineno"> 9121</span>  <span class="keywordtype">int</span> write_fd = -1;</div><div class="line"><a name="l09122"></a><span class="lineno"> 9122</span> </div><div class="line"><a name="l09123"></a><span class="lineno"> 9123</span> <span class="preprocessor"># if GTEST_OS_WINDOWS</span></div><div class="line"><a name="l09124"></a><span class="lineno"> 9124</span> </div><div class="line"><a name="l09125"></a><span class="lineno"> 9125</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> parent_process_id = 0;</div><div class="line"><a name="l09126"></a><span class="lineno"> 9126</span>  <span class="keywordtype">size_t</span> write_handle_as_size_t = 0;</div><div class="line"><a name="l09127"></a><span class="lineno"> 9127</span>  <span class="keywordtype">size_t</span> event_handle_as_size_t = 0;</div><div class="line"><a name="l09128"></a><span class="lineno"> 9128</span> </div><div class="line"><a name="l09129"></a><span class="lineno"> 9129</span>  <span class="keywordflow">if</span> (fields.size() != 6</div><div class="line"><a name="l09130"></a><span class="lineno"> 9130</span>  || !ParseNaturalNumber(fields[1], &line)</div><div class="line"><a name="l09131"></a><span class="lineno"> 9131</span>  || !ParseNaturalNumber(fields[2], &index)</div><div class="line"><a name="l09132"></a><span class="lineno"> 9132</span>  || !ParseNaturalNumber(fields[3], &parent_process_id)</div><div class="line"><a name="l09133"></a><span class="lineno"> 9133</span>  || !ParseNaturalNumber(fields[4], &write_handle_as_size_t)</div><div class="line"><a name="l09134"></a><span class="lineno"> 9134</span>  || !ParseNaturalNumber(fields[5], &event_handle_as_size_t)) {</div><div class="line"><a name="l09135"></a><span class="lineno"> 9135</span>  DeathTestAbort(<span class="stringliteral">"Bad --gtest_internal_run_death_test flag: "</span> +</div><div class="line"><a name="l09136"></a><span class="lineno"> 9136</span>  <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(internal_run_death_test));</div><div class="line"><a name="l09137"></a><span class="lineno"> 9137</span>  }</div><div class="line"><a name="l09138"></a><span class="lineno"> 9138</span>  write_fd = GetStatusFileDescriptor(parent_process_id,</div><div class="line"><a name="l09139"></a><span class="lineno"> 9139</span>  write_handle_as_size_t,</div><div class="line"><a name="l09140"></a><span class="lineno"> 9140</span>  event_handle_as_size_t);</div><div class="line"><a name="l09141"></a><span class="lineno"> 9141</span> </div><div class="line"><a name="l09142"></a><span class="lineno"> 9142</span> <span class="preprocessor"># elif GTEST_OS_FUCHSIA</span></div><div class="line"><a name="l09143"></a><span class="lineno"> 9143</span> </div><div class="line"><a name="l09144"></a><span class="lineno"> 9144</span>  <span class="keywordflow">if</span> (fields.size() != 3</div><div class="line"><a name="l09145"></a><span class="lineno"> 9145</span>  || !ParseNaturalNumber(fields[1], &line)</div><div class="line"><a name="l09146"></a><span class="lineno"> 9146</span>  || !ParseNaturalNumber(fields[2], &index)) {</div><div class="line"><a name="l09147"></a><span class="lineno"> 9147</span>  DeathTestAbort(<span class="stringliteral">"Bad --gtest_internal_run_death_test flag: "</span></div><div class="line"><a name="l09148"></a><span class="lineno"> 9148</span>  + <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(internal_run_death_test));</div><div class="line"><a name="l09149"></a><span class="lineno"> 9149</span>  }</div><div class="line"><a name="l09150"></a><span class="lineno"> 9150</span> </div><div class="line"><a name="l09151"></a><span class="lineno"> 9151</span> <span class="preprocessor"># else</span></div><div class="line"><a name="l09152"></a><span class="lineno"> 9152</span> </div><div class="line"><a name="l09153"></a><span class="lineno"> 9153</span>  <span class="keywordflow">if</span> (fields.size() != 4</div><div class="line"><a name="l09154"></a><span class="lineno"> 9154</span>  || !ParseNaturalNumber(fields[1], &line)</div><div class="line"><a name="l09155"></a><span class="lineno"> 9155</span>  || !ParseNaturalNumber(fields[2], &index)</div><div class="line"><a name="l09156"></a><span class="lineno"> 9156</span>  || !ParseNaturalNumber(fields[3], &write_fd)) {</div><div class="line"><a name="l09157"></a><span class="lineno"> 9157</span>  DeathTestAbort(<span class="stringliteral">"Bad --gtest_internal_run_death_test flag: "</span></div><div class="line"><a name="l09158"></a><span class="lineno"> 9158</span>  + <a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(internal_run_death_test));</div><div class="line"><a name="l09159"></a><span class="lineno"> 9159</span>  }</div><div class="line"><a name="l09160"></a><span class="lineno"> 9160</span> </div><div class="line"><a name="l09161"></a><span class="lineno"> 9161</span> <span class="preprocessor"># endif // GTEST_OS_WINDOWS</span></div><div class="line"><a name="l09162"></a><span class="lineno"> 9162</span> </div><div class="line"><a name="l09163"></a><span class="lineno"> 9163</span>  <span class="keywordflow">return</span> <span class="keyword">new</span> InternalRunDeathTestFlag(fields[0], line, index, write_fd);</div><div class="line"><a name="l09164"></a><span class="lineno"> 9164</span> }</div><div class="line"><a name="l09165"></a><span class="lineno"> 9165</span> </div><div class="line"><a name="l09166"></a><span class="lineno"> 9166</span> } <span class="comment">// namespace internal</span></div><div class="line"><a name="l09167"></a><span class="lineno"> 9167</span> </div><div class="line"><a name="l09168"></a><span class="lineno"> 9168</span> <span class="preprocessor">#endif // GTEST_HAS_DEATH_TEST</span></div><div class="line"><a name="l09169"></a><span class="lineno"> 9169</span> </div><div class="line"><a name="l09170"></a><span class="lineno"> 9170</span> } <span class="comment">// namespace testing</span></div><div class="line"><a name="l09171"></a><span class="lineno"> 9171</span> <span class="comment">// Copyright 2008, Google Inc.</span></div><div class="line"><a name="l09172"></a><span class="lineno"> 9172</span> <span class="comment">// All rights reserved.</span></div><div class="line"><a name="l09173"></a><span class="lineno"> 9173</span> <span class="comment">//</span></div><div class="line"><a name="l09174"></a><span class="lineno"> 9174</span> <span class="comment">// Redistribution and use in source and binary forms, with or without</span></div><div class="line"><a name="l09175"></a><span class="lineno"> 9175</span> <span class="comment">// modification, are permitted provided that the following conditions are</span></div><div class="line"><a name="l09176"></a><span class="lineno"> 9176</span> <span class="comment">// met:</span></div><div class="line"><a name="l09177"></a><span class="lineno"> 9177</span> <span class="comment">//</span></div><div class="line"><a name="l09178"></a><span class="lineno"> 9178</span> <span class="comment">// * Redistributions of source code must retain the above copyright</span></div><div class="line"><a name="l09179"></a><span class="lineno"> 9179</span> <span class="comment">// notice, this list of conditions and the following disclaimer.</span></div><div class="line"><a name="l09180"></a><span class="lineno"> 9180</span> <span class="comment">// * Redistributions in binary form must reproduce the above</span></div><div class="line"><a name="l09181"></a><span class="lineno"> 9181</span> <span class="comment">// copyright notice, this list of conditions and the following disclaimer</span></div><div class="line"><a name="l09182"></a><span class="lineno"> 9182</span> <span class="comment">// in the documentation and/or other materials provided with the</span></div><div class="line"><a name="l09183"></a><span class="lineno"> 9183</span> <span class="comment">// distribution.</span></div><div class="line"><a name="l09184"></a><span class="lineno"> 9184</span> <span class="comment">// * Neither the name of Google Inc. nor the names of its</span></div><div class="line"><a name="l09185"></a><span class="lineno"> 9185</span> <span class="comment">// contributors may be used to endorse or promote products derived from</span></div><div class="line"><a name="l09186"></a><span class="lineno"> 9186</span> <span class="comment">// this software without specific prior written permission.</span></div><div class="line"><a name="l09187"></a><span class="lineno"> 9187</span> <span class="comment">//</span></div><div class="line"><a name="l09188"></a><span class="lineno"> 9188</span> <span class="comment">// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span></div><div class="line"><a name="l09189"></a><span class="lineno"> 9189</span> <span class="comment">// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</span></div><div class="line"><a name="l09190"></a><span class="lineno"> 9190</span> <span class="comment">// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR</span></div><div class="line"><a name="l09191"></a><span class="lineno"> 9191</span> <span class="comment">// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT</span></div><div class="line"><a name="l09192"></a><span class="lineno"> 9192</span> <span class="comment">// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span></div><div class="line"><a name="l09193"></a><span class="lineno"> 9193</span> <span class="comment">// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</span></div><div class="line"><a name="l09194"></a><span class="lineno"> 9194</span> <span class="comment">// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</span></div><div class="line"><a name="l09195"></a><span class="lineno"> 9195</span> <span class="comment">// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY</span></div><div class="line"><a name="l09196"></a><span class="lineno"> 9196</span> <span class="comment">// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span></div><div class="line"><a name="l09197"></a><span class="lineno"> 9197</span> <span class="comment">// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE</span></div><div class="line"><a name="l09198"></a><span class="lineno"> 9198</span> <span class="comment">// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span></div><div class="line"><a name="l09199"></a><span class="lineno"> 9199</span> </div><div class="line"><a name="l09200"></a><span class="lineno"> 9200</span> </div><div class="line"><a name="l09201"></a><span class="lineno"> 9201</span> <span class="preprocessor">#include <stdlib.h></span></div><div class="line"><a name="l09202"></a><span class="lineno"> 9202</span> </div><div class="line"><a name="l09203"></a><span class="lineno"> 9203</span> <span class="preprocessor">#if GTEST_OS_WINDOWS_MOBILE</span></div><div class="line"><a name="l09204"></a><span class="lineno"> 9204</span> <span class="preprocessor"># include <windows.h></span></div><div class="line"><a name="l09205"></a><span class="lineno"> 9205</span> <span class="preprocessor">#elif GTEST_OS_WINDOWS</span></div><div class="line"><a name="l09206"></a><span class="lineno"> 9206</span> <span class="preprocessor"># include <direct.h></span></div><div class="line"><a name="l09207"></a><span class="lineno"> 9207</span> <span class="preprocessor"># include <io.h></span></div><div class="line"><a name="l09208"></a><span class="lineno"> 9208</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l09209"></a><span class="lineno"> 9209</span> <span class="preprocessor"># include <limits.h></span></div><div class="line"><a name="l09210"></a><span class="lineno"> 9210</span> <span class="preprocessor"># include <climits></span> <span class="comment">// Some Linux distributions define PATH_MAX here.</span></div><div class="line"><a name="l09211"></a><span class="lineno"> 9211</span> <span class="preprocessor">#endif // GTEST_OS_WINDOWS_MOBILE</span></div><div class="line"><a name="l09212"></a><span class="lineno"> 9212</span> </div><div class="line"><a name="l09213"></a><span class="lineno"> 9213</span> </div><div class="line"><a name="l09214"></a><span class="lineno"> 9214</span> <span class="preprocessor">#if GTEST_OS_WINDOWS</span></div><div class="line"><a name="l09215"></a><span class="lineno"> 9215</span> <span class="preprocessor"># define GTEST_PATH_MAX_ _MAX_PATH</span></div><div class="line"><a name="l09216"></a><span class="lineno"> 9216</span> <span class="preprocessor">#elif defined(PATH_MAX)</span></div><div class="line"><a name="l09217"></a><span class="lineno"> 9217</span> <span class="preprocessor"># define GTEST_PATH_MAX_ PATH_MAX</span></div><div class="line"><a name="l09218"></a><span class="lineno"> 9218</span> <span class="preprocessor">#elif defined(_XOPEN_PATH_MAX)</span></div><div class="line"><a name="l09219"></a><span class="lineno"> 9219</span> <span class="preprocessor"># define GTEST_PATH_MAX_ _XOPEN_PATH_MAX</span></div><div class="line"><a name="l09220"></a><span class="lineno"> 9220</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l09221"></a><span class="lineno"><a class="line" href="gtest-all_8cc.html#ad9d445747785a9271a57cf1d392b89ad"> 9221</a></span> <span class="preprocessor"># define GTEST_PATH_MAX_ _POSIX_PATH_MAX</span></div><div class="line"><a name="l09222"></a><span class="lineno"> 9222</span> <span class="preprocessor">#endif // GTEST_OS_WINDOWS</span></div><div class="line"><a name="l09223"></a><span class="lineno"> 9223</span> </div><div class="line"><a name="l09224"></a><span class="lineno"> 9224</span> <span class="keyword">namespace </span><a class="code" href="namespacetesting.html">testing</a> {</div><div class="line"><a name="l09225"></a><span class="lineno"> 9225</span> <span class="keyword">namespace </span>internal {</div><div class="line"><a name="l09226"></a><span class="lineno"> 9226</span> </div><div class="line"><a name="l09227"></a><span class="lineno"> 9227</span> <span class="preprocessor">#if GTEST_OS_WINDOWS</span></div><div class="line"><a name="l09228"></a><span class="lineno"> 9228</span> <span class="comment">// On Windows, '\\' is the standard path separator, but many tools and the</span></div><div class="line"><a name="l09229"></a><span class="lineno"> 9229</span> <span class="comment">// Windows API also accept '/' as an alternate path separator. Unless otherwise</span></div><div class="line"><a name="l09230"></a><span class="lineno"> 9230</span> <span class="comment">// noted, a file path can contain either kind of path separators, or a mixture</span></div><div class="line"><a name="l09231"></a><span class="lineno"> 9231</span> <span class="comment">// of them.</span></div><div class="line"><a name="l09232"></a><span class="lineno"> 9232</span> <span class="keyword">const</span> <span class="keywordtype">char</span> <a class="code" href="namespacetesting_1_1internal.html#afcd71adaa9d1e6df7b282a17fc48125c">kPathSeparator</a> = <span class="charliteral">'\\'</span>;</div><div class="line"><a name="l09233"></a><span class="lineno"> 9233</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kAlternatePathSeparator = <span class="charliteral">'/'</span>;</div><div class="line"><a name="l09234"></a><span class="lineno"> 9234</span> <span class="keyword">const</span> <span class="keywordtype">char</span> kAlternatePathSeparatorString[] = <span class="stringliteral">"/"</span>;</div><div class="line"><a name="l09235"></a><span class="lineno"> 9235</span> <span class="preprocessor"># if GTEST_OS_WINDOWS_MOBILE</span></div><div class="line"><a name="l09236"></a><span class="lineno"> 9236</span> <span class="comment">// Windows CE doesn't have a current directory. You should not use</span></div><div class="line"><a name="l09237"></a><span class="lineno"> 9237</span> <span class="comment">// the current directory in tests on Windows CE, but this at least</span></div><div class="line"><a name="l09238"></a><span class="lineno"> 9238</span> <span class="comment">// provides a reasonable fallback.</span></div><div class="line"><a name="l09239"></a><span class="lineno"> 9239</span> <span class="keyword">const</span> <span class="keywordtype">char</span> <a class="code" href="namespacetesting_1_1internal.html#a23a8e9527d0e544e7df2d64ad549ce3e">kCurrentDirectoryString</a>[] = <span class="stringliteral">"\\"</span>;</div><div class="line"><a name="l09240"></a><span class="lineno"> 9240</span> <span class="comment">// Windows CE doesn't define INVALID_FILE_ATTRIBUTES</span></div><div class="line"><a name="l09241"></a><span class="lineno"> 9241</span> <span class="keyword">const</span> DWORD kInvalidFileAttributes = 0xffffffff;</div><div class="line"><a name="l09242"></a><span class="lineno"> 9242</span> <span class="preprocessor"># else</span></div><div class="line"><a name="l09243"></a><span class="lineno"> 9243</span> <span class="keyword">const</span> <span class="keywordtype">char</span> <a class="code" href="namespacetesting_1_1internal.html#a23a8e9527d0e544e7df2d64ad549ce3e">kCurrentDirectoryString</a>[] = <span class="stringliteral">".\\"</span>;</div><div class="line"><a name="l09244"></a><span class="lineno"> 9244</span> <span class="preprocessor"># endif // GTEST_OS_WINDOWS_MOBILE</span></div><div class="line"><a name="l09245"></a><span class="lineno"> 9245</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l09246"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#afcd71adaa9d1e6df7b282a17fc48125c"> 9246</a></span> <span class="keyword">const</span> <span class="keywordtype">char</span> <a class="code" href="namespacetesting_1_1internal.html#afcd71adaa9d1e6df7b282a17fc48125c">kPathSeparator</a> = <span class="charliteral">'/'</span>;</div><div class="line"><a name="l09247"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#a23a8e9527d0e544e7df2d64ad549ce3e"> 9247</a></span> <span class="keyword">const</span> <span class="keywordtype">char</span> <a class="code" href="namespacetesting_1_1internal.html#a23a8e9527d0e544e7df2d64ad549ce3e">kCurrentDirectoryString</a>[] = <span class="stringliteral">"./"</span>;</div><div class="line"><a name="l09248"></a><span class="lineno"> 9248</span> <span class="preprocessor">#endif // GTEST_OS_WINDOWS</span></div><div class="line"><a name="l09249"></a><span class="lineno"> 9249</span> </div><div class="line"><a name="l09250"></a><span class="lineno"> 9250</span> <span class="comment">// Returns whether the given character is a valid path separator.</span></div><div class="line"><a name="l09251"></a><span class="lineno"> 9251</span> <span class="keyword">static</span> <span class="keywordtype">bool</span> IsPathSeparator(<span class="keywordtype">char</span> c) {</div><div class="line"><a name="l09252"></a><span class="lineno"> 9252</span> <span class="preprocessor">#if GTEST_HAS_ALT_PATH_SEP_</span></div><div class="line"><a name="l09253"></a><span class="lineno"> 9253</span>  <span class="keywordflow">return</span> (c == <a class="code" href="namespacetesting_1_1internal.html#afcd71adaa9d1e6df7b282a17fc48125c">kPathSeparator</a>) || (c == kAlternatePathSeparator);</div><div class="line"><a name="l09254"></a><span class="lineno"> 9254</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l09255"></a><span class="lineno"> 9255</span>  <span class="keywordflow">return</span> c == <a class="code" href="namespacetesting_1_1internal.html#afcd71adaa9d1e6df7b282a17fc48125c">kPathSeparator</a>;</div><div class="line"><a name="l09256"></a><span class="lineno"> 9256</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l09257"></a><span class="lineno"> 9257</span> }</div><div class="line"><a name="l09258"></a><span class="lineno"> 9258</span> </div><div class="line"><a name="l09259"></a><span class="lineno"> 9259</span> <span class="comment">// Returns the current working directory, or "" if unsuccessful.</span></div><div class="line"><a name="l09260"></a><span class="lineno"> 9260</span> FilePath FilePath::GetCurrentDir() {</div><div class="line"><a name="l09261"></a><span class="lineno"> 9261</span> <span class="preprocessor">#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT</span></div><div class="line"><a name="l09262"></a><span class="lineno"> 9262</span>  <span class="comment">// Windows CE doesn't have a current directory, so we just return</span></div><div class="line"><a name="l09263"></a><span class="lineno"> 9263</span>  <span class="comment">// something reasonable.</span></div><div class="line"><a name="l09264"></a><span class="lineno"> 9264</span>  <span class="keywordflow">return</span> FilePath(<a class="code" href="namespacetesting_1_1internal.html#a23a8e9527d0e544e7df2d64ad549ce3e">kCurrentDirectoryString</a>);</div><div class="line"><a name="l09265"></a><span class="lineno"> 9265</span> <span class="preprocessor">#elif GTEST_OS_WINDOWS</span></div><div class="line"><a name="l09266"></a><span class="lineno"> 9266</span>  <span class="keywordtype">char</span> cwd[<a class="code" href="gtest-all_8cc.html#ad9d445747785a9271a57cf1d392b89ad">GTEST_PATH_MAX_</a> + 1] = { <span class="charliteral">'\0'</span> };</div><div class="line"><a name="l09267"></a><span class="lineno"> 9267</span>  <span class="keywordflow">return</span> FilePath(_getcwd(cwd, <span class="keyword">sizeof</span>(cwd)) == <span class="keyword">nullptr</span> ? <span class="stringliteral">""</span> : cwd);</div><div class="line"><a name="l09268"></a><span class="lineno"> 9268</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l09269"></a><span class="lineno"> 9269</span>  <span class="keywordtype">char</span> cwd[<a class="code" href="gtest-all_8cc.html#ad9d445747785a9271a57cf1d392b89ad">GTEST_PATH_MAX_</a> + 1] = { <span class="charliteral">'\0'</span> };</div><div class="line"><a name="l09270"></a><span class="lineno"> 9270</span>  <span class="keywordtype">char</span>* result = getcwd(cwd, <span class="keyword">sizeof</span>(cwd));</div><div class="line"><a name="l09271"></a><span class="lineno"> 9271</span> <span class="preprocessor"># if GTEST_OS_NACL</span></div><div class="line"><a name="l09272"></a><span class="lineno"> 9272</span>  <span class="comment">// getcwd will likely fail in NaCl due to the sandbox, so return something</span></div><div class="line"><a name="l09273"></a><span class="lineno"> 9273</span>  <span class="comment">// reasonable. The user may have provided a shim implementation for getcwd,</span></div><div class="line"><a name="l09274"></a><span class="lineno"> 9274</span>  <span class="comment">// however, so fallback only when failure is detected.</span></div><div class="line"><a name="l09275"></a><span class="lineno"> 9275</span>  <span class="keywordflow">return</span> FilePath(result == <span class="keyword">nullptr</span> ? <a class="code" href="namespacetesting_1_1internal.html#a23a8e9527d0e544e7df2d64ad549ce3e">kCurrentDirectoryString</a> : cwd);</div><div class="line"><a name="l09276"></a><span class="lineno"> 9276</span> <span class="preprocessor"># endif // GTEST_OS_NACL</span></div><div class="line"><a name="l09277"></a><span class="lineno"> 9277</span>  <span class="keywordflow">return</span> FilePath(result == <span class="keyword">nullptr</span> ? <span class="stringliteral">""</span> : cwd);</div><div class="line"><a name="l09278"></a><span class="lineno"> 9278</span> <span class="preprocessor">#endif // GTEST_OS_WINDOWS_MOBILE</span></div><div class="line"><a name="l09279"></a><span class="lineno"> 9279</span> }</div><div class="line"><a name="l09280"></a><span class="lineno"> 9280</span> </div><div class="line"><a name="l09281"></a><span class="lineno"> 9281</span> <span class="comment">// Returns a copy of the FilePath with the case-insensitive extension removed.</span></div><div class="line"><a name="l09282"></a><span class="lineno"> 9282</span> <span class="comment">// Example: FilePath("dir/file.exe").RemoveExtension("EXE") returns</span></div><div class="line"><a name="l09283"></a><span class="lineno"> 9283</span> <span class="comment">// FilePath("dir/file"). If a case-insensitive extension is not</span></div><div class="line"><a name="l09284"></a><span class="lineno"> 9284</span> <span class="comment">// found, returns a copy of the original FilePath.</span></div><div class="line"><a name="l09285"></a><span class="lineno"> 9285</span> FilePath FilePath::RemoveExtension(<span class="keyword">const</span> <span class="keywordtype">char</span>* extension)<span class="keyword"> const </span>{</div><div class="line"><a name="l09286"></a><span class="lineno"> 9286</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> dot_extension = <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(<span class="stringliteral">"."</span>) + extension;</div><div class="line"><a name="l09287"></a><span class="lineno"> 9287</span>  <span class="keywordflow">if</span> (String::EndsWithCaseInsensitive(pathname_, dot_extension)) {</div><div class="line"><a name="l09288"></a><span class="lineno"> 9288</span>  <span class="keywordflow">return</span> FilePath(pathname_.substr(</div><div class="line"><a name="l09289"></a><span class="lineno"> 9289</span>  0, pathname_.length() - dot_extension.length()));</div><div class="line"><a name="l09290"></a><span class="lineno"> 9290</span>  }</div><div class="line"><a name="l09291"></a><span class="lineno"> 9291</span>  <span class="keywordflow">return</span> *<span class="keyword">this</span>;</div><div class="line"><a name="l09292"></a><span class="lineno"> 9292</span> }</div><div class="line"><a name="l09293"></a><span class="lineno"> 9293</span> </div><div class="line"><a name="l09294"></a><span class="lineno"> 9294</span> <span class="comment">// Returns a pointer to the last occurrence of a valid path separator in</span></div><div class="line"><a name="l09295"></a><span class="lineno"> 9295</span> <span class="comment">// the FilePath. On Windows, for example, both '/' and '\' are valid path</span></div><div class="line"><a name="l09296"></a><span class="lineno"> 9296</span> <span class="comment">// separators. Returns NULL if no path separator was found.</span></div><div class="line"><a name="l09297"></a><span class="lineno"> 9297</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* FilePath::FindLastPathSeparator()<span class="keyword"> const </span>{</div><div class="line"><a name="l09298"></a><span class="lineno"> 9298</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> last_sep = strrchr(c_str(), <a class="code" href="namespacetesting_1_1internal.html#afcd71adaa9d1e6df7b282a17fc48125c">kPathSeparator</a>);</div><div class="line"><a name="l09299"></a><span class="lineno"> 9299</span> <span class="preprocessor">#if GTEST_HAS_ALT_PATH_SEP_</span></div><div class="line"><a name="l09300"></a><span class="lineno"> 9300</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> last_alt_sep = strrchr(c_str(), kAlternatePathSeparator);</div><div class="line"><a name="l09301"></a><span class="lineno"> 9301</span>  <span class="comment">// Comparing two pointers of which only one is NULL is undefined.</span></div><div class="line"><a name="l09302"></a><span class="lineno"> 9302</span>  <span class="keywordflow">if</span> (last_alt_sep != <span class="keyword">nullptr</span> &&</div><div class="line"><a name="l09303"></a><span class="lineno"> 9303</span>  (last_sep == <span class="keyword">nullptr</span> || last_alt_sep > last_sep)) {</div><div class="line"><a name="l09304"></a><span class="lineno"> 9304</span>  <span class="keywordflow">return</span> last_alt_sep;</div><div class="line"><a name="l09305"></a><span class="lineno"> 9305</span>  }</div><div class="line"><a name="l09306"></a><span class="lineno"> 9306</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l09307"></a><span class="lineno"> 9307</span>  <span class="keywordflow">return</span> last_sep;</div><div class="line"><a name="l09308"></a><span class="lineno"> 9308</span> }</div><div class="line"><a name="l09309"></a><span class="lineno"> 9309</span> </div><div class="line"><a name="l09310"></a><span class="lineno"> 9310</span> <span class="comment">// Returns a copy of the FilePath with the directory part removed.</span></div><div class="line"><a name="l09311"></a><span class="lineno"> 9311</span> <span class="comment">// Example: FilePath("path/to/file").RemoveDirectoryName() returns</span></div><div class="line"><a name="l09312"></a><span class="lineno"> 9312</span> <span class="comment">// FilePath("file"). If there is no directory part ("just_a_file"), it returns</span></div><div class="line"><a name="l09313"></a><span class="lineno"> 9313</span> <span class="comment">// the FilePath unmodified. If there is no file part ("just_a_dir/") it</span></div><div class="line"><a name="l09314"></a><span class="lineno"> 9314</span> <span class="comment">// returns an empty FilePath ("").</span></div><div class="line"><a name="l09315"></a><span class="lineno"> 9315</span> <span class="comment">// On Windows platform, '\' is the path separator, otherwise it is '/'.</span></div><div class="line"><a name="l09316"></a><span class="lineno"> 9316</span> FilePath FilePath::RemoveDirectoryName()<span class="keyword"> const </span>{</div><div class="line"><a name="l09317"></a><span class="lineno"> 9317</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> last_sep = FindLastPathSeparator();</div><div class="line"><a name="l09318"></a><span class="lineno"> 9318</span>  <span class="keywordflow">return</span> last_sep ? FilePath(last_sep + 1) : *this;</div><div class="line"><a name="l09319"></a><span class="lineno"> 9319</span> }</div><div class="line"><a name="l09320"></a><span class="lineno"> 9320</span> </div><div class="line"><a name="l09321"></a><span class="lineno"> 9321</span> <span class="comment">// RemoveFileName returns the directory path with the filename removed.</span></div><div class="line"><a name="l09322"></a><span class="lineno"> 9322</span> <span class="comment">// Example: FilePath("path/to/file").RemoveFileName() returns "path/to/".</span></div><div class="line"><a name="l09323"></a><span class="lineno"> 9323</span> <span class="comment">// If the FilePath is "a_file" or "/a_file", RemoveFileName returns</span></div><div class="line"><a name="l09324"></a><span class="lineno"> 9324</span> <span class="comment">// FilePath("./") or, on Windows, FilePath(".\\"). If the filepath does</span></div><div class="line"><a name="l09325"></a><span class="lineno"> 9325</span> <span class="comment">// not have a file, like "just/a/dir/", it returns the FilePath unmodified.</span></div><div class="line"><a name="l09326"></a><span class="lineno"> 9326</span> <span class="comment">// On Windows platform, '\' is the path separator, otherwise it is '/'.</span></div><div class="line"><a name="l09327"></a><span class="lineno"> 9327</span> FilePath FilePath::RemoveFileName()<span class="keyword"> const </span>{</div><div class="line"><a name="l09328"></a><span class="lineno"> 9328</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> last_sep = FindLastPathSeparator();</div><div class="line"><a name="l09329"></a><span class="lineno"> 9329</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> dir;</div><div class="line"><a name="l09330"></a><span class="lineno"> 9330</span>  <span class="keywordflow">if</span> (last_sep) {</div><div class="line"><a name="l09331"></a><span class="lineno"> 9331</span>  dir = <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(c_str(), last_sep + 1 - c_str());</div><div class="line"><a name="l09332"></a><span class="lineno"> 9332</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l09333"></a><span class="lineno"> 9333</span>  dir = <a class="code" href="namespacetesting_1_1internal.html#a23a8e9527d0e544e7df2d64ad549ce3e">kCurrentDirectoryString</a>;</div><div class="line"><a name="l09334"></a><span class="lineno"> 9334</span>  }</div><div class="line"><a name="l09335"></a><span class="lineno"> 9335</span>  <span class="keywordflow">return</span> FilePath(dir);</div><div class="line"><a name="l09336"></a><span class="lineno"> 9336</span> }</div><div class="line"><a name="l09337"></a><span class="lineno"> 9337</span> </div><div class="line"><a name="l09338"></a><span class="lineno"> 9338</span> <span class="comment">// Helper functions for naming files in a directory for xml output.</span></div><div class="line"><a name="l09339"></a><span class="lineno"> 9339</span> </div><div class="line"><a name="l09340"></a><span class="lineno"> 9340</span> <span class="comment">// Given directory = "dir", base_name = "test", number = 0,</span></div><div class="line"><a name="l09341"></a><span class="lineno"> 9341</span> <span class="comment">// extension = "xml", returns "dir/test.xml". If number is greater</span></div><div class="line"><a name="l09342"></a><span class="lineno"> 9342</span> <span class="comment">// than zero (e.g., 12), returns "dir/test_12.xml".</span></div><div class="line"><a name="l09343"></a><span class="lineno"> 9343</span> <span class="comment">// On Windows platform, uses \ as the separator rather than /.</span></div><div class="line"><a name="l09344"></a><span class="lineno"> 9344</span> FilePath FilePath::MakeFileName(<span class="keyword">const</span> FilePath& directory,</div><div class="line"><a name="l09345"></a><span class="lineno"> 9345</span>  <span class="keyword">const</span> FilePath& base_name,</div><div class="line"><a name="l09346"></a><span class="lineno"> 9346</span>  <span class="keywordtype">int</span> number,</div><div class="line"><a name="l09347"></a><span class="lineno"> 9347</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* extension) {</div><div class="line"><a name="l09348"></a><span class="lineno"> 9348</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> file;</div><div class="line"><a name="l09349"></a><span class="lineno"> 9349</span>  <span class="keywordflow">if</span> (number == 0) {</div><div class="line"><a name="l09350"></a><span class="lineno"> 9350</span>  file = base_name.string() + <span class="stringliteral">"."</span> + extension;</div><div class="line"><a name="l09351"></a><span class="lineno"> 9351</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l09352"></a><span class="lineno"> 9352</span>  file = base_name.string() + <span class="stringliteral">"_"</span> + <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(number)</div><div class="line"><a name="l09353"></a><span class="lineno"> 9353</span>  + <span class="stringliteral">"."</span> + extension;</div><div class="line"><a name="l09354"></a><span class="lineno"> 9354</span>  }</div><div class="line"><a name="l09355"></a><span class="lineno"> 9355</span>  <span class="keywordflow">return</span> ConcatPaths(directory, FilePath(file));</div><div class="line"><a name="l09356"></a><span class="lineno"> 9356</span> }</div><div class="line"><a name="l09357"></a><span class="lineno"> 9357</span> </div><div class="line"><a name="l09358"></a><span class="lineno"> 9358</span> <span class="comment">// Given directory = "dir", relative_path = "test.xml", returns "dir/test.xml".</span></div><div class="line"><a name="l09359"></a><span class="lineno"> 9359</span> <span class="comment">// On Windows, uses \ as the separator rather than /.</span></div><div class="line"><a name="l09360"></a><span class="lineno"> 9360</span> FilePath FilePath::ConcatPaths(<span class="keyword">const</span> FilePath& directory,</div><div class="line"><a name="l09361"></a><span class="lineno"> 9361</span>  <span class="keyword">const</span> FilePath& relative_path) {</div><div class="line"><a name="l09362"></a><span class="lineno"> 9362</span>  <span class="keywordflow">if</span> (directory.IsEmpty())</div><div class="line"><a name="l09363"></a><span class="lineno"> 9363</span>  <span class="keywordflow">return</span> relative_path;</div><div class="line"><a name="l09364"></a><span class="lineno"> 9364</span>  <span class="keyword">const</span> FilePath dir(directory.RemoveTrailingPathSeparator());</div><div class="line"><a name="l09365"></a><span class="lineno"> 9365</span>  <span class="keywordflow">return</span> FilePath(dir.string() + <a class="code" href="namespacetesting_1_1internal.html#afcd71adaa9d1e6df7b282a17fc48125c">kPathSeparator</a> + relative_path.string());</div><div class="line"><a name="l09366"></a><span class="lineno"> 9366</span> }</div><div class="line"><a name="l09367"></a><span class="lineno"> 9367</span> </div><div class="line"><a name="l09368"></a><span class="lineno"> 9368</span> <span class="comment">// Returns true if pathname describes something findable in the file-system,</span></div><div class="line"><a name="l09369"></a><span class="lineno"> 9369</span> <span class="comment">// either a file, directory, or whatever.</span></div><div class="line"><a name="l09370"></a><span class="lineno"> 9370</span> <span class="keywordtype">bool</span> FilePath::FileOrDirectoryExists()<span class="keyword"> const </span>{</div><div class="line"><a name="l09371"></a><span class="lineno"> 9371</span> <span class="preprocessor">#if GTEST_OS_WINDOWS_MOBILE</span></div><div class="line"><a name="l09372"></a><span class="lineno"> 9372</span>  LPCWSTR unicode = String::AnsiToUtf16(pathname_.c_str());</div><div class="line"><a name="l09373"></a><span class="lineno"> 9373</span>  <span class="keyword">const</span> DWORD attributes = GetFileAttributes(unicode);</div><div class="line"><a name="l09374"></a><span class="lineno"> 9374</span>  <span class="keyword">delete</span> [] unicode;</div><div class="line"><a name="l09375"></a><span class="lineno"> 9375</span>  <span class="keywordflow">return</span> attributes != kInvalidFileAttributes;</div><div class="line"><a name="l09376"></a><span class="lineno"> 9376</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l09377"></a><span class="lineno"> 9377</span>  <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a8eb9f08d3af29941c2d2a964cfff3ecb">posix::StatStruct</a> file_stat;</div><div class="line"><a name="l09378"></a><span class="lineno"> 9378</span>  <span class="keywordflow">return</span> <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a2b87b7ff647a128614daf50667eb9304">posix::Stat</a>(pathname_.c_str(), &file_stat) == 0;</div><div class="line"><a name="l09379"></a><span class="lineno"> 9379</span> <span class="preprocessor">#endif // GTEST_OS_WINDOWS_MOBILE</span></div><div class="line"><a name="l09380"></a><span class="lineno"> 9380</span> }</div><div class="line"><a name="l09381"></a><span class="lineno"> 9381</span> </div><div class="line"><a name="l09382"></a><span class="lineno"> 9382</span> <span class="comment">// Returns true if pathname describes a directory in the file-system</span></div><div class="line"><a name="l09383"></a><span class="lineno"> 9383</span> <span class="comment">// that exists.</span></div><div class="line"><a name="l09384"></a><span class="lineno"> 9384</span> <span class="keywordtype">bool</span> FilePath::DirectoryExists()<span class="keyword"> const </span>{</div><div class="line"><a name="l09385"></a><span class="lineno"> 9385</span>  <span class="keywordtype">bool</span> result = <span class="keyword">false</span>;</div><div class="line"><a name="l09386"></a><span class="lineno"> 9386</span> <span class="preprocessor">#if GTEST_OS_WINDOWS</span></div><div class="line"><a name="l09387"></a><span class="lineno"> 9387</span>  <span class="comment">// Don't strip off trailing separator if path is a root directory on</span></div><div class="line"><a name="l09388"></a><span class="lineno"> 9388</span>  <span class="comment">// Windows (like "C:\\").</span></div><div class="line"><a name="l09389"></a><span class="lineno"> 9389</span>  <span class="keyword">const</span> FilePath& path(IsRootDirectory() ? *<span class="keyword">this</span> :</div><div class="line"><a name="l09390"></a><span class="lineno"> 9390</span>  RemoveTrailingPathSeparator());</div><div class="line"><a name="l09391"></a><span class="lineno"> 9391</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l09392"></a><span class="lineno"> 9392</span>  <span class="keyword">const</span> FilePath& path(*<span class="keyword">this</span>);</div><div class="line"><a name="l09393"></a><span class="lineno"> 9393</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l09394"></a><span class="lineno"> 9394</span> </div><div class="line"><a name="l09395"></a><span class="lineno"> 9395</span> <span class="preprocessor">#if GTEST_OS_WINDOWS_MOBILE</span></div><div class="line"><a name="l09396"></a><span class="lineno"> 9396</span>  LPCWSTR unicode = String::AnsiToUtf16(path.c_str());</div><div class="line"><a name="l09397"></a><span class="lineno"> 9397</span>  <span class="keyword">const</span> DWORD attributes = GetFileAttributes(unicode);</div><div class="line"><a name="l09398"></a><span class="lineno"> 9398</span>  <span class="keyword">delete</span> [] unicode;</div><div class="line"><a name="l09399"></a><span class="lineno"> 9399</span>  <span class="keywordflow">if</span> ((attributes != kInvalidFileAttributes) &&</div><div class="line"><a name="l09400"></a><span class="lineno"> 9400</span>  (attributes & FILE_ATTRIBUTE_DIRECTORY)) {</div><div class="line"><a name="l09401"></a><span class="lineno"> 9401</span>  result = <span class="keyword">true</span>;</div><div class="line"><a name="l09402"></a><span class="lineno"> 9402</span>  }</div><div class="line"><a name="l09403"></a><span class="lineno"> 9403</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l09404"></a><span class="lineno"> 9404</span>  <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a8eb9f08d3af29941c2d2a964cfff3ecb">posix::StatStruct</a> file_stat;</div><div class="line"><a name="l09405"></a><span class="lineno"> 9405</span>  result = <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a2b87b7ff647a128614daf50667eb9304">posix::Stat</a>(path.c_str(), &file_stat) == 0 &&</div><div class="line"><a name="l09406"></a><span class="lineno"> 9406</span>  <a class="code" href="namespacetesting_1_1internal_1_1posix.html#af0d04ed5baeed28353fa38742748a421">posix::IsDir</a>(file_stat);</div><div class="line"><a name="l09407"></a><span class="lineno"> 9407</span> <span class="preprocessor">#endif // GTEST_OS_WINDOWS_MOBILE</span></div><div class="line"><a name="l09408"></a><span class="lineno"> 9408</span> </div><div class="line"><a name="l09409"></a><span class="lineno"> 9409</span>  <span class="keywordflow">return</span> result;</div><div class="line"><a name="l09410"></a><span class="lineno"> 9410</span> }</div><div class="line"><a name="l09411"></a><span class="lineno"> 9411</span> </div><div class="line"><a name="l09412"></a><span class="lineno"> 9412</span> <span class="comment">// Returns true if pathname describes a root directory. (Windows has one</span></div><div class="line"><a name="l09413"></a><span class="lineno"> 9413</span> <span class="comment">// root directory per disk drive.)</span></div><div class="line"><a name="l09414"></a><span class="lineno"> 9414</span> <span class="keywordtype">bool</span> FilePath::IsRootDirectory()<span class="keyword"> const </span>{</div><div class="line"><a name="l09415"></a><span class="lineno"> 9415</span> <span class="preprocessor">#if GTEST_OS_WINDOWS</span></div><div class="line"><a name="l09416"></a><span class="lineno"> 9416</span>  <span class="keywordflow">return</span> pathname_.length() == 3 && IsAbsolutePath();</div><div class="line"><a name="l09417"></a><span class="lineno"> 9417</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l09418"></a><span class="lineno"> 9418</span>  <span class="keywordflow">return</span> pathname_.length() == 1 && IsPathSeparator(pathname_.c_str()[0]);</div><div class="line"><a name="l09419"></a><span class="lineno"> 9419</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l09420"></a><span class="lineno"> 9420</span> }</div><div class="line"><a name="l09421"></a><span class="lineno"> 9421</span> </div><div class="line"><a name="l09422"></a><span class="lineno"> 9422</span> <span class="comment">// Returns true if pathname describes an absolute path.</span></div><div class="line"><a name="l09423"></a><span class="lineno"> 9423</span> <span class="keywordtype">bool</span> FilePath::IsAbsolutePath()<span class="keyword"> const </span>{</div><div class="line"><a name="l09424"></a><span class="lineno"> 9424</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> name = pathname_.c_str();</div><div class="line"><a name="l09425"></a><span class="lineno"> 9425</span> <span class="preprocessor">#if GTEST_OS_WINDOWS</span></div><div class="line"><a name="l09426"></a><span class="lineno"> 9426</span>  <span class="keywordflow">return</span> pathname_.length() >= 3 &&</div><div class="line"><a name="l09427"></a><span class="lineno"> 9427</span>  ((name[0] >= <span class="charliteral">'a'</span> && name[0] <= <span class="charliteral">'z'</span>) ||</div><div class="line"><a name="l09428"></a><span class="lineno"> 9428</span>  (name[0] >= <span class="charliteral">'A'</span> && name[0] <= <span class="charliteral">'Z'</span>)) &&</div><div class="line"><a name="l09429"></a><span class="lineno"> 9429</span>  name[1] == <span class="charliteral">':'</span> &&</div><div class="line"><a name="l09430"></a><span class="lineno"> 9430</span>  IsPathSeparator(name[2]);</div><div class="line"><a name="l09431"></a><span class="lineno"> 9431</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l09432"></a><span class="lineno"> 9432</span>  <span class="keywordflow">return</span> IsPathSeparator(name[0]);</div><div class="line"><a name="l09433"></a><span class="lineno"> 9433</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l09434"></a><span class="lineno"> 9434</span> }</div><div class="line"><a name="l09435"></a><span class="lineno"> 9435</span> </div><div class="line"><a name="l09436"></a><span class="lineno"> 9436</span> <span class="comment">// Returns a pathname for a file that does not currently exist. The pathname</span></div><div class="line"><a name="l09437"></a><span class="lineno"> 9437</span> <span class="comment">// will be directory/base_name.extension or</span></div><div class="line"><a name="l09438"></a><span class="lineno"> 9438</span> <span class="comment">// directory/base_name_<number>.extension if directory/base_name.extension</span></div><div class="line"><a name="l09439"></a><span class="lineno"> 9439</span> <span class="comment">// already exists. The number will be incremented until a pathname is found</span></div><div class="line"><a name="l09440"></a><span class="lineno"> 9440</span> <span class="comment">// that does not already exist.</span></div><div class="line"><a name="l09441"></a><span class="lineno"> 9441</span> <span class="comment">// Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'.</span></div><div class="line"><a name="l09442"></a><span class="lineno"> 9442</span> <span class="comment">// There could be a race condition if two or more processes are calling this</span></div><div class="line"><a name="l09443"></a><span class="lineno"> 9443</span> <span class="comment">// function at the same time -- they could both pick the same filename.</span></div><div class="line"><a name="l09444"></a><span class="lineno"> 9444</span> FilePath FilePath::GenerateUniqueFileName(<span class="keyword">const</span> FilePath& directory,</div><div class="line"><a name="l09445"></a><span class="lineno"> 9445</span>  <span class="keyword">const</span> FilePath& base_name,</div><div class="line"><a name="l09446"></a><span class="lineno"> 9446</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* extension) {</div><div class="line"><a name="l09447"></a><span class="lineno"> 9447</span>  FilePath full_pathname;</div><div class="line"><a name="l09448"></a><span class="lineno"> 9448</span>  <span class="keywordtype">int</span> number = 0;</div><div class="line"><a name="l09449"></a><span class="lineno"> 9449</span>  <span class="keywordflow">do</span> {</div><div class="line"><a name="l09450"></a><span class="lineno"> 9450</span>  full_pathname.Set(MakeFileName(directory, base_name, number++, extension));</div><div class="line"><a name="l09451"></a><span class="lineno"> 9451</span>  } <span class="keywordflow">while</span> (full_pathname.FileOrDirectoryExists());</div><div class="line"><a name="l09452"></a><span class="lineno"> 9452</span>  <span class="keywordflow">return</span> full_pathname;</div><div class="line"><a name="l09453"></a><span class="lineno"> 9453</span> }</div><div class="line"><a name="l09454"></a><span class="lineno"> 9454</span> </div><div class="line"><a name="l09455"></a><span class="lineno"> 9455</span> <span class="comment">// Returns true if FilePath ends with a path separator, which indicates that</span></div><div class="line"><a name="l09456"></a><span class="lineno"> 9456</span> <span class="comment">// it is intended to represent a directory. Returns false otherwise.</span></div><div class="line"><a name="l09457"></a><span class="lineno"> 9457</span> <span class="comment">// This does NOT check that a directory (or file) actually exists.</span></div><div class="line"><a name="l09458"></a><span class="lineno"> 9458</span> <span class="keywordtype">bool</span> FilePath::IsDirectory()<span class="keyword"> const </span>{</div><div class="line"><a name="l09459"></a><span class="lineno"> 9459</span>  <span class="keywordflow">return</span> !pathname_.empty() &&</div><div class="line"><a name="l09460"></a><span class="lineno"> 9460</span>  IsPathSeparator(pathname_.c_str()[pathname_.length() - 1]);</div><div class="line"><a name="l09461"></a><span class="lineno"> 9461</span> }</div><div class="line"><a name="l09462"></a><span class="lineno"> 9462</span> </div><div class="line"><a name="l09463"></a><span class="lineno"> 9463</span> <span class="comment">// Create directories so that path exists. Returns true if successful or if</span></div><div class="line"><a name="l09464"></a><span class="lineno"> 9464</span> <span class="comment">// the directories already exist; returns false if unable to create directories</span></div><div class="line"><a name="l09465"></a><span class="lineno"> 9465</span> <span class="comment">// for any reason.</span></div><div class="line"><a name="l09466"></a><span class="lineno"> 9466</span> <span class="keywordtype">bool</span> FilePath::CreateDirectoriesRecursively()<span class="keyword"> const </span>{</div><div class="line"><a name="l09467"></a><span class="lineno"> 9467</span>  <span class="keywordflow">if</span> (!this->IsDirectory()) {</div><div class="line"><a name="l09468"></a><span class="lineno"> 9468</span>  <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l09469"></a><span class="lineno"> 9469</span>  }</div><div class="line"><a name="l09470"></a><span class="lineno"> 9470</span> </div><div class="line"><a name="l09471"></a><span class="lineno"> 9471</span>  <span class="keywordflow">if</span> (pathname_.length() == 0 || this->DirectoryExists()) {</div><div class="line"><a name="l09472"></a><span class="lineno"> 9472</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l09473"></a><span class="lineno"> 9473</span>  }</div><div class="line"><a name="l09474"></a><span class="lineno"> 9474</span> </div><div class="line"><a name="l09475"></a><span class="lineno"> 9475</span>  <span class="keyword">const</span> FilePath parent(this->RemoveTrailingPathSeparator().RemoveFileName());</div><div class="line"><a name="l09476"></a><span class="lineno"> 9476</span>  <span class="keywordflow">return</span> parent.CreateDirectoriesRecursively() && this->CreateFolder();</div><div class="line"><a name="l09477"></a><span class="lineno"> 9477</span> }</div><div class="line"><a name="l09478"></a><span class="lineno"> 9478</span> </div><div class="line"><a name="l09479"></a><span class="lineno"> 9479</span> <span class="comment">// Create the directory so that path exists. Returns true if successful or</span></div><div class="line"><a name="l09480"></a><span class="lineno"> 9480</span> <span class="comment">// if the directory already exists; returns false if unable to create the</span></div><div class="line"><a name="l09481"></a><span class="lineno"> 9481</span> <span class="comment">// directory for any reason, including if the parent directory does not</span></div><div class="line"><a name="l09482"></a><span class="lineno"> 9482</span> <span class="comment">// exist. Not named "CreateDirectory" because that's a macro on Windows.</span></div><div class="line"><a name="l09483"></a><span class="lineno"> 9483</span> <span class="keywordtype">bool</span> FilePath::CreateFolder()<span class="keyword"> const </span>{</div><div class="line"><a name="l09484"></a><span class="lineno"> 9484</span> <span class="preprocessor">#if GTEST_OS_WINDOWS_MOBILE</span></div><div class="line"><a name="l09485"></a><span class="lineno"> 9485</span>  FilePath removed_sep(this->RemoveTrailingPathSeparator());</div><div class="line"><a name="l09486"></a><span class="lineno"> 9486</span>  LPCWSTR unicode = String::AnsiToUtf16(removed_sep.c_str());</div><div class="line"><a name="l09487"></a><span class="lineno"> 9487</span>  <span class="keywordtype">int</span> result = CreateDirectory(unicode, <span class="keyword">nullptr</span>) ? 0 : -1;</div><div class="line"><a name="l09488"></a><span class="lineno"> 9488</span>  <span class="keyword">delete</span> [] unicode;</div><div class="line"><a name="l09489"></a><span class="lineno"> 9489</span> <span class="preprocessor">#elif GTEST_OS_WINDOWS</span></div><div class="line"><a name="l09490"></a><span class="lineno"> 9490</span>  <span class="keywordtype">int</span> result = _mkdir(pathname_.c_str());</div><div class="line"><a name="l09491"></a><span class="lineno"> 9491</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l09492"></a><span class="lineno"> 9492</span>  <span class="keywordtype">int</span> result = mkdir(pathname_.c_str(), 0777);</div><div class="line"><a name="l09493"></a><span class="lineno"> 9493</span> <span class="preprocessor">#endif // GTEST_OS_WINDOWS_MOBILE</span></div><div class="line"><a name="l09494"></a><span class="lineno"> 9494</span> </div><div class="line"><a name="l09495"></a><span class="lineno"> 9495</span>  <span class="keywordflow">if</span> (result == -1) {</div><div class="line"><a name="l09496"></a><span class="lineno"> 9496</span>  <span class="keywordflow">return</span> this->DirectoryExists(); <span class="comment">// An error is OK if the directory exists.</span></div><div class="line"><a name="l09497"></a><span class="lineno"> 9497</span>  }</div><div class="line"><a name="l09498"></a><span class="lineno"> 9498</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>; <span class="comment">// No error.</span></div><div class="line"><a name="l09499"></a><span class="lineno"> 9499</span> }</div><div class="line"><a name="l09500"></a><span class="lineno"> 9500</span> </div><div class="line"><a name="l09501"></a><span class="lineno"> 9501</span> <span class="comment">// If input name has a trailing separator character, remove it and return the</span></div><div class="line"><a name="l09502"></a><span class="lineno"> 9502</span> <span class="comment">// name, otherwise return the name string unmodified.</span></div><div class="line"><a name="l09503"></a><span class="lineno"> 9503</span> <span class="comment">// On Windows platform, uses \ as the separator, other platforms use /.</span></div><div class="line"><a name="l09504"></a><span class="lineno"> 9504</span> FilePath FilePath::RemoveTrailingPathSeparator()<span class="keyword"> const </span>{</div><div class="line"><a name="l09505"></a><span class="lineno"> 9505</span>  <span class="keywordflow">return</span> IsDirectory()</div><div class="line"><a name="l09506"></a><span class="lineno"> 9506</span>  ? FilePath(pathname_.substr(0, pathname_.length() - 1))</div><div class="line"><a name="l09507"></a><span class="lineno"> 9507</span>  : *this;</div><div class="line"><a name="l09508"></a><span class="lineno"> 9508</span> }</div><div class="line"><a name="l09509"></a><span class="lineno"> 9509</span> </div><div class="line"><a name="l09510"></a><span class="lineno"> 9510</span> <span class="comment">// Removes any redundant separators that might be in the pathname.</span></div><div class="line"><a name="l09511"></a><span class="lineno"> 9511</span> <span class="comment">// For example, "bar///foo" becomes "bar/foo". Does not eliminate other</span></div><div class="line"><a name="l09512"></a><span class="lineno"> 9512</span> <span class="comment">// redundancies that might be in a pathname involving "." or "..".</span></div><div class="line"><a name="l09513"></a><span class="lineno"> 9513</span> <span class="keywordtype">void</span> FilePath::Normalize() {</div><div class="line"><a name="l09514"></a><span class="lineno"> 9514</span>  <span class="keywordflow">if</span> (pathname_.c_str() == <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l09515"></a><span class="lineno"> 9515</span>  pathname_ = <span class="stringliteral">""</span>;</div><div class="line"><a name="l09516"></a><span class="lineno"> 9516</span>  <span class="keywordflow">return</span>;</div><div class="line"><a name="l09517"></a><span class="lineno"> 9517</span>  }</div><div class="line"><a name="l09518"></a><span class="lineno"> 9518</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* src = pathname_.c_str();</div><div class="line"><a name="l09519"></a><span class="lineno"> 9519</span>  <span class="keywordtype">char</span>* <span class="keyword">const</span> dest = <span class="keyword">new</span> <span class="keywordtype">char</span>[pathname_.length() + 1];</div><div class="line"><a name="l09520"></a><span class="lineno"> 9520</span>  <span class="keywordtype">char</span>* dest_ptr = dest;</div><div class="line"><a name="l09521"></a><span class="lineno"> 9521</span>  memset(dest_ptr, 0, pathname_.length() + 1);</div><div class="line"><a name="l09522"></a><span class="lineno"> 9522</span> </div><div class="line"><a name="l09523"></a><span class="lineno"> 9523</span>  <span class="keywordflow">while</span> (*src != <span class="charliteral">'\0'</span>) {</div><div class="line"><a name="l09524"></a><span class="lineno"> 9524</span>  *dest_ptr = *src;</div><div class="line"><a name="l09525"></a><span class="lineno"> 9525</span>  <span class="keywordflow">if</span> (!IsPathSeparator(*src)) {</div><div class="line"><a name="l09526"></a><span class="lineno"> 9526</span>  src++;</div><div class="line"><a name="l09527"></a><span class="lineno"> 9527</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l09528"></a><span class="lineno"> 9528</span> <span class="preprocessor">#if GTEST_HAS_ALT_PATH_SEP_</span></div><div class="line"><a name="l09529"></a><span class="lineno"> 9529</span>  <span class="keywordflow">if</span> (*dest_ptr == kAlternatePathSeparator) {</div><div class="line"><a name="l09530"></a><span class="lineno"> 9530</span>  *dest_ptr = <a class="code" href="namespacetesting_1_1internal.html#afcd71adaa9d1e6df7b282a17fc48125c">kPathSeparator</a>;</div><div class="line"><a name="l09531"></a><span class="lineno"> 9531</span>  }</div><div class="line"><a name="l09532"></a><span class="lineno"> 9532</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l09533"></a><span class="lineno"> 9533</span>  <span class="keywordflow">while</span> (IsPathSeparator(*src))</div><div class="line"><a name="l09534"></a><span class="lineno"> 9534</span>  src++;</div><div class="line"><a name="l09535"></a><span class="lineno"> 9535</span>  }</div><div class="line"><a name="l09536"></a><span class="lineno"> 9536</span>  dest_ptr++;</div><div class="line"><a name="l09537"></a><span class="lineno"> 9537</span>  }</div><div class="line"><a name="l09538"></a><span class="lineno"> 9538</span>  *dest_ptr = <span class="charliteral">'\0'</span>;</div><div class="line"><a name="l09539"></a><span class="lineno"> 9539</span>  pathname_ = dest;</div><div class="line"><a name="l09540"></a><span class="lineno"> 9540</span>  <span class="keyword">delete</span>[] dest;</div><div class="line"><a name="l09541"></a><span class="lineno"> 9541</span> }</div><div class="line"><a name="l09542"></a><span class="lineno"> 9542</span> </div><div class="line"><a name="l09543"></a><span class="lineno"> 9543</span> } <span class="comment">// namespace internal</span></div><div class="line"><a name="l09544"></a><span class="lineno"> 9544</span> } <span class="comment">// namespace testing</span></div><div class="line"><a name="l09545"></a><span class="lineno"> 9545</span> <span class="comment">// Copyright 2007, Google Inc.</span></div><div class="line"><a name="l09546"></a><span class="lineno"> 9546</span> <span class="comment">// All rights reserved.</span></div><div class="line"><a name="l09547"></a><span class="lineno"> 9547</span> <span class="comment">//</span></div><div class="line"><a name="l09548"></a><span class="lineno"> 9548</span> <span class="comment">// Redistribution and use in source and binary forms, with or without</span></div><div class="line"><a name="l09549"></a><span class="lineno"> 9549</span> <span class="comment">// modification, are permitted provided that the following conditions are</span></div><div class="line"><a name="l09550"></a><span class="lineno"> 9550</span> <span class="comment">// met:</span></div><div class="line"><a name="l09551"></a><span class="lineno"> 9551</span> <span class="comment">//</span></div><div class="line"><a name="l09552"></a><span class="lineno"> 9552</span> <span class="comment">// * Redistributions of source code must retain the above copyright</span></div><div class="line"><a name="l09553"></a><span class="lineno"> 9553</span> <span class="comment">// notice, this list of conditions and the following disclaimer.</span></div><div class="line"><a name="l09554"></a><span class="lineno"> 9554</span> <span class="comment">// * Redistributions in binary form must reproduce the above</span></div><div class="line"><a name="l09555"></a><span class="lineno"> 9555</span> <span class="comment">// copyright notice, this list of conditions and the following disclaimer</span></div><div class="line"><a name="l09556"></a><span class="lineno"> 9556</span> <span class="comment">// in the documentation and/or other materials provided with the</span></div><div class="line"><a name="l09557"></a><span class="lineno"> 9557</span> <span class="comment">// distribution.</span></div><div class="line"><a name="l09558"></a><span class="lineno"> 9558</span> <span class="comment">// * Neither the name of Google Inc. nor the names of its</span></div><div class="line"><a name="l09559"></a><span class="lineno"> 9559</span> <span class="comment">// contributors may be used to endorse or promote products derived from</span></div><div class="line"><a name="l09560"></a><span class="lineno"> 9560</span> <span class="comment">// this software without specific prior written permission.</span></div><div class="line"><a name="l09561"></a><span class="lineno"> 9561</span> <span class="comment">//</span></div><div class="line"><a name="l09562"></a><span class="lineno"> 9562</span> <span class="comment">// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span></div><div class="line"><a name="l09563"></a><span class="lineno"> 9563</span> <span class="comment">// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</span></div><div class="line"><a name="l09564"></a><span class="lineno"> 9564</span> <span class="comment">// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR</span></div><div class="line"><a name="l09565"></a><span class="lineno"> 9565</span> <span class="comment">// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT</span></div><div class="line"><a name="l09566"></a><span class="lineno"> 9566</span> <span class="comment">// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span></div><div class="line"><a name="l09567"></a><span class="lineno"> 9567</span> <span class="comment">// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</span></div><div class="line"><a name="l09568"></a><span class="lineno"> 9568</span> <span class="comment">// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</span></div><div class="line"><a name="l09569"></a><span class="lineno"> 9569</span> <span class="comment">// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY</span></div><div class="line"><a name="l09570"></a><span class="lineno"> 9570</span> <span class="comment">// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span></div><div class="line"><a name="l09571"></a><span class="lineno"> 9571</span> <span class="comment">// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE</span></div><div class="line"><a name="l09572"></a><span class="lineno"> 9572</span> <span class="comment">// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span></div><div class="line"><a name="l09573"></a><span class="lineno"> 9573</span> </div><div class="line"><a name="l09574"></a><span class="lineno"> 9574</span> <span class="comment">// The Google C++ Testing and Mocking Framework (Google Test)</span></div><div class="line"><a name="l09575"></a><span class="lineno"> 9575</span> <span class="comment">//</span></div><div class="line"><a name="l09576"></a><span class="lineno"> 9576</span> <span class="comment">// This file implements just enough of the matcher interface to allow</span></div><div class="line"><a name="l09577"></a><span class="lineno"> 9577</span> <span class="comment">// EXPECT_DEATH and friends to accept a matcher argument.</span></div><div class="line"><a name="l09578"></a><span class="lineno"> 9578</span> </div><div class="line"><a name="l09579"></a><span class="lineno"> 9579</span> </div><div class="line"><a name="l09580"></a><span class="lineno"> 9580</span> <span class="preprocessor">#include <string></span></div><div class="line"><a name="l09581"></a><span class="lineno"> 9581</span> </div><div class="line"><a name="l09582"></a><span class="lineno"> 9582</span> <span class="keyword">namespace </span><a class="code" href="namespacetesting.html">testing</a> {</div><div class="line"><a name="l09583"></a><span class="lineno"> 9583</span> </div><div class="line"><a name="l09584"></a><span class="lineno"> 9584</span> <span class="comment">// Constructs a matcher that matches a const std::string& whose value is</span></div><div class="line"><a name="l09585"></a><span class="lineno"> 9585</span> <span class="comment">// equal to s.</span></div><div class="line"><a name="l09586"></a><span class="lineno"> 9586</span> Matcher<const std::string&>::Matcher(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& s) { *<span class="keyword">this</span> = Eq(s); }</div><div class="line"><a name="l09587"></a><span class="lineno"> 9587</span> </div><div class="line"><a name="l09588"></a><span class="lineno"> 9588</span> <span class="preprocessor">#if GTEST_HAS_GLOBAL_STRING</span></div><div class="line"><a name="l09589"></a><span class="lineno"> 9589</span> <span class="comment">// Constructs a matcher that matches a const std::string& whose value is</span></div><div class="line"><a name="l09590"></a><span class="lineno"> 9590</span> <span class="comment">// equal to s.</span></div><div class="line"><a name="l09591"></a><span class="lineno"> 9591</span> Matcher<const std::string&>::Matcher(<a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">const ::string</a>& s) {</div><div class="line"><a name="l09592"></a><span class="lineno"> 9592</span>  *<span class="keyword">this</span> = Eq(static_cast<std::string>(s));</div><div class="line"><a name="l09593"></a><span class="lineno"> 9593</span> }</div><div class="line"><a name="l09594"></a><span class="lineno"> 9594</span> <span class="preprocessor">#endif // GTEST_HAS_GLOBAL_STRING</span></div><div class="line"><a name="l09595"></a><span class="lineno"> 9595</span> </div><div class="line"><a name="l09596"></a><span class="lineno"> 9596</span> <span class="comment">// Constructs a matcher that matches a const std::string& whose value is</span></div><div class="line"><a name="l09597"></a><span class="lineno"> 9597</span> <span class="comment">// equal to s.</span></div><div class="line"><a name="l09598"></a><span class="lineno"> 9598</span> Matcher<const std::string&>::Matcher(<span class="keyword">const</span> <span class="keywordtype">char</span>* s) {</div><div class="line"><a name="l09599"></a><span class="lineno"> 9599</span>  *<span class="keyword">this</span> = Eq(<a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(s));</div><div class="line"><a name="l09600"></a><span class="lineno"> 9600</span> }</div><div class="line"><a name="l09601"></a><span class="lineno"> 9601</span> </div><div class="line"><a name="l09602"></a><span class="lineno"> 9602</span> <span class="comment">// Constructs a matcher that matches a std::string whose value is equal to</span></div><div class="line"><a name="l09603"></a><span class="lineno"> 9603</span> <span class="comment">// s.</span></div><div class="line"><a name="l09604"></a><span class="lineno"> 9604</span> Matcher<std::string>::Matcher(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& s) { *<span class="keyword">this</span> = Eq(s); }</div><div class="line"><a name="l09605"></a><span class="lineno"> 9605</span> </div><div class="line"><a name="l09606"></a><span class="lineno"> 9606</span> <span class="preprocessor">#if GTEST_HAS_GLOBAL_STRING</span></div><div class="line"><a name="l09607"></a><span class="lineno"> 9607</span> <span class="comment">// Constructs a matcher that matches a std::string whose value is equal to</span></div><div class="line"><a name="l09608"></a><span class="lineno"> 9608</span> <span class="comment">// s.</span></div><div class="line"><a name="l09609"></a><span class="lineno"> 9609</span> Matcher<std::string>::Matcher(<a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">const ::string</a>& s) {</div><div class="line"><a name="l09610"></a><span class="lineno"> 9610</span>  *<span class="keyword">this</span> = Eq(static_cast<std::string>(s));</div><div class="line"><a name="l09611"></a><span class="lineno"> 9611</span> }</div><div class="line"><a name="l09612"></a><span class="lineno"> 9612</span> <span class="preprocessor">#endif // GTEST_HAS_GLOBAL_STRING</span></div><div class="line"><a name="l09613"></a><span class="lineno"> 9613</span> </div><div class="line"><a name="l09614"></a><span class="lineno"> 9614</span> <span class="comment">// Constructs a matcher that matches a std::string whose value is equal to</span></div><div class="line"><a name="l09615"></a><span class="lineno"> 9615</span> <span class="comment">// s.</span></div><div class="line"><a name="l09616"></a><span class="lineno"> 9616</span> Matcher<std::string>::Matcher(<span class="keyword">const</span> <span class="keywordtype">char</span>* s) { *<span class="keyword">this</span> = Eq(<a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(s)); }</div><div class="line"><a name="l09617"></a><span class="lineno"> 9617</span> </div><div class="line"><a name="l09618"></a><span class="lineno"> 9618</span> <span class="preprocessor">#if GTEST_HAS_GLOBAL_STRING</span></div><div class="line"><a name="l09619"></a><span class="lineno"> 9619</span> <span class="comment">// Constructs a matcher that matches a const ::string& whose value is</span></div><div class="line"><a name="l09620"></a><span class="lineno"> 9620</span> <span class="comment">// equal to s.</span></div><div class="line"><a name="l09621"></a><span class="lineno"> 9621</span> Matcher<const ::string&>::Matcher(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& s) {</div><div class="line"><a name="l09622"></a><span class="lineno"> 9622</span>  *<span class="keyword">this</span> = Eq(static_cast<::string>(s));</div><div class="line"><a name="l09623"></a><span class="lineno"> 9623</span> }</div><div class="line"><a name="l09624"></a><span class="lineno"> 9624</span> </div><div class="line"><a name="l09625"></a><span class="lineno"> 9625</span> <span class="comment">// Constructs a matcher that matches a const ::string& whose value is</span></div><div class="line"><a name="l09626"></a><span class="lineno"> 9626</span> <span class="comment">// equal to s.</span></div><div class="line"><a name="l09627"></a><span class="lineno"> 9627</span> Matcher<const ::string&>::Matcher(<a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">const ::string</a>& s) { *<span class="keyword">this</span> = Eq(s); }</div><div class="line"><a name="l09628"></a><span class="lineno"> 9628</span> </div><div class="line"><a name="l09629"></a><span class="lineno"> 9629</span> <span class="comment">// Constructs a matcher that matches a const ::string& whose value is</span></div><div class="line"><a name="l09630"></a><span class="lineno"> 9630</span> <span class="comment">// equal to s.</span></div><div class="line"><a name="l09631"></a><span class="lineno"> 9631</span> Matcher<const ::string&>::Matcher(<span class="keyword">const</span> <span class="keywordtype">char</span>* s) { *<span class="keyword">this</span> = Eq(::<span class="keywordtype">string</span>(s)); }</div><div class="line"><a name="l09632"></a><span class="lineno"> 9632</span> </div><div class="line"><a name="l09633"></a><span class="lineno"> 9633</span> <span class="comment">// Constructs a matcher that matches a ::string whose value is equal to s.</span></div><div class="line"><a name="l09634"></a><span class="lineno"> 9634</span> Matcher<::string>::Matcher(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& s) {</div><div class="line"><a name="l09635"></a><span class="lineno"> 9635</span>  *<span class="keyword">this</span> = Eq(static_cast<::string>(s));</div><div class="line"><a name="l09636"></a><span class="lineno"> 9636</span> }</div><div class="line"><a name="l09637"></a><span class="lineno"> 9637</span> </div><div class="line"><a name="l09638"></a><span class="lineno"> 9638</span> <span class="comment">// Constructs a matcher that matches a ::string whose value is equal to s.</span></div><div class="line"><a name="l09639"></a><span class="lineno"> 9639</span> Matcher<::string>::Matcher(<a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">const ::string</a>& s) { *<span class="keyword">this</span> = Eq(s); }</div><div class="line"><a name="l09640"></a><span class="lineno"> 9640</span> </div><div class="line"><a name="l09641"></a><span class="lineno"> 9641</span> <span class="comment">// Constructs a matcher that matches a string whose value is equal to s.</span></div><div class="line"><a name="l09642"></a><span class="lineno"> 9642</span> Matcher<::string>::Matcher(<span class="keyword">const</span> <span class="keywordtype">char</span>* s) { *<span class="keyword">this</span> = Eq(::<span class="keywordtype">string</span>(s)); }</div><div class="line"><a name="l09643"></a><span class="lineno"> 9643</span> <span class="preprocessor">#endif // GTEST_HAS_GLOBAL_STRING</span></div><div class="line"><a name="l09644"></a><span class="lineno"> 9644</span> </div><div class="line"><a name="l09645"></a><span class="lineno"> 9645</span> <span class="preprocessor">#if GTEST_HAS_ABSL</span></div><div class="line"><a name="l09646"></a><span class="lineno"> 9646</span> <span class="comment">// Constructs a matcher that matches a const absl::string_view& whose value is</span></div><div class="line"><a name="l09647"></a><span class="lineno"> 9647</span> <span class="comment">// equal to s.</span></div><div class="line"><a name="l09648"></a><span class="lineno"> 9648</span> Matcher<const absl::string_view&>::Matcher(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& s) {</div><div class="line"><a name="l09649"></a><span class="lineno"> 9649</span>  *<span class="keyword">this</span> = Eq(s);</div><div class="line"><a name="l09650"></a><span class="lineno"> 9650</span> }</div><div class="line"><a name="l09651"></a><span class="lineno"> 9651</span> </div><div class="line"><a name="l09652"></a><span class="lineno"> 9652</span> <span class="preprocessor">#if GTEST_HAS_GLOBAL_STRING</span></div><div class="line"><a name="l09653"></a><span class="lineno"> 9653</span> <span class="comment">// Constructs a matcher that matches a const absl::string_view& whose value is</span></div><div class="line"><a name="l09654"></a><span class="lineno"> 9654</span> <span class="comment">// equal to s.</span></div><div class="line"><a name="l09655"></a><span class="lineno"> 9655</span> Matcher<const absl::string_view&>::Matcher(<a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">const ::string</a>& s) { *<span class="keyword">this</span> = Eq(s); }</div><div class="line"><a name="l09656"></a><span class="lineno"> 9656</span> <span class="preprocessor">#endif // GTEST_HAS_GLOBAL_STRING</span></div><div class="line"><a name="l09657"></a><span class="lineno"> 9657</span> </div><div class="line"><a name="l09658"></a><span class="lineno"> 9658</span> <span class="comment">// Constructs a matcher that matches a const absl::string_view& whose value is</span></div><div class="line"><a name="l09659"></a><span class="lineno"> 9659</span> <span class="comment">// equal to s.</span></div><div class="line"><a name="l09660"></a><span class="lineno"> 9660</span> Matcher<const absl::string_view&>::Matcher(<span class="keyword">const</span> <span class="keywordtype">char</span>* s) {</div><div class="line"><a name="l09661"></a><span class="lineno"> 9661</span>  *<span class="keyword">this</span> = Eq(<a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(s));</div><div class="line"><a name="l09662"></a><span class="lineno"> 9662</span> }</div><div class="line"><a name="l09663"></a><span class="lineno"> 9663</span> </div><div class="line"><a name="l09664"></a><span class="lineno"> 9664</span> <span class="comment">// Constructs a matcher that matches a const absl::string_view& whose value is</span></div><div class="line"><a name="l09665"></a><span class="lineno"> 9665</span> <span class="comment">// equal to s.</span></div><div class="line"><a name="l09666"></a><span class="lineno"> 9666</span> Matcher<const absl::string_view&>::Matcher(absl::string_view s) {</div><div class="line"><a name="l09667"></a><span class="lineno"> 9667</span>  *<span class="keyword">this</span> = Eq(<a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(s));</div><div class="line"><a name="l09668"></a><span class="lineno"> 9668</span> }</div><div class="line"><a name="l09669"></a><span class="lineno"> 9669</span> </div><div class="line"><a name="l09670"></a><span class="lineno"> 9670</span> <span class="comment">// Constructs a matcher that matches a absl::string_view whose value is equal to</span></div><div class="line"><a name="l09671"></a><span class="lineno"> 9671</span> <span class="comment">// s.</span></div><div class="line"><a name="l09672"></a><span class="lineno"> 9672</span> Matcher<absl::string_view>::Matcher(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& s) { *<span class="keyword">this</span> = Eq(s); }</div><div class="line"><a name="l09673"></a><span class="lineno"> 9673</span> </div><div class="line"><a name="l09674"></a><span class="lineno"> 9674</span> <span class="preprocessor">#if GTEST_HAS_GLOBAL_STRING</span></div><div class="line"><a name="l09675"></a><span class="lineno"> 9675</span> <span class="comment">// Constructs a matcher that matches a absl::string_view whose value is equal to</span></div><div class="line"><a name="l09676"></a><span class="lineno"> 9676</span> <span class="comment">// s.</span></div><div class="line"><a name="l09677"></a><span class="lineno"> 9677</span> Matcher<absl::string_view>::Matcher(<a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">const ::string</a>& s) { *<span class="keyword">this</span> = Eq(s); }</div><div class="line"><a name="l09678"></a><span class="lineno"> 9678</span> <span class="preprocessor">#endif // GTEST_HAS_GLOBAL_STRING</span></div><div class="line"><a name="l09679"></a><span class="lineno"> 9679</span> </div><div class="line"><a name="l09680"></a><span class="lineno"> 9680</span> <span class="comment">// Constructs a matcher that matches a absl::string_view whose value is equal to</span></div><div class="line"><a name="l09681"></a><span class="lineno"> 9681</span> <span class="comment">// s.</span></div><div class="line"><a name="l09682"></a><span class="lineno"> 9682</span> Matcher<absl::string_view>::Matcher(<span class="keyword">const</span> <span class="keywordtype">char</span>* s) {</div><div class="line"><a name="l09683"></a><span class="lineno"> 9683</span>  *<span class="keyword">this</span> = Eq(<a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(s));</div><div class="line"><a name="l09684"></a><span class="lineno"> 9684</span> }</div><div class="line"><a name="l09685"></a><span class="lineno"> 9685</span> </div><div class="line"><a name="l09686"></a><span class="lineno"> 9686</span> <span class="comment">// Constructs a matcher that matches a absl::string_view whose value is equal to</span></div><div class="line"><a name="l09687"></a><span class="lineno"> 9687</span> <span class="comment">// s.</span></div><div class="line"><a name="l09688"></a><span class="lineno"> 9688</span> Matcher<absl::string_view>::Matcher(absl::string_view s) {</div><div class="line"><a name="l09689"></a><span class="lineno"> 9689</span>  *<span class="keyword">this</span> = Eq(<a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(s));</div><div class="line"><a name="l09690"></a><span class="lineno"> 9690</span> }</div><div class="line"><a name="l09691"></a><span class="lineno"> 9691</span> <span class="preprocessor">#endif // GTEST_HAS_ABSL</span></div><div class="line"><a name="l09692"></a><span class="lineno"> 9692</span> </div><div class="line"><a name="l09693"></a><span class="lineno"> 9693</span> } <span class="comment">// namespace testing</span></div><div class="line"><a name="l09694"></a><span class="lineno"> 9694</span> <span class="comment">// Copyright 2008, Google Inc.</span></div><div class="line"><a name="l09695"></a><span class="lineno"> 9695</span> <span class="comment">// All rights reserved.</span></div><div class="line"><a name="l09696"></a><span class="lineno"> 9696</span> <span class="comment">//</span></div><div class="line"><a name="l09697"></a><span class="lineno"> 9697</span> <span class="comment">// Redistribution and use in source and binary forms, with or without</span></div><div class="line"><a name="l09698"></a><span class="lineno"> 9698</span> <span class="comment">// modification, are permitted provided that the following conditions are</span></div><div class="line"><a name="l09699"></a><span class="lineno"> 9699</span> <span class="comment">// met:</span></div><div class="line"><a name="l09700"></a><span class="lineno"> 9700</span> <span class="comment">//</span></div><div class="line"><a name="l09701"></a><span class="lineno"> 9701</span> <span class="comment">// * Redistributions of source code must retain the above copyright</span></div><div class="line"><a name="l09702"></a><span class="lineno"> 9702</span> <span class="comment">// notice, this list of conditions and the following disclaimer.</span></div><div class="line"><a name="l09703"></a><span class="lineno"> 9703</span> <span class="comment">// * Redistributions in binary form must reproduce the above</span></div><div class="line"><a name="l09704"></a><span class="lineno"> 9704</span> <span class="comment">// copyright notice, this list of conditions and the following disclaimer</span></div><div class="line"><a name="l09705"></a><span class="lineno"> 9705</span> <span class="comment">// in the documentation and/or other materials provided with the</span></div><div class="line"><a name="l09706"></a><span class="lineno"> 9706</span> <span class="comment">// distribution.</span></div><div class="line"><a name="l09707"></a><span class="lineno"> 9707</span> <span class="comment">// * Neither the name of Google Inc. nor the names of its</span></div><div class="line"><a name="l09708"></a><span class="lineno"> 9708</span> <span class="comment">// contributors may be used to endorse or promote products derived from</span></div><div class="line"><a name="l09709"></a><span class="lineno"> 9709</span> <span class="comment">// this software without specific prior written permission.</span></div><div class="line"><a name="l09710"></a><span class="lineno"> 9710</span> <span class="comment">//</span></div><div class="line"><a name="l09711"></a><span class="lineno"> 9711</span> <span class="comment">// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span></div><div class="line"><a name="l09712"></a><span class="lineno"> 9712</span> <span class="comment">// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</span></div><div class="line"><a name="l09713"></a><span class="lineno"> 9713</span> <span class="comment">// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR</span></div><div class="line"><a name="l09714"></a><span class="lineno"> 9714</span> <span class="comment">// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT</span></div><div class="line"><a name="l09715"></a><span class="lineno"> 9715</span> <span class="comment">// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span></div><div class="line"><a name="l09716"></a><span class="lineno"> 9716</span> <span class="comment">// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</span></div><div class="line"><a name="l09717"></a><span class="lineno"> 9717</span> <span class="comment">// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</span></div><div class="line"><a name="l09718"></a><span class="lineno"> 9718</span> <span class="comment">// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY</span></div><div class="line"><a name="l09719"></a><span class="lineno"> 9719</span> <span class="comment">// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span></div><div class="line"><a name="l09720"></a><span class="lineno"> 9720</span> <span class="comment">// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE</span></div><div class="line"><a name="l09721"></a><span class="lineno"> 9721</span> <span class="comment">// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span></div><div class="line"><a name="l09722"></a><span class="lineno"> 9722</span> </div><div class="line"><a name="l09723"></a><span class="lineno"> 9723</span> </div><div class="line"><a name="l09724"></a><span class="lineno"> 9724</span> </div><div class="line"><a name="l09725"></a><span class="lineno"> 9725</span> <span class="preprocessor">#include <limits.h></span></div><div class="line"><a name="l09726"></a><span class="lineno"> 9726</span> <span class="preprocessor">#include <stdio.h></span></div><div class="line"><a name="l09727"></a><span class="lineno"> 9727</span> <span class="preprocessor">#include <stdlib.h></span></div><div class="line"><a name="l09728"></a><span class="lineno"> 9728</span> <span class="preprocessor">#include <string.h></span></div><div class="line"><a name="l09729"></a><span class="lineno"> 9729</span> <span class="preprocessor">#include <fstream></span></div><div class="line"><a name="l09730"></a><span class="lineno"> 9730</span> <span class="preprocessor">#include <memory></span></div><div class="line"><a name="l09731"></a><span class="lineno"> 9731</span> </div><div class="line"><a name="l09732"></a><span class="lineno"> 9732</span> <span class="preprocessor">#if GTEST_OS_WINDOWS</span></div><div class="line"><a name="l09733"></a><span class="lineno"> 9733</span> <span class="preprocessor"># include <windows.h></span></div><div class="line"><a name="l09734"></a><span class="lineno"> 9734</span> <span class="preprocessor"># include <io.h></span></div><div class="line"><a name="l09735"></a><span class="lineno"> 9735</span> <span class="preprocessor"># include <sys/stat.h></span></div><div class="line"><a name="l09736"></a><span class="lineno"> 9736</span> <span class="preprocessor"># include <map></span> <span class="comment">// Used in ThreadLocal.</span></div><div class="line"><a name="l09737"></a><span class="lineno"> 9737</span> <span class="preprocessor"># ifdef _MSC_VER</span></div><div class="line"><a name="l09738"></a><span class="lineno"> 9738</span> <span class="preprocessor"># include <crtdbg.h></span></div><div class="line"><a name="l09739"></a><span class="lineno"> 9739</span> <span class="preprocessor"># endif // _MSC_VER</span></div><div class="line"><a name="l09740"></a><span class="lineno"> 9740</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l09741"></a><span class="lineno"> 9741</span> <span class="preprocessor"># include <unistd.h></span></div><div class="line"><a name="l09742"></a><span class="lineno"> 9742</span> <span class="preprocessor">#endif // GTEST_OS_WINDOWS</span></div><div class="line"><a name="l09743"></a><span class="lineno"> 9743</span> </div><div class="line"><a name="l09744"></a><span class="lineno"> 9744</span> <span class="preprocessor">#if GTEST_OS_MAC</span></div><div class="line"><a name="l09745"></a><span class="lineno"> 9745</span> <span class="preprocessor"># include <mach/mach_init.h></span></div><div class="line"><a name="l09746"></a><span class="lineno"> 9746</span> <span class="preprocessor"># include <mach/task.h></span></div><div class="line"><a name="l09747"></a><span class="lineno"> 9747</span> <span class="preprocessor"># include <mach/vm_map.h></span></div><div class="line"><a name="l09748"></a><span class="lineno"> 9748</span> <span class="preprocessor">#endif // GTEST_OS_MAC</span></div><div class="line"><a name="l09749"></a><span class="lineno"> 9749</span> </div><div class="line"><a name="l09750"></a><span class="lineno"> 9750</span> <span class="preprocessor">#if GTEST_OS_QNX</span></div><div class="line"><a name="l09751"></a><span class="lineno"> 9751</span> <span class="preprocessor"># include <devctl.h></span></div><div class="line"><a name="l09752"></a><span class="lineno"> 9752</span> <span class="preprocessor"># include <fcntl.h></span></div><div class="line"><a name="l09753"></a><span class="lineno"> 9753</span> <span class="preprocessor"># include <sys/procfs.h></span></div><div class="line"><a name="l09754"></a><span class="lineno"> 9754</span> <span class="preprocessor">#endif // GTEST_OS_QNX</span></div><div class="line"><a name="l09755"></a><span class="lineno"> 9755</span> </div><div class="line"><a name="l09756"></a><span class="lineno"> 9756</span> <span class="preprocessor">#if GTEST_OS_AIX</span></div><div class="line"><a name="l09757"></a><span class="lineno"> 9757</span> <span class="preprocessor"># include <procinfo.h></span></div><div class="line"><a name="l09758"></a><span class="lineno"> 9758</span> <span class="preprocessor"># include <sys/types.h></span></div><div class="line"><a name="l09759"></a><span class="lineno"> 9759</span> <span class="preprocessor">#endif // GTEST_OS_AIX</span></div><div class="line"><a name="l09760"></a><span class="lineno"> 9760</span> </div><div class="line"><a name="l09761"></a><span class="lineno"> 9761</span> <span class="preprocessor">#if GTEST_OS_FUCHSIA</span></div><div class="line"><a name="l09762"></a><span class="lineno"> 9762</span> <span class="preprocessor"># include <zircon/process.h></span></div><div class="line"><a name="l09763"></a><span class="lineno"> 9763</span> <span class="preprocessor"># include <zircon/syscalls.h></span></div><div class="line"><a name="l09764"></a><span class="lineno"> 9764</span> <span class="preprocessor">#endif // GTEST_OS_FUCHSIA</span></div><div class="line"><a name="l09765"></a><span class="lineno"> 9765</span> </div><div class="line"><a name="l09766"></a><span class="lineno"> 9766</span> </div><div class="line"><a name="l09767"></a><span class="lineno"> 9767</span> <span class="keyword">namespace </span><a class="code" href="namespacetesting.html">testing</a> {</div><div class="line"><a name="l09768"></a><span class="lineno"> 9768</span> <span class="keyword">namespace </span>internal {</div><div class="line"><a name="l09769"></a><span class="lineno"> 9769</span> </div><div class="line"><a name="l09770"></a><span class="lineno"> 9770</span> <span class="preprocessor">#if defined(_MSC_VER) || defined(__BORLANDC__)</span></div><div class="line"><a name="l09771"></a><span class="lineno"> 9771</span> <span class="comment">// MSVC and C++Builder do not provide a definition of STDERR_FILENO.</span></div><div class="line"><a name="l09772"></a><span class="lineno"> 9772</span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="namespacetesting_1_1internal.html#a24f0a3d50cac54a9132f4828ec9b96d9">kStdOutFileno</a> = 1;</div><div class="line"><a name="l09773"></a><span class="lineno"> 9773</span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="namespacetesting_1_1internal.html#a747eccfdbdee3ff8af3bedc476a57c85">kStdErrFileno</a> = 2;</div><div class="line"><a name="l09774"></a><span class="lineno"> 9774</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l09775"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#a24f0a3d50cac54a9132f4828ec9b96d9"> 9775</a></span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="namespacetesting_1_1internal.html#a24f0a3d50cac54a9132f4828ec9b96d9">kStdOutFileno</a> = STDOUT_FILENO;</div><div class="line"><a name="l09776"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#a747eccfdbdee3ff8af3bedc476a57c85"> 9776</a></span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="namespacetesting_1_1internal.html#a747eccfdbdee3ff8af3bedc476a57c85">kStdErrFileno</a> = STDERR_FILENO;</div><div class="line"><a name="l09777"></a><span class="lineno"> 9777</span> <span class="preprocessor">#endif // _MSC_VER</span></div><div class="line"><a name="l09778"></a><span class="lineno"> 9778</span> </div><div class="line"><a name="l09779"></a><span class="lineno"> 9779</span> <span class="preprocessor">#if GTEST_OS_LINUX</span></div><div class="line"><a name="l09780"></a><span class="lineno"> 9780</span> </div><div class="line"><a name="l09781"></a><span class="lineno"> 9781</span> <span class="keyword">namespace </span>{</div><div class="line"><a name="l09782"></a><span class="lineno"> 9782</span> <span class="keyword">template</span> <<span class="keyword">typename</span> T></div><div class="line"><a name="l09783"></a><span class="lineno"> 9783</span> T ReadProcFileField(<span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& filename, <span class="keywordtype">int</span> field) {</div><div class="line"><a name="l09784"></a><span class="lineno"> 9784</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> dummy;</div><div class="line"><a name="l09785"></a><span class="lineno"> 9785</span>  std::ifstream file(filename.c_str());</div><div class="line"><a name="l09786"></a><span class="lineno"> 9786</span>  <span class="keywordflow">while</span> (field-- > 0) {</div><div class="line"><a name="l09787"></a><span class="lineno"> 9787</span>  file >> dummy;</div><div class="line"><a name="l09788"></a><span class="lineno"> 9788</span>  }</div><div class="line"><a name="l09789"></a><span class="lineno"> 9789</span>  T output = 0;</div><div class="line"><a name="l09790"></a><span class="lineno"> 9790</span>  file >> output;</div><div class="line"><a name="l09791"></a><span class="lineno"> 9791</span>  <span class="keywordflow">return</span> output;</div><div class="line"><a name="l09792"></a><span class="lineno"> 9792</span> }</div><div class="line"><a name="l09793"></a><span class="lineno"> 9793</span> } <span class="comment">// namespace</span></div><div class="line"><a name="l09794"></a><span class="lineno"> 9794</span> </div><div class="line"><a name="l09795"></a><span class="lineno"> 9795</span> <span class="comment">// Returns the number of active threads, or 0 when there is an error.</span></div><div class="line"><a name="l09796"></a><span class="lineno"> 9796</span> <span class="keywordtype">size_t</span> <a class="code" href="namespacetesting_1_1internal.html#a8cbd8bf820517923d7f3c4477b3af5fa">GetThreadCount</a>() {</div><div class="line"><a name="l09797"></a><span class="lineno"> 9797</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> filename =</div><div class="line"><a name="l09798"></a><span class="lineno"> 9798</span>  (<a class="code" href="classtesting_1_1_message.html">Message</a>() << <span class="stringliteral">"/proc/"</span> << getpid() << <span class="stringliteral">"/stat"</span>).GetString();</div><div class="line"><a name="l09799"></a><span class="lineno"> 9799</span>  <span class="keywordflow">return</span> ReadProcFileField<int>(filename, 19);</div><div class="line"><a name="l09800"></a><span class="lineno"> 9800</span> }</div><div class="line"><a name="l09801"></a><span class="lineno"> 9801</span> </div><div class="line"><a name="l09802"></a><span class="lineno"> 9802</span> <span class="preprocessor">#elif GTEST_OS_MAC</span></div><div class="line"><a name="l09803"></a><span class="lineno"> 9803</span> </div><div class="line"><a name="l09804"></a><span class="lineno"> 9804</span> <span class="keywordtype">size_t</span> <a class="code" href="namespacetesting_1_1internal.html#a8cbd8bf820517923d7f3c4477b3af5fa">GetThreadCount</a>() {</div><div class="line"><a name="l09805"></a><span class="lineno"> 9805</span>  <span class="keyword">const</span> task_t task = mach_task_self();</div><div class="line"><a name="l09806"></a><span class="lineno"> 9806</span>  mach_msg_type_number_t thread_count;</div><div class="line"><a name="l09807"></a><span class="lineno"> 9807</span>  thread_act_array_t thread_list;</div><div class="line"><a name="l09808"></a><span class="lineno"> 9808</span>  <span class="keyword">const</span> kern_return_t status = task_threads(task, &thread_list, &thread_count);</div><div class="line"><a name="l09809"></a><span class="lineno"> 9809</span>  <span class="keywordflow">if</span> (status == KERN_SUCCESS) {</div><div class="line"><a name="l09810"></a><span class="lineno"> 9810</span>  <span class="comment">// task_threads allocates resources in thread_list and we need to free them</span></div><div class="line"><a name="l09811"></a><span class="lineno"> 9811</span>  <span class="comment">// to avoid leaks.</span></div><div class="line"><a name="l09812"></a><span class="lineno"> 9812</span>  vm_deallocate(task,</div><div class="line"><a name="l09813"></a><span class="lineno"> 9813</span>  reinterpret_cast<vm_address_t>(thread_list),</div><div class="line"><a name="l09814"></a><span class="lineno"> 9814</span>  <span class="keyword">sizeof</span>(thread_t) * thread_count);</div><div class="line"><a name="l09815"></a><span class="lineno"> 9815</span>  <span class="keywordflow">return</span> <span class="keyword">static_cast<</span><span class="keywordtype">size_t</span><span class="keyword">></span>(thread_count);</div><div class="line"><a name="l09816"></a><span class="lineno"> 9816</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l09817"></a><span class="lineno"> 9817</span>  <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l09818"></a><span class="lineno"> 9818</span>  }</div><div class="line"><a name="l09819"></a><span class="lineno"> 9819</span> }</div><div class="line"><a name="l09820"></a><span class="lineno"> 9820</span> </div><div class="line"><a name="l09821"></a><span class="lineno"> 9821</span> <span class="preprocessor">#elif GTEST_OS_QNX</span></div><div class="line"><a name="l09822"></a><span class="lineno"> 9822</span> </div><div class="line"><a name="l09823"></a><span class="lineno"> 9823</span> <span class="comment">// Returns the number of threads running in the process, or 0 to indicate that</span></div><div class="line"><a name="l09824"></a><span class="lineno"> 9824</span> <span class="comment">// we cannot detect it.</span></div><div class="line"><a name="l09825"></a><span class="lineno"> 9825</span> <span class="keywordtype">size_t</span> <a class="code" href="namespacetesting_1_1internal.html#a8cbd8bf820517923d7f3c4477b3af5fa">GetThreadCount</a>() {</div><div class="line"><a name="l09826"></a><span class="lineno"> 9826</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> fd = open(<span class="stringliteral">"/proc/self/as"</span>, O_RDONLY);</div><div class="line"><a name="l09827"></a><span class="lineno"> 9827</span>  <span class="keywordflow">if</span> (fd < 0) {</div><div class="line"><a name="l09828"></a><span class="lineno"> 9828</span>  <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l09829"></a><span class="lineno"> 9829</span>  }</div><div class="line"><a name="l09830"></a><span class="lineno"> 9830</span>  procfs_info process_info;</div><div class="line"><a name="l09831"></a><span class="lineno"> 9831</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> status =</div><div class="line"><a name="l09832"></a><span class="lineno"> 9832</span>  devctl(fd, DCMD_PROC_INFO, &process_info, <span class="keyword">sizeof</span>(process_info), <span class="keyword">nullptr</span>);</div><div class="line"><a name="l09833"></a><span class="lineno"> 9833</span>  close(fd);</div><div class="line"><a name="l09834"></a><span class="lineno"> 9834</span>  <span class="keywordflow">if</span> (status == EOK) {</div><div class="line"><a name="l09835"></a><span class="lineno"> 9835</span>  <span class="keywordflow">return</span> <span class="keyword">static_cast<</span><span class="keywordtype">size_t</span><span class="keyword">></span>(process_info.num_threads);</div><div class="line"><a name="l09836"></a><span class="lineno"> 9836</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l09837"></a><span class="lineno"> 9837</span>  <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l09838"></a><span class="lineno"> 9838</span>  }</div><div class="line"><a name="l09839"></a><span class="lineno"> 9839</span> }</div><div class="line"><a name="l09840"></a><span class="lineno"> 9840</span> </div><div class="line"><a name="l09841"></a><span class="lineno"> 9841</span> <span class="preprocessor">#elif GTEST_OS_AIX</span></div><div class="line"><a name="l09842"></a><span class="lineno"> 9842</span> </div><div class="line"><a name="l09843"></a><span class="lineno"> 9843</span> <span class="keywordtype">size_t</span> <a class="code" href="namespacetesting_1_1internal.html#a8cbd8bf820517923d7f3c4477b3af5fa">GetThreadCount</a>() {</div><div class="line"><a name="l09844"></a><span class="lineno"> 9844</span>  <span class="keyword">struct </span>procentry64 entry;</div><div class="line"><a name="l09845"></a><span class="lineno"> 9845</span>  pid_t pid = getpid();</div><div class="line"><a name="l09846"></a><span class="lineno"> 9846</span>  <span class="keywordtype">int</span> status = getprocs64(&entry, <span class="keyword">sizeof</span>(entry), <span class="keyword">nullptr</span>, 0, &pid, 1);</div><div class="line"><a name="l09847"></a><span class="lineno"> 9847</span>  <span class="keywordflow">if</span> (status == 1) {</div><div class="line"><a name="l09848"></a><span class="lineno"> 9848</span>  <span class="keywordflow">return</span> entry.pi_thcount;</div><div class="line"><a name="l09849"></a><span class="lineno"> 9849</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l09850"></a><span class="lineno"> 9850</span>  <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l09851"></a><span class="lineno"> 9851</span>  }</div><div class="line"><a name="l09852"></a><span class="lineno"> 9852</span> }</div><div class="line"><a name="l09853"></a><span class="lineno"> 9853</span> </div><div class="line"><a name="l09854"></a><span class="lineno"> 9854</span> <span class="preprocessor">#elif GTEST_OS_FUCHSIA</span></div><div class="line"><a name="l09855"></a><span class="lineno"> 9855</span> </div><div class="line"><a name="l09856"></a><span class="lineno"> 9856</span> <span class="keywordtype">size_t</span> <a class="code" href="namespacetesting_1_1internal.html#a8cbd8bf820517923d7f3c4477b3af5fa">GetThreadCount</a>() {</div><div class="line"><a name="l09857"></a><span class="lineno"> 9857</span>  <span class="keywordtype">int</span> dummy_buffer;</div><div class="line"><a name="l09858"></a><span class="lineno"> 9858</span>  <span class="keywordtype">size_t</span> avail;</div><div class="line"><a name="l09859"></a><span class="lineno"> 9859</span>  zx_status_t status = zx_object_get_info(</div><div class="line"><a name="l09860"></a><span class="lineno"> 9860</span>  zx_process_self(),</div><div class="line"><a name="l09861"></a><span class="lineno"> 9861</span>  ZX_INFO_PROCESS_THREADS,</div><div class="line"><a name="l09862"></a><span class="lineno"> 9862</span>  &dummy_buffer,</div><div class="line"><a name="l09863"></a><span class="lineno"> 9863</span>  0,</div><div class="line"><a name="l09864"></a><span class="lineno"> 9864</span>  <span class="keyword">nullptr</span>,</div><div class="line"><a name="l09865"></a><span class="lineno"> 9865</span>  &avail);</div><div class="line"><a name="l09866"></a><span class="lineno"> 9866</span>  <span class="keywordflow">if</span> (status == ZX_OK) {</div><div class="line"><a name="l09867"></a><span class="lineno"> 9867</span>  <span class="keywordflow">return</span> avail;</div><div class="line"><a name="l09868"></a><span class="lineno"> 9868</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l09869"></a><span class="lineno"> 9869</span>  <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l09870"></a><span class="lineno"> 9870</span>  }</div><div class="line"><a name="l09871"></a><span class="lineno"> 9871</span> }</div><div class="line"><a name="l09872"></a><span class="lineno"> 9872</span> </div><div class="line"><a name="l09873"></a><span class="lineno"> 9873</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l09874"></a><span class="lineno"> 9874</span> </div><div class="line"><a name="l09875"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#a8cbd8bf820517923d7f3c4477b3af5fa"> 9875</a></span> <span class="keywordtype">size_t</span> <a class="code" href="namespacetesting_1_1internal.html#a8cbd8bf820517923d7f3c4477b3af5fa">GetThreadCount</a>() {</div><div class="line"><a name="l09876"></a><span class="lineno"> 9876</span>  <span class="comment">// There's no portable way to detect the number of threads, so we just</span></div><div class="line"><a name="l09877"></a><span class="lineno"> 9877</span>  <span class="comment">// return 0 to indicate that we cannot detect it.</span></div><div class="line"><a name="l09878"></a><span class="lineno"> 9878</span>  <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l09879"></a><span class="lineno"> 9879</span> }</div><div class="line"><a name="l09880"></a><span class="lineno"> 9880</span> </div><div class="line"><a name="l09881"></a><span class="lineno"> 9881</span> <span class="preprocessor">#endif // GTEST_OS_LINUX</span></div><div class="line"><a name="l09882"></a><span class="lineno"> 9882</span> </div><div class="line"><a name="l09883"></a><span class="lineno"> 9883</span> <span class="preprocessor">#if GTEST_IS_THREADSAFE && GTEST_OS_WINDOWS</span></div><div class="line"><a name="l09884"></a><span class="lineno"> 9884</span> </div><div class="line"><a name="l09885"></a><span class="lineno"> 9885</span> <span class="keywordtype">void</span> SleepMilliseconds(<span class="keywordtype">int</span> n) {</div><div class="line"><a name="l09886"></a><span class="lineno"> 9886</span>  ::Sleep(n);</div><div class="line"><a name="l09887"></a><span class="lineno"> 9887</span> }</div><div class="line"><a name="l09888"></a><span class="lineno"> 9888</span> </div><div class="line"><a name="l09889"></a><span class="lineno"> 9889</span> AutoHandle::AutoHandle()</div><div class="line"><a name="l09890"></a><span class="lineno"> 9890</span>  : handle_(INVALID_HANDLE_VALUE) {}</div><div class="line"><a name="l09891"></a><span class="lineno"> 9891</span> </div><div class="line"><a name="l09892"></a><span class="lineno"> 9892</span> AutoHandle::AutoHandle(Handle handle)</div><div class="line"><a name="l09893"></a><span class="lineno"> 9893</span>  : handle_(handle) {}</div><div class="line"><a name="l09894"></a><span class="lineno"> 9894</span> </div><div class="line"><a name="l09895"></a><span class="lineno"> 9895</span> AutoHandle::~AutoHandle() {</div><div class="line"><a name="l09896"></a><span class="lineno"> 9896</span>  Reset();</div><div class="line"><a name="l09897"></a><span class="lineno"> 9897</span> }</div><div class="line"><a name="l09898"></a><span class="lineno"> 9898</span> </div><div class="line"><a name="l09899"></a><span class="lineno"> 9899</span> AutoHandle::Handle AutoHandle::Get()<span class="keyword"> const </span>{</div><div class="line"><a name="l09900"></a><span class="lineno"> 9900</span>  <span class="keywordflow">return</span> handle_;</div><div class="line"><a name="l09901"></a><span class="lineno"> 9901</span> }</div><div class="line"><a name="l09902"></a><span class="lineno"> 9902</span> </div><div class="line"><a name="l09903"></a><span class="lineno"> 9903</span> <span class="keywordtype">void</span> AutoHandle::Reset() {</div><div class="line"><a name="l09904"></a><span class="lineno"> 9904</span>  Reset(INVALID_HANDLE_VALUE);</div><div class="line"><a name="l09905"></a><span class="lineno"> 9905</span> }</div><div class="line"><a name="l09906"></a><span class="lineno"> 9906</span> </div><div class="line"><a name="l09907"></a><span class="lineno"> 9907</span> <span class="keywordtype">void</span> AutoHandle::Reset(HANDLE handle) {</div><div class="line"><a name="l09908"></a><span class="lineno"> 9908</span>  <span class="comment">// Resetting with the same handle we already own is invalid.</span></div><div class="line"><a name="l09909"></a><span class="lineno"> 9909</span>  <span class="keywordflow">if</span> (handle_ != handle) {</div><div class="line"><a name="l09910"></a><span class="lineno"> 9910</span>  <span class="keywordflow">if</span> (IsCloseable()) {</div><div class="line"><a name="l09911"></a><span class="lineno"> 9911</span>  ::CloseHandle(handle_);</div><div class="line"><a name="l09912"></a><span class="lineno"> 9912</span>  }</div><div class="line"><a name="l09913"></a><span class="lineno"> 9913</span>  handle_ = handle;</div><div class="line"><a name="l09914"></a><span class="lineno"> 9914</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l09915"></a><span class="lineno"> 9915</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(!IsCloseable())</div><div class="line"><a name="l09916"></a><span class="lineno"> 9916</span>  << <span class="stringliteral">"Resetting a valid handle to itself is likely a programmer error "</span></div><div class="line"><a name="l09917"></a><span class="lineno"> 9917</span>  <span class="stringliteral">"and thus not allowed."</span>;</div><div class="line"><a name="l09918"></a><span class="lineno"> 9918</span>  }</div><div class="line"><a name="l09919"></a><span class="lineno"> 9919</span> }</div><div class="line"><a name="l09920"></a><span class="lineno"> 9920</span> </div><div class="line"><a name="l09921"></a><span class="lineno"> 9921</span> <span class="keywordtype">bool</span> AutoHandle::IsCloseable()<span class="keyword"> const </span>{</div><div class="line"><a name="l09922"></a><span class="lineno"> 9922</span>  <span class="comment">// Different Windows APIs may use either of these values to represent an</span></div><div class="line"><a name="l09923"></a><span class="lineno"> 9923</span>  <span class="comment">// invalid handle.</span></div><div class="line"><a name="l09924"></a><span class="lineno"> 9924</span>  <span class="keywordflow">return</span> handle_ != <span class="keyword">nullptr</span> && handle_ != INVALID_HANDLE_VALUE;</div><div class="line"><a name="l09925"></a><span class="lineno"> 9925</span> }</div><div class="line"><a name="l09926"></a><span class="lineno"> 9926</span> </div><div class="line"><a name="l09927"></a><span class="lineno"> 9927</span> Notification::Notification()</div><div class="line"><a name="l09928"></a><span class="lineno"> 9928</span>  : event_(::CreateEvent(nullptr, <span class="comment">// Default security attributes.</span></div><div class="line"><a name="l09929"></a><span class="lineno"> 9929</span>  TRUE, <span class="comment">// Do not reset automatically.</span></div><div class="line"><a name="l09930"></a><span class="lineno"> 9930</span>  FALSE, <span class="comment">// Initially unset.</span></div><div class="line"><a name="l09931"></a><span class="lineno"> 9931</span>  nullptr)) { <span class="comment">// Anonymous event.</span></div><div class="line"><a name="l09932"></a><span class="lineno"> 9932</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(event_.Get() != <span class="keyword">nullptr</span>);</div><div class="line"><a name="l09933"></a><span class="lineno"> 9933</span> }</div><div class="line"><a name="l09934"></a><span class="lineno"> 9934</span> </div><div class="line"><a name="l09935"></a><span class="lineno"> 9935</span> <span class="keywordtype">void</span> Notification::Notify() {</div><div class="line"><a name="l09936"></a><span class="lineno"> 9936</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(::SetEvent(event_.Get()) != FALSE);</div><div class="line"><a name="l09937"></a><span class="lineno"> 9937</span> }</div><div class="line"><a name="l09938"></a><span class="lineno"> 9938</span> </div><div class="line"><a name="l09939"></a><span class="lineno"> 9939</span> <span class="keywordtype">void</span> Notification::WaitForNotification() {</div><div class="line"><a name="l09940"></a><span class="lineno"> 9940</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(</div><div class="line"><a name="l09941"></a><span class="lineno"> 9941</span>  ::WaitForSingleObject(event_.Get(), INFINITE) == WAIT_OBJECT_0);</div><div class="line"><a name="l09942"></a><span class="lineno"> 9942</span> }</div><div class="line"><a name="l09943"></a><span class="lineno"> 9943</span> </div><div class="line"><a name="l09944"></a><span class="lineno"> 9944</span> Mutex::Mutex()</div><div class="line"><a name="l09945"></a><span class="lineno"> 9945</span>  : owner_thread_id_(0),</div><div class="line"><a name="l09946"></a><span class="lineno"> 9946</span>  type_(kDynamic),</div><div class="line"><a name="l09947"></a><span class="lineno"> 9947</span>  critical_section_init_phase_(0),</div><div class="line"><a name="l09948"></a><span class="lineno"> 9948</span>  critical_section_(new CRITICAL_SECTION) {</div><div class="line"><a name="l09949"></a><span class="lineno"> 9949</span>  ::InitializeCriticalSection(critical_section_);</div><div class="line"><a name="l09950"></a><span class="lineno"> 9950</span> }</div><div class="line"><a name="l09951"></a><span class="lineno"> 9951</span> </div><div class="line"><a name="l09952"></a><span class="lineno"> 9952</span> Mutex::~Mutex() {</div><div class="line"><a name="l09953"></a><span class="lineno"> 9953</span>  <span class="comment">// Static mutexes are leaked intentionally. It is not thread-safe to try</span></div><div class="line"><a name="l09954"></a><span class="lineno"> 9954</span>  <span class="comment">// to clean them up.</span></div><div class="line"><a name="l09955"></a><span class="lineno"> 9955</span>  <span class="keywordflow">if</span> (type_ == kDynamic) {</div><div class="line"><a name="l09956"></a><span class="lineno"> 9956</span>  ::DeleteCriticalSection(critical_section_);</div><div class="line"><a name="l09957"></a><span class="lineno"> 9957</span>  <span class="keyword">delete</span> critical_section_;</div><div class="line"><a name="l09958"></a><span class="lineno"> 9958</span>  critical_section_ = <span class="keyword">nullptr</span>;</div><div class="line"><a name="l09959"></a><span class="lineno"> 9959</span>  }</div><div class="line"><a name="l09960"></a><span class="lineno"> 9960</span> }</div><div class="line"><a name="l09961"></a><span class="lineno"> 9961</span> </div><div class="line"><a name="l09962"></a><span class="lineno"> 9962</span> <span class="keywordtype">void</span> Mutex::Lock() {</div><div class="line"><a name="l09963"></a><span class="lineno"> 9963</span>  ThreadSafeLazyInit();</div><div class="line"><a name="l09964"></a><span class="lineno"> 9964</span>  ::EnterCriticalSection(critical_section_);</div><div class="line"><a name="l09965"></a><span class="lineno"> 9965</span>  owner_thread_id_ = ::GetCurrentThreadId();</div><div class="line"><a name="l09966"></a><span class="lineno"> 9966</span> }</div><div class="line"><a name="l09967"></a><span class="lineno"> 9967</span> </div><div class="line"><a name="l09968"></a><span class="lineno"> 9968</span> <span class="keywordtype">void</span> Mutex::Unlock() {</div><div class="line"><a name="l09969"></a><span class="lineno"> 9969</span>  ThreadSafeLazyInit();</div><div class="line"><a name="l09970"></a><span class="lineno"> 9970</span>  <span class="comment">// We don't protect writing to owner_thread_id_ here, as it's the</span></div><div class="line"><a name="l09971"></a><span class="lineno"> 9971</span>  <span class="comment">// caller's responsibility to ensure that the current thread holds the</span></div><div class="line"><a name="l09972"></a><span class="lineno"> 9972</span>  <span class="comment">// mutex when this is called.</span></div><div class="line"><a name="l09973"></a><span class="lineno"> 9973</span>  owner_thread_id_ = 0;</div><div class="line"><a name="l09974"></a><span class="lineno"> 9974</span>  ::LeaveCriticalSection(critical_section_);</div><div class="line"><a name="l09975"></a><span class="lineno"> 9975</span> }</div><div class="line"><a name="l09976"></a><span class="lineno"> 9976</span> </div><div class="line"><a name="l09977"></a><span class="lineno"> 9977</span> <span class="comment">// Does nothing if the current thread holds the mutex. Otherwise, crashes</span></div><div class="line"><a name="l09978"></a><span class="lineno"> 9978</span> <span class="comment">// with high probability.</span></div><div class="line"><a name="l09979"></a><span class="lineno"> 9979</span> <span class="keywordtype">void</span> Mutex::AssertHeld() {</div><div class="line"><a name="l09980"></a><span class="lineno"> 9980</span>  ThreadSafeLazyInit();</div><div class="line"><a name="l09981"></a><span class="lineno"> 9981</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(owner_thread_id_ == ::GetCurrentThreadId())</div><div class="line"><a name="l09982"></a><span class="lineno"> 9982</span>  << <span class="stringliteral">"The current thread is not holding the mutex @"</span> << <span class="keyword">this</span>;</div><div class="line"><a name="l09983"></a><span class="lineno"> 9983</span> }</div><div class="line"><a name="l09984"></a><span class="lineno"> 9984</span> </div><div class="line"><a name="l09985"></a><span class="lineno"> 9985</span> <span class="keyword">namespace </span>{</div><div class="line"><a name="l09986"></a><span class="lineno"> 9986</span> </div><div class="line"><a name="l09987"></a><span class="lineno"> 9987</span> <span class="comment">// Use the RAII idiom to flag mem allocs that are intentionally never</span></div><div class="line"><a name="l09988"></a><span class="lineno"> 9988</span> <span class="comment">// deallocated. The motivation is to silence the false positive mem leaks</span></div><div class="line"><a name="l09989"></a><span class="lineno"> 9989</span> <span class="comment">// that are reported by the debug version of MS's CRT which can only detect</span></div><div class="line"><a name="l09990"></a><span class="lineno"> 9990</span> <span class="comment">// if an alloc is missing a matching deallocation.</span></div><div class="line"><a name="l09991"></a><span class="lineno"> 9991</span> <span class="comment">// Example:</span></div><div class="line"><a name="l09992"></a><span class="lineno"> 9992</span> <span class="comment">// MemoryIsNotDeallocated memory_is_not_deallocated;</span></div><div class="line"><a name="l09993"></a><span class="lineno"> 9993</span> <span class="comment">// critical_section_ = new CRITICAL_SECTION;</span></div><div class="line"><a name="l09994"></a><span class="lineno"> 9994</span> <span class="comment">//</span></div><div class="line"><a name="l09995"></a><span class="lineno"> 9995</span> <span class="keyword">class </span>MemoryIsNotDeallocated</div><div class="line"><a name="l09996"></a><span class="lineno"> 9996</span> {</div><div class="line"><a name="l09997"></a><span class="lineno"> 9997</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l09998"></a><span class="lineno"> 9998</span>  MemoryIsNotDeallocated() : old_crtdbg_flag_(0) {</div><div class="line"><a name="l09999"></a><span class="lineno"> 9999</span> <span class="preprocessor">#ifdef _MSC_VER</span></div><div class="line"><a name="l10000"></a><span class="lineno">10000</span>  old_crtdbg_flag_ = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);</div><div class="line"><a name="l10001"></a><span class="lineno">10001</span>  <span class="comment">// Set heap allocation block type to _IGNORE_BLOCK so that MS debug CRT</span></div><div class="line"><a name="l10002"></a><span class="lineno">10002</span>  <span class="comment">// doesn't report mem leak if there's no matching deallocation.</span></div><div class="line"><a name="l10003"></a><span class="lineno">10003</span>  _CrtSetDbgFlag(old_crtdbg_flag_ & ~_CRTDBG_ALLOC_MEM_DF);</div><div class="line"><a name="l10004"></a><span class="lineno">10004</span> <span class="preprocessor">#endif // _MSC_VER</span></div><div class="line"><a name="l10005"></a><span class="lineno">10005</span>  }</div><div class="line"><a name="l10006"></a><span class="lineno">10006</span> </div><div class="line"><a name="l10007"></a><span class="lineno">10007</span>  ~MemoryIsNotDeallocated() {</div><div class="line"><a name="l10008"></a><span class="lineno">10008</span> <span class="preprocessor">#ifdef _MSC_VER</span></div><div class="line"><a name="l10009"></a><span class="lineno">10009</span>  <span class="comment">// Restore the original _CRTDBG_ALLOC_MEM_DF flag</span></div><div class="line"><a name="l10010"></a><span class="lineno">10010</span>  _CrtSetDbgFlag(old_crtdbg_flag_);</div><div class="line"><a name="l10011"></a><span class="lineno">10011</span> <span class="preprocessor">#endif // _MSC_VER</span></div><div class="line"><a name="l10012"></a><span class="lineno">10012</span>  }</div><div class="line"><a name="l10013"></a><span class="lineno">10013</span> </div><div class="line"><a name="l10014"></a><span class="lineno">10014</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l10015"></a><span class="lineno">10015</span>  <span class="keywordtype">int</span> old_crtdbg_flag_;</div><div class="line"><a name="l10016"></a><span class="lineno">10016</span> </div><div class="line"><a name="l10017"></a><span class="lineno">10017</span>  <a class="code" href="gtest_8h.html#aed8c1888c32b588b0681e88b95031e29">GTEST_DISALLOW_COPY_AND_ASSIGN_</a>(MemoryIsNotDeallocated);</div><div class="line"><a name="l10018"></a><span class="lineno">10018</span> };</div><div class="line"><a name="l10019"></a><span class="lineno">10019</span> </div><div class="line"><a name="l10020"></a><span class="lineno">10020</span> } <span class="comment">// namespace</span></div><div class="line"><a name="l10021"></a><span class="lineno">10021</span> </div><div class="line"><a name="l10022"></a><span class="lineno">10022</span> <span class="comment">// Initializes owner_thread_id_ and critical_section_ in static mutexes.</span></div><div class="line"><a name="l10023"></a><span class="lineno">10023</span> <span class="keywordtype">void</span> Mutex::ThreadSafeLazyInit() {</div><div class="line"><a name="l10024"></a><span class="lineno">10024</span>  <span class="comment">// Dynamic mutexes are initialized in the constructor.</span></div><div class="line"><a name="l10025"></a><span class="lineno">10025</span>  <span class="keywordflow">if</span> (type_ == kStatic) {</div><div class="line"><a name="l10026"></a><span class="lineno">10026</span>  <span class="keywordflow">switch</span> (</div><div class="line"><a name="l10027"></a><span class="lineno">10027</span>  ::InterlockedCompareExchange(&critical_section_init_phase_, 1L, 0L)) {</div><div class="line"><a name="l10028"></a><span class="lineno">10028</span>  <span class="keywordflow">case</span> 0:</div><div class="line"><a name="l10029"></a><span class="lineno">10029</span>  <span class="comment">// If critical_section_init_phase_ was 0 before the exchange, we</span></div><div class="line"><a name="l10030"></a><span class="lineno">10030</span>  <span class="comment">// are the first to test it and need to perform the initialization.</span></div><div class="line"><a name="l10031"></a><span class="lineno">10031</span>  owner_thread_id_ = 0;</div><div class="line"><a name="l10032"></a><span class="lineno">10032</span>  {</div><div class="line"><a name="l10033"></a><span class="lineno">10033</span>  <span class="comment">// Use RAII to flag that following mem alloc is never deallocated.</span></div><div class="line"><a name="l10034"></a><span class="lineno">10034</span>  MemoryIsNotDeallocated memory_is_not_deallocated;</div><div class="line"><a name="l10035"></a><span class="lineno">10035</span>  critical_section_ = <span class="keyword">new</span> CRITICAL_SECTION;</div><div class="line"><a name="l10036"></a><span class="lineno">10036</span>  }</div><div class="line"><a name="l10037"></a><span class="lineno">10037</span>  ::InitializeCriticalSection(critical_section_);</div><div class="line"><a name="l10038"></a><span class="lineno">10038</span>  <span class="comment">// Updates the critical_section_init_phase_ to 2 to signal</span></div><div class="line"><a name="l10039"></a><span class="lineno">10039</span>  <span class="comment">// initialization complete.</span></div><div class="line"><a name="l10040"></a><span class="lineno">10040</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(::InterlockedCompareExchange(</div><div class="line"><a name="l10041"></a><span class="lineno">10041</span>  &critical_section_init_phase_, 2L, 1L) ==</div><div class="line"><a name="l10042"></a><span class="lineno">10042</span>  1L);</div><div class="line"><a name="l10043"></a><span class="lineno">10043</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l10044"></a><span class="lineno">10044</span>  <span class="keywordflow">case</span> 1:</div><div class="line"><a name="l10045"></a><span class="lineno">10045</span>  <span class="comment">// Somebody else is already initializing the mutex; spin until they</span></div><div class="line"><a name="l10046"></a><span class="lineno">10046</span>  <span class="comment">// are done.</span></div><div class="line"><a name="l10047"></a><span class="lineno">10047</span>  <span class="keywordflow">while</span> (::InterlockedCompareExchange(&critical_section_init_phase_,</div><div class="line"><a name="l10048"></a><span class="lineno">10048</span>  2L,</div><div class="line"><a name="l10049"></a><span class="lineno">10049</span>  2L) != 2L) {</div><div class="line"><a name="l10050"></a><span class="lineno">10050</span>  <span class="comment">// Possibly yields the rest of the thread's time slice to other</span></div><div class="line"><a name="l10051"></a><span class="lineno">10051</span>  <span class="comment">// threads.</span></div><div class="line"><a name="l10052"></a><span class="lineno">10052</span>  ::Sleep(0);</div><div class="line"><a name="l10053"></a><span class="lineno">10053</span>  }</div><div class="line"><a name="l10054"></a><span class="lineno">10054</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l10055"></a><span class="lineno">10055</span> </div><div class="line"><a name="l10056"></a><span class="lineno">10056</span>  <span class="keywordflow">case</span> 2:</div><div class="line"><a name="l10057"></a><span class="lineno">10057</span>  <span class="keywordflow">break</span>; <span class="comment">// The mutex is already initialized and ready for use.</span></div><div class="line"><a name="l10058"></a><span class="lineno">10058</span> </div><div class="line"><a name="l10059"></a><span class="lineno">10059</span>  <span class="keywordflow">default</span>:</div><div class="line"><a name="l10060"></a><span class="lineno">10060</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(<span class="keyword">false</span>)</div><div class="line"><a name="l10061"></a><span class="lineno">10061</span>  << <span class="stringliteral">"Unexpected value of critical_section_init_phase_ "</span></div><div class="line"><a name="l10062"></a><span class="lineno">10062</span>  << <span class="stringliteral">"while initializing a static mutex."</span>;</div><div class="line"><a name="l10063"></a><span class="lineno">10063</span>  }</div><div class="line"><a name="l10064"></a><span class="lineno">10064</span>  }</div><div class="line"><a name="l10065"></a><span class="lineno">10065</span> }</div><div class="line"><a name="l10066"></a><span class="lineno">10066</span> </div><div class="line"><a name="l10067"></a><span class="lineno">10067</span> <span class="keyword">namespace </span>{</div><div class="line"><a name="l10068"></a><span class="lineno">10068</span> </div><div class="line"><a name="l10069"></a><span class="lineno">10069</span> <span class="keyword">class </span>ThreadWithParamSupport : <span class="keyword">public</span> ThreadWithParamBase {</div><div class="line"><a name="l10070"></a><span class="lineno">10070</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l10071"></a><span class="lineno">10071</span>  <span class="keyword">static</span> HANDLE CreateThread(Runnable* runnable,</div><div class="line"><a name="l10072"></a><span class="lineno">10072</span>  Notification* thread_can_start) {</div><div class="line"><a name="l10073"></a><span class="lineno">10073</span>  ThreadMainParam* param = <span class="keyword">new</span> ThreadMainParam(runnable, thread_can_start);</div><div class="line"><a name="l10074"></a><span class="lineno">10074</span>  DWORD thread_id;</div><div class="line"><a name="l10075"></a><span class="lineno">10075</span>  HANDLE thread_handle = ::CreateThread(</div><div class="line"><a name="l10076"></a><span class="lineno">10076</span>  <span class="keyword">nullptr</span>, <span class="comment">// Default security.</span></div><div class="line"><a name="l10077"></a><span class="lineno">10077</span>  0, <span class="comment">// Default stack size.</span></div><div class="line"><a name="l10078"></a><span class="lineno">10078</span>  &ThreadWithParamSupport::ThreadMain,</div><div class="line"><a name="l10079"></a><span class="lineno">10079</span>  param, <span class="comment">// Parameter to ThreadMainStatic</span></div><div class="line"><a name="l10080"></a><span class="lineno">10080</span>  0x0, <span class="comment">// Default creation flags.</span></div><div class="line"><a name="l10081"></a><span class="lineno">10081</span>  &thread_id); <span class="comment">// Need a valid pointer for the call to work under Win98.</span></div><div class="line"><a name="l10082"></a><span class="lineno">10082</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(thread_handle != <span class="keyword">nullptr</span>)</div><div class="line"><a name="l10083"></a><span class="lineno">10083</span>  << <span class="stringliteral">"CreateThread failed with error "</span> << ::GetLastError() << <span class="stringliteral">"."</span>;</div><div class="line"><a name="l10084"></a><span class="lineno">10084</span>  <span class="keywordflow">if</span> (thread_handle == <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l10085"></a><span class="lineno">10085</span>  <span class="keyword">delete</span> param;</div><div class="line"><a name="l10086"></a><span class="lineno">10086</span>  }</div><div class="line"><a name="l10087"></a><span class="lineno">10087</span>  <span class="keywordflow">return</span> thread_handle;</div><div class="line"><a name="l10088"></a><span class="lineno">10088</span>  }</div><div class="line"><a name="l10089"></a><span class="lineno">10089</span> </div><div class="line"><a name="l10090"></a><span class="lineno">10090</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l10091"></a><span class="lineno">10091</span>  <span class="keyword">struct </span>ThreadMainParam {</div><div class="line"><a name="l10092"></a><span class="lineno">10092</span>  ThreadMainParam(Runnable* runnable, Notification* thread_can_start)</div><div class="line"><a name="l10093"></a><span class="lineno">10093</span>  : runnable_(runnable),</div><div class="line"><a name="l10094"></a><span class="lineno">10094</span>  thread_can_start_(thread_can_start) {</div><div class="line"><a name="l10095"></a><span class="lineno">10095</span>  }</div><div class="line"><a name="l10096"></a><span class="lineno">10096</span>  std::unique_ptr<Runnable> runnable_;</div><div class="line"><a name="l10097"></a><span class="lineno">10097</span>  <span class="comment">// Does not own.</span></div><div class="line"><a name="l10098"></a><span class="lineno">10098</span>  Notification* thread_can_start_;</div><div class="line"><a name="l10099"></a><span class="lineno">10099</span>  };</div><div class="line"><a name="l10100"></a><span class="lineno">10100</span> </div><div class="line"><a name="l10101"></a><span class="lineno">10101</span>  <span class="keyword">static</span> DWORD WINAPI ThreadMain(<span class="keywordtype">void</span>* ptr) {</div><div class="line"><a name="l10102"></a><span class="lineno">10102</span>  <span class="comment">// Transfers ownership.</span></div><div class="line"><a name="l10103"></a><span class="lineno">10103</span>  std::unique_ptr<ThreadMainParam> param(static_cast<ThreadMainParam*>(ptr));</div><div class="line"><a name="l10104"></a><span class="lineno">10104</span>  <span class="keywordflow">if</span> (param->thread_can_start_ != <span class="keyword">nullptr</span>)</div><div class="line"><a name="l10105"></a><span class="lineno">10105</span>  param->thread_can_start_->WaitForNotification();</div><div class="line"><a name="l10106"></a><span class="lineno">10106</span>  param->runnable_->Run();</div><div class="line"><a name="l10107"></a><span class="lineno">10107</span>  <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l10108"></a><span class="lineno">10108</span>  }</div><div class="line"><a name="l10109"></a><span class="lineno">10109</span> </div><div class="line"><a name="l10110"></a><span class="lineno">10110</span>  <span class="comment">// Prohibit instantiation.</span></div><div class="line"><a name="l10111"></a><span class="lineno">10111</span>  ThreadWithParamSupport();</div><div class="line"><a name="l10112"></a><span class="lineno">10112</span> </div><div class="line"><a name="l10113"></a><span class="lineno">10113</span>  <a class="code" href="gtest_8h.html#aed8c1888c32b588b0681e88b95031e29">GTEST_DISALLOW_COPY_AND_ASSIGN_</a>(ThreadWithParamSupport);</div><div class="line"><a name="l10114"></a><span class="lineno">10114</span> };</div><div class="line"><a name="l10115"></a><span class="lineno">10115</span> </div><div class="line"><a name="l10116"></a><span class="lineno">10116</span> } <span class="comment">// namespace</span></div><div class="line"><a name="l10117"></a><span class="lineno">10117</span> </div><div class="line"><a name="l10118"></a><span class="lineno">10118</span> ThreadWithParamBase::ThreadWithParamBase(Runnable *runnable,</div><div class="line"><a name="l10119"></a><span class="lineno">10119</span>  Notification* thread_can_start)</div><div class="line"><a name="l10120"></a><span class="lineno">10120</span>  : thread_(ThreadWithParamSupport::CreateThread(runnable,</div><div class="line"><a name="l10121"></a><span class="lineno">10121</span>  thread_can_start)) {</div><div class="line"><a name="l10122"></a><span class="lineno">10122</span> }</div><div class="line"><a name="l10123"></a><span class="lineno">10123</span> </div><div class="line"><a name="l10124"></a><span class="lineno">10124</span> ThreadWithParamBase::~ThreadWithParamBase() {</div><div class="line"><a name="l10125"></a><span class="lineno">10125</span>  Join();</div><div class="line"><a name="l10126"></a><span class="lineno">10126</span> }</div><div class="line"><a name="l10127"></a><span class="lineno">10127</span> </div><div class="line"><a name="l10128"></a><span class="lineno">10128</span> <span class="keywordtype">void</span> ThreadWithParamBase::Join() {</div><div class="line"><a name="l10129"></a><span class="lineno">10129</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(::WaitForSingleObject(thread_.Get(), INFINITE) == WAIT_OBJECT_0)</div><div class="line"><a name="l10130"></a><span class="lineno">10130</span>  << <span class="stringliteral">"Failed to join the thread with error "</span> << ::GetLastError() << <span class="stringliteral">"."</span>;</div><div class="line"><a name="l10131"></a><span class="lineno">10131</span> }</div><div class="line"><a name="l10132"></a><span class="lineno">10132</span> </div><div class="line"><a name="l10133"></a><span class="lineno">10133</span> <span class="comment">// Maps a thread to a set of ThreadIdToThreadLocals that have values</span></div><div class="line"><a name="l10134"></a><span class="lineno">10134</span> <span class="comment">// instantiated on that thread and notifies them when the thread exits. A</span></div><div class="line"><a name="l10135"></a><span class="lineno">10135</span> <span class="comment">// ThreadLocal instance is expected to persist until all threads it has</span></div><div class="line"><a name="l10136"></a><span class="lineno">10136</span> <span class="comment">// values on have terminated.</span></div><div class="line"><a name="l10137"></a><span class="lineno">10137</span> <span class="keyword">class </span>ThreadLocalRegistryImpl {</div><div class="line"><a name="l10138"></a><span class="lineno">10138</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l10139"></a><span class="lineno">10139</span>  <span class="comment">// Registers thread_local_instance as having value on the current thread.</span></div><div class="line"><a name="l10140"></a><span class="lineno">10140</span>  <span class="comment">// Returns a value that can be used to identify the thread from other threads.</span></div><div class="line"><a name="l10141"></a><span class="lineno">10141</span>  <span class="keyword">static</span> ThreadLocalValueHolderBase* GetValueOnCurrentThread(</div><div class="line"><a name="l10142"></a><span class="lineno">10142</span>  <span class="keyword">const</span> ThreadLocalBase* thread_local_instance) {</div><div class="line"><a name="l10143"></a><span class="lineno">10143</span>  DWORD current_thread = ::GetCurrentThreadId();</div><div class="line"><a name="l10144"></a><span class="lineno">10144</span>  <a class="code" href="namespacetesting_1_1internal.html#a08b187c6cc4e28400aadf9a32fccc8de">MutexLock</a> lock(&mutex_);</div><div class="line"><a name="l10145"></a><span class="lineno">10145</span>  ThreadIdToThreadLocals* <span class="keyword">const</span> thread_to_thread_locals =</div><div class="line"><a name="l10146"></a><span class="lineno">10146</span>  GetThreadLocalsMapLocked();</div><div class="line"><a name="l10147"></a><span class="lineno">10147</span>  ThreadIdToThreadLocals::iterator thread_local_pos =</div><div class="line"><a name="l10148"></a><span class="lineno">10148</span>  thread_to_thread_locals->find(current_thread);</div><div class="line"><a name="l10149"></a><span class="lineno">10149</span>  <span class="keywordflow">if</span> (thread_local_pos == thread_to_thread_locals->end()) {</div><div class="line"><a name="l10150"></a><span class="lineno">10150</span>  thread_local_pos = thread_to_thread_locals->insert(</div><div class="line"><a name="l10151"></a><span class="lineno">10151</span>  std::make_pair(current_thread, ThreadLocalValues())).first;</div><div class="line"><a name="l10152"></a><span class="lineno">10152</span>  StartWatcherThreadFor(current_thread);</div><div class="line"><a name="l10153"></a><span class="lineno">10153</span>  }</div><div class="line"><a name="l10154"></a><span class="lineno">10154</span>  ThreadLocalValues& thread_local_values = thread_local_pos->second;</div><div class="line"><a name="l10155"></a><span class="lineno">10155</span>  ThreadLocalValues::iterator value_pos =</div><div class="line"><a name="l10156"></a><span class="lineno">10156</span>  thread_local_values.find(thread_local_instance);</div><div class="line"><a name="l10157"></a><span class="lineno">10157</span>  <span class="keywordflow">if</span> (value_pos == thread_local_values.end()) {</div><div class="line"><a name="l10158"></a><span class="lineno">10158</span>  value_pos =</div><div class="line"><a name="l10159"></a><span class="lineno">10159</span>  thread_local_values</div><div class="line"><a name="l10160"></a><span class="lineno">10160</span>  .insert(std::make_pair(</div><div class="line"><a name="l10161"></a><span class="lineno">10161</span>  thread_local_instance,</div><div class="line"><a name="l10162"></a><span class="lineno">10162</span>  std::shared_ptr<ThreadLocalValueHolderBase>(</div><div class="line"><a name="l10163"></a><span class="lineno">10163</span>  thread_local_instance->NewValueForCurrentThread())))</div><div class="line"><a name="l10164"></a><span class="lineno">10164</span>  .first;</div><div class="line"><a name="l10165"></a><span class="lineno">10165</span>  }</div><div class="line"><a name="l10166"></a><span class="lineno">10166</span>  <span class="keywordflow">return</span> value_pos->second.get();</div><div class="line"><a name="l10167"></a><span class="lineno">10167</span>  }</div><div class="line"><a name="l10168"></a><span class="lineno">10168</span> </div><div class="line"><a name="l10169"></a><span class="lineno">10169</span>  <span class="keyword">static</span> <span class="keywordtype">void</span> OnThreadLocalDestroyed(</div><div class="line"><a name="l10170"></a><span class="lineno">10170</span>  <span class="keyword">const</span> ThreadLocalBase* thread_local_instance) {</div><div class="line"><a name="l10171"></a><span class="lineno">10171</span>  std::vector<std::shared_ptr<ThreadLocalValueHolderBase> > value_holders;</div><div class="line"><a name="l10172"></a><span class="lineno">10172</span>  <span class="comment">// Clean up the ThreadLocalValues data structure while holding the lock, but</span></div><div class="line"><a name="l10173"></a><span class="lineno">10173</span>  <span class="comment">// defer the destruction of the ThreadLocalValueHolderBases.</span></div><div class="line"><a name="l10174"></a><span class="lineno">10174</span>  {</div><div class="line"><a name="l10175"></a><span class="lineno">10175</span>  <a class="code" href="namespacetesting_1_1internal.html#a08b187c6cc4e28400aadf9a32fccc8de">MutexLock</a> lock(&mutex_);</div><div class="line"><a name="l10176"></a><span class="lineno">10176</span>  ThreadIdToThreadLocals* <span class="keyword">const</span> thread_to_thread_locals =</div><div class="line"><a name="l10177"></a><span class="lineno">10177</span>  GetThreadLocalsMapLocked();</div><div class="line"><a name="l10178"></a><span class="lineno">10178</span>  <span class="keywordflow">for</span> (ThreadIdToThreadLocals::iterator it =</div><div class="line"><a name="l10179"></a><span class="lineno">10179</span>  thread_to_thread_locals->begin();</div><div class="line"><a name="l10180"></a><span class="lineno">10180</span>  it != thread_to_thread_locals->end();</div><div class="line"><a name="l10181"></a><span class="lineno">10181</span>  ++it) {</div><div class="line"><a name="l10182"></a><span class="lineno">10182</span>  ThreadLocalValues& thread_local_values = it->second;</div><div class="line"><a name="l10183"></a><span class="lineno">10183</span>  ThreadLocalValues::iterator value_pos =</div><div class="line"><a name="l10184"></a><span class="lineno">10184</span>  thread_local_values.find(thread_local_instance);</div><div class="line"><a name="l10185"></a><span class="lineno">10185</span>  <span class="keywordflow">if</span> (value_pos != thread_local_values.end()) {</div><div class="line"><a name="l10186"></a><span class="lineno">10186</span>  value_holders.push_back(value_pos->second);</div><div class="line"><a name="l10187"></a><span class="lineno">10187</span>  thread_local_values.erase(value_pos);</div><div class="line"><a name="l10188"></a><span class="lineno">10188</span>  <span class="comment">// This 'if' can only be successful at most once, so theoretically we</span></div><div class="line"><a name="l10189"></a><span class="lineno">10189</span>  <span class="comment">// could break out of the loop here, but we don't bother doing so.</span></div><div class="line"><a name="l10190"></a><span class="lineno">10190</span>  }</div><div class="line"><a name="l10191"></a><span class="lineno">10191</span>  }</div><div class="line"><a name="l10192"></a><span class="lineno">10192</span>  }</div><div class="line"><a name="l10193"></a><span class="lineno">10193</span>  <span class="comment">// Outside the lock, let the destructor for 'value_holders' deallocate the</span></div><div class="line"><a name="l10194"></a><span class="lineno">10194</span>  <span class="comment">// ThreadLocalValueHolderBases.</span></div><div class="line"><a name="l10195"></a><span class="lineno">10195</span>  }</div><div class="line"><a name="l10196"></a><span class="lineno">10196</span> </div><div class="line"><a name="l10197"></a><span class="lineno">10197</span>  <span class="keyword">static</span> <span class="keywordtype">void</span> OnThreadExit(DWORD thread_id) {</div><div class="line"><a name="l10198"></a><span class="lineno">10198</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(thread_id != 0) << ::GetLastError();</div><div class="line"><a name="l10199"></a><span class="lineno">10199</span>  std::vector<std::shared_ptr<ThreadLocalValueHolderBase> > value_holders;</div><div class="line"><a name="l10200"></a><span class="lineno">10200</span>  <span class="comment">// Clean up the ThreadIdToThreadLocals data structure while holding the</span></div><div class="line"><a name="l10201"></a><span class="lineno">10201</span>  <span class="comment">// lock, but defer the destruction of the ThreadLocalValueHolderBases.</span></div><div class="line"><a name="l10202"></a><span class="lineno">10202</span>  {</div><div class="line"><a name="l10203"></a><span class="lineno">10203</span>  <a class="code" href="namespacetesting_1_1internal.html#a08b187c6cc4e28400aadf9a32fccc8de">MutexLock</a> lock(&mutex_);</div><div class="line"><a name="l10204"></a><span class="lineno">10204</span>  ThreadIdToThreadLocals* <span class="keyword">const</span> thread_to_thread_locals =</div><div class="line"><a name="l10205"></a><span class="lineno">10205</span>  GetThreadLocalsMapLocked();</div><div class="line"><a name="l10206"></a><span class="lineno">10206</span>  ThreadIdToThreadLocals::iterator thread_local_pos =</div><div class="line"><a name="l10207"></a><span class="lineno">10207</span>  thread_to_thread_locals->find(thread_id);</div><div class="line"><a name="l10208"></a><span class="lineno">10208</span>  <span class="keywordflow">if</span> (thread_local_pos != thread_to_thread_locals->end()) {</div><div class="line"><a name="l10209"></a><span class="lineno">10209</span>  ThreadLocalValues& thread_local_values = thread_local_pos->second;</div><div class="line"><a name="l10210"></a><span class="lineno">10210</span>  <span class="keywordflow">for</span> (ThreadLocalValues::iterator value_pos =</div><div class="line"><a name="l10211"></a><span class="lineno">10211</span>  thread_local_values.begin();</div><div class="line"><a name="l10212"></a><span class="lineno">10212</span>  value_pos != thread_local_values.end();</div><div class="line"><a name="l10213"></a><span class="lineno">10213</span>  ++value_pos) {</div><div class="line"><a name="l10214"></a><span class="lineno">10214</span>  value_holders.push_back(value_pos->second);</div><div class="line"><a name="l10215"></a><span class="lineno">10215</span>  }</div><div class="line"><a name="l10216"></a><span class="lineno">10216</span>  thread_to_thread_locals->erase(thread_local_pos);</div><div class="line"><a name="l10217"></a><span class="lineno">10217</span>  }</div><div class="line"><a name="l10218"></a><span class="lineno">10218</span>  }</div><div class="line"><a name="l10219"></a><span class="lineno">10219</span>  <span class="comment">// Outside the lock, let the destructor for 'value_holders' deallocate the</span></div><div class="line"><a name="l10220"></a><span class="lineno">10220</span>  <span class="comment">// ThreadLocalValueHolderBases.</span></div><div class="line"><a name="l10221"></a><span class="lineno">10221</span>  }</div><div class="line"><a name="l10222"></a><span class="lineno">10222</span> </div><div class="line"><a name="l10223"></a><span class="lineno">10223</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l10224"></a><span class="lineno">10224</span>  <span class="comment">// In a particular thread, maps a ThreadLocal object to its value.</span></div><div class="line"><a name="l10225"></a><span class="lineno">10225</span>  <span class="keyword">typedef</span> std::map<<span class="keyword">const</span> ThreadLocalBase*,</div><div class="line"><a name="l10226"></a><span class="lineno">10226</span>  std::shared_ptr<ThreadLocalValueHolderBase> ></div><div class="line"><a name="l10227"></a><span class="lineno">10227</span>  ThreadLocalValues;</div><div class="line"><a name="l10228"></a><span class="lineno">10228</span>  <span class="comment">// Stores all ThreadIdToThreadLocals having values in a thread, indexed by</span></div><div class="line"><a name="l10229"></a><span class="lineno">10229</span>  <span class="comment">// thread's ID.</span></div><div class="line"><a name="l10230"></a><span class="lineno">10230</span>  <span class="keyword">typedef</span> std::map<DWORD, ThreadLocalValues> ThreadIdToThreadLocals;</div><div class="line"><a name="l10231"></a><span class="lineno">10231</span> </div><div class="line"><a name="l10232"></a><span class="lineno">10232</span>  <span class="comment">// Holds the thread id and thread handle that we pass from</span></div><div class="line"><a name="l10233"></a><span class="lineno">10233</span>  <span class="comment">// StartWatcherThreadFor to WatcherThreadFunc.</span></div><div class="line"><a name="l10234"></a><span class="lineno">10234</span>  <span class="keyword">typedef</span> std::pair<DWORD, HANDLE> ThreadIdAndHandle;</div><div class="line"><a name="l10235"></a><span class="lineno">10235</span> </div><div class="line"><a name="l10236"></a><span class="lineno">10236</span>  <span class="keyword">static</span> <span class="keywordtype">void</span> StartWatcherThreadFor(DWORD thread_id) {</div><div class="line"><a name="l10237"></a><span class="lineno">10237</span>  <span class="comment">// The returned handle will be kept in thread_map and closed by</span></div><div class="line"><a name="l10238"></a><span class="lineno">10238</span>  <span class="comment">// watcher_thread in WatcherThreadFunc.</span></div><div class="line"><a name="l10239"></a><span class="lineno">10239</span>  HANDLE thread = ::OpenThread(SYNCHRONIZE | THREAD_QUERY_INFORMATION,</div><div class="line"><a name="l10240"></a><span class="lineno">10240</span>  FALSE,</div><div class="line"><a name="l10241"></a><span class="lineno">10241</span>  thread_id);</div><div class="line"><a name="l10242"></a><span class="lineno">10242</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(thread != <span class="keyword">nullptr</span>);</div><div class="line"><a name="l10243"></a><span class="lineno">10243</span>  <span class="comment">// We need to pass a valid thread ID pointer into CreateThread for it</span></div><div class="line"><a name="l10244"></a><span class="lineno">10244</span>  <span class="comment">// to work correctly under Win98.</span></div><div class="line"><a name="l10245"></a><span class="lineno">10245</span>  DWORD watcher_thread_id;</div><div class="line"><a name="l10246"></a><span class="lineno">10246</span>  HANDLE watcher_thread = ::CreateThread(</div><div class="line"><a name="l10247"></a><span class="lineno">10247</span>  <span class="keyword">nullptr</span>, <span class="comment">// Default security.</span></div><div class="line"><a name="l10248"></a><span class="lineno">10248</span>  0, <span class="comment">// Default stack size</span></div><div class="line"><a name="l10249"></a><span class="lineno">10249</span>  &ThreadLocalRegistryImpl::WatcherThreadFunc,</div><div class="line"><a name="l10250"></a><span class="lineno">10250</span>  reinterpret_cast<LPVOID>(<span class="keyword">new</span> ThreadIdAndHandle(thread_id, thread)),</div><div class="line"><a name="l10251"></a><span class="lineno">10251</span>  CREATE_SUSPENDED, &watcher_thread_id);</div><div class="line"><a name="l10252"></a><span class="lineno">10252</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(watcher_thread != <span class="keyword">nullptr</span>);</div><div class="line"><a name="l10253"></a><span class="lineno">10253</span>  <span class="comment">// Give the watcher thread the same priority as ours to avoid being</span></div><div class="line"><a name="l10254"></a><span class="lineno">10254</span>  <span class="comment">// blocked by it.</span></div><div class="line"><a name="l10255"></a><span class="lineno">10255</span>  ::SetThreadPriority(watcher_thread,</div><div class="line"><a name="l10256"></a><span class="lineno">10256</span>  ::GetThreadPriority(::GetCurrentThread()));</div><div class="line"><a name="l10257"></a><span class="lineno">10257</span>  ::ResumeThread(watcher_thread);</div><div class="line"><a name="l10258"></a><span class="lineno">10258</span>  ::CloseHandle(watcher_thread);</div><div class="line"><a name="l10259"></a><span class="lineno">10259</span>  }</div><div class="line"><a name="l10260"></a><span class="lineno">10260</span> </div><div class="line"><a name="l10261"></a><span class="lineno">10261</span>  <span class="comment">// Monitors exit from a given thread and notifies those</span></div><div class="line"><a name="l10262"></a><span class="lineno">10262</span>  <span class="comment">// ThreadIdToThreadLocals about thread termination.</span></div><div class="line"><a name="l10263"></a><span class="lineno">10263</span>  <span class="keyword">static</span> DWORD WINAPI WatcherThreadFunc(LPVOID param) {</div><div class="line"><a name="l10264"></a><span class="lineno">10264</span>  <span class="keyword">const</span> ThreadIdAndHandle* tah =</div><div class="line"><a name="l10265"></a><span class="lineno">10265</span>  <span class="keyword">reinterpret_cast<</span><span class="keyword">const </span>ThreadIdAndHandle*<span class="keyword">></span>(param);</div><div class="line"><a name="l10266"></a><span class="lineno">10266</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(</div><div class="line"><a name="l10267"></a><span class="lineno">10267</span>  ::WaitForSingleObject(tah->second, INFINITE) == WAIT_OBJECT_0);</div><div class="line"><a name="l10268"></a><span class="lineno">10268</span>  OnThreadExit(tah->first);</div><div class="line"><a name="l10269"></a><span class="lineno">10269</span>  ::CloseHandle(tah->second);</div><div class="line"><a name="l10270"></a><span class="lineno">10270</span>  <span class="keyword">delete</span> tah;</div><div class="line"><a name="l10271"></a><span class="lineno">10271</span>  <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l10272"></a><span class="lineno">10272</span>  }</div><div class="line"><a name="l10273"></a><span class="lineno">10273</span> </div><div class="line"><a name="l10274"></a><span class="lineno">10274</span>  <span class="comment">// Returns map of thread local instances.</span></div><div class="line"><a name="l10275"></a><span class="lineno">10275</span>  <span class="keyword">static</span> ThreadIdToThreadLocals* GetThreadLocalsMapLocked() {</div><div class="line"><a name="l10276"></a><span class="lineno">10276</span>  mutex_.AssertHeld();</div><div class="line"><a name="l10277"></a><span class="lineno">10277</span>  MemoryIsNotDeallocated memory_is_not_deallocated;</div><div class="line"><a name="l10278"></a><span class="lineno">10278</span>  <span class="keyword">static</span> ThreadIdToThreadLocals* map = <span class="keyword">new</span> ThreadIdToThreadLocals();</div><div class="line"><a name="l10279"></a><span class="lineno">10279</span>  <span class="keywordflow">return</span> map;</div><div class="line"><a name="l10280"></a><span class="lineno">10280</span>  }</div><div class="line"><a name="l10281"></a><span class="lineno">10281</span> </div><div class="line"><a name="l10282"></a><span class="lineno">10282</span>  <span class="comment">// Protects access to GetThreadLocalsMapLocked() and its return value.</span></div><div class="line"><a name="l10283"></a><span class="lineno">10283</span>  <span class="keyword">static</span> Mutex mutex_;</div><div class="line"><a name="l10284"></a><span class="lineno">10284</span>  <span class="comment">// Protects access to GetThreadMapLocked() and its return value.</span></div><div class="line"><a name="l10285"></a><span class="lineno">10285</span>  <span class="keyword">static</span> Mutex thread_map_mutex_;</div><div class="line"><a name="l10286"></a><span class="lineno">10286</span> };</div><div class="line"><a name="l10287"></a><span class="lineno">10287</span> </div><div class="line"><a name="l10288"></a><span class="lineno">10288</span> Mutex ThreadLocalRegistryImpl::mutex_(Mutex::kStaticMutex);</div><div class="line"><a name="l10289"></a><span class="lineno">10289</span> Mutex ThreadLocalRegistryImpl::thread_map_mutex_(Mutex::kStaticMutex);</div><div class="line"><a name="l10290"></a><span class="lineno">10290</span> </div><div class="line"><a name="l10291"></a><span class="lineno">10291</span> ThreadLocalValueHolderBase* ThreadLocalRegistry::GetValueOnCurrentThread(</div><div class="line"><a name="l10292"></a><span class="lineno">10292</span>  <span class="keyword">const</span> ThreadLocalBase* thread_local_instance) {</div><div class="line"><a name="l10293"></a><span class="lineno">10293</span>  <span class="keywordflow">return</span> ThreadLocalRegistryImpl::GetValueOnCurrentThread(</div><div class="line"><a name="l10294"></a><span class="lineno">10294</span>  thread_local_instance);</div><div class="line"><a name="l10295"></a><span class="lineno">10295</span> }</div><div class="line"><a name="l10296"></a><span class="lineno">10296</span> </div><div class="line"><a name="l10297"></a><span class="lineno">10297</span> <span class="keywordtype">void</span> ThreadLocalRegistry::OnThreadLocalDestroyed(</div><div class="line"><a name="l10298"></a><span class="lineno">10298</span>  <span class="keyword">const</span> ThreadLocalBase* thread_local_instance) {</div><div class="line"><a name="l10299"></a><span class="lineno">10299</span>  ThreadLocalRegistryImpl::OnThreadLocalDestroyed(thread_local_instance);</div><div class="line"><a name="l10300"></a><span class="lineno">10300</span> }</div><div class="line"><a name="l10301"></a><span class="lineno">10301</span> </div><div class="line"><a name="l10302"></a><span class="lineno">10302</span> <span class="preprocessor">#endif // GTEST_IS_THREADSAFE && GTEST_OS_WINDOWS</span></div><div class="line"><a name="l10303"></a><span class="lineno">10303</span> </div><div class="line"><a name="l10304"></a><span class="lineno">10304</span> <span class="preprocessor">#if GTEST_USES_POSIX_RE</span></div><div class="line"><a name="l10305"></a><span class="lineno">10305</span> </div><div class="line"><a name="l10306"></a><span class="lineno">10306</span> <span class="comment">// Implements RE. Currently only needed for death tests.</span></div><div class="line"><a name="l10307"></a><span class="lineno">10307</span> </div><div class="line"><a name="l10308"></a><span class="lineno"><a class="line" href="classtesting_1_1internal_1_1_r_e.html#af3ad18e6c0b433f3d85ed23eda8119f3">10308</a></span> RE::~RE() {</div><div class="line"><a name="l10309"></a><span class="lineno">10309</span>  <span class="keywordflow">if</span> (is_valid_) {</div><div class="line"><a name="l10310"></a><span class="lineno">10310</span>  <span class="comment">// regfree'ing an invalid regex might crash because the content</span></div><div class="line"><a name="l10311"></a><span class="lineno">10311</span>  <span class="comment">// of the regex is undefined. Since the regex's are essentially</span></div><div class="line"><a name="l10312"></a><span class="lineno">10312</span>  <span class="comment">// the same, one cannot be valid (or invalid) without the other</span></div><div class="line"><a name="l10313"></a><span class="lineno">10313</span>  <span class="comment">// being so too.</span></div><div class="line"><a name="l10314"></a><span class="lineno">10314</span>  regfree(&partial_regex_);</div><div class="line"><a name="l10315"></a><span class="lineno">10315</span>  regfree(&full_regex_);</div><div class="line"><a name="l10316"></a><span class="lineno">10316</span>  }</div><div class="line"><a name="l10317"></a><span class="lineno">10317</span>  free(const_cast<char*>(pattern_));</div><div class="line"><a name="l10318"></a><span class="lineno">10318</span> }</div><div class="line"><a name="l10319"></a><span class="lineno">10319</span> </div><div class="line"><a name="l10320"></a><span class="lineno">10320</span> <span class="comment">// Returns true iff regular expression re matches the entire str.</span></div><div class="line"><a name="l10321"></a><span class="lineno"><a class="line" href="classtesting_1_1internal_1_1_r_e.html#a0892b449d80184a7074276377401895e">10321</a></span> <span class="keywordtype">bool</span> RE::FullMatch(<span class="keyword">const</span> <span class="keywordtype">char</span>* str, <span class="keyword">const</span> <a class="code" href="classtesting_1_1internal_1_1_r_e.html">RE</a>& re) {</div><div class="line"><a name="l10322"></a><span class="lineno">10322</span>  <span class="keywordflow">if</span> (!re.is_valid_) <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l10323"></a><span class="lineno">10323</span> </div><div class="line"><a name="l10324"></a><span class="lineno">10324</span>  regmatch_t match;</div><div class="line"><a name="l10325"></a><span class="lineno">10325</span>  <span class="keywordflow">return</span> regexec(&re.full_regex_, str, 1, &match, 0) == 0;</div><div class="line"><a name="l10326"></a><span class="lineno">10326</span> }</div><div class="line"><a name="l10327"></a><span class="lineno">10327</span> </div><div class="line"><a name="l10328"></a><span class="lineno">10328</span> <span class="comment">// Returns true iff regular expression re matches a substring of str</span></div><div class="line"><a name="l10329"></a><span class="lineno">10329</span> <span class="comment">// (including str itself).</span></div><div class="line"><a name="l10330"></a><span class="lineno"><a class="line" href="classtesting_1_1internal_1_1_r_e.html#ab6b3d18a28c44d3ff9f42840d1fa8d00">10330</a></span> <span class="keywordtype">bool</span> RE::PartialMatch(<span class="keyword">const</span> <span class="keywordtype">char</span>* str, <span class="keyword">const</span> <a class="code" href="classtesting_1_1internal_1_1_r_e.html">RE</a>& re) {</div><div class="line"><a name="l10331"></a><span class="lineno">10331</span>  <span class="keywordflow">if</span> (!re.is_valid_) <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l10332"></a><span class="lineno">10332</span> </div><div class="line"><a name="l10333"></a><span class="lineno">10333</span>  regmatch_t match;</div><div class="line"><a name="l10334"></a><span class="lineno">10334</span>  <span class="keywordflow">return</span> regexec(&re.partial_regex_, str, 1, &match, 0) == 0;</div><div class="line"><a name="l10335"></a><span class="lineno">10335</span> }</div><div class="line"><a name="l10336"></a><span class="lineno">10336</span> </div><div class="line"><a name="l10337"></a><span class="lineno">10337</span> <span class="comment">// Initializes an RE from its string representation.</span></div><div class="line"><a name="l10338"></a><span class="lineno">10338</span> <span class="keywordtype">void</span> RE::Init(<span class="keyword">const</span> <span class="keywordtype">char</span>* regex) {</div><div class="line"><a name="l10339"></a><span class="lineno">10339</span>  pattern_ = <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a8e352884793a65ae8be144676f1a9136">posix::StrDup</a>(regex);</div><div class="line"><a name="l10340"></a><span class="lineno">10340</span> </div><div class="line"><a name="l10341"></a><span class="lineno">10341</span>  <span class="comment">// Reserves enough bytes to hold the regular expression used for a</span></div><div class="line"><a name="l10342"></a><span class="lineno">10342</span>  <span class="comment">// full match.</span></div><div class="line"><a name="l10343"></a><span class="lineno">10343</span>  <span class="keyword">const</span> <span class="keywordtype">size_t</span> full_regex_len = strlen(regex) + 10;</div><div class="line"><a name="l10344"></a><span class="lineno">10344</span>  <span class="keywordtype">char</span>* <span class="keyword">const</span> full_pattern = <span class="keyword">new</span> <span class="keywordtype">char</span>[full_regex_len];</div><div class="line"><a name="l10345"></a><span class="lineno">10345</span> </div><div class="line"><a name="l10346"></a><span class="lineno">10346</span>  snprintf(full_pattern, full_regex_len, <span class="stringliteral">"^(%s)$"</span>, regex);</div><div class="line"><a name="l10347"></a><span class="lineno">10347</span>  is_valid_ = regcomp(&full_regex_, full_pattern, REG_EXTENDED) == 0;</div><div class="line"><a name="l10348"></a><span class="lineno">10348</span>  <span class="comment">// We want to call regcomp(&partial_regex_, ...) even if the</span></div><div class="line"><a name="l10349"></a><span class="lineno">10349</span>  <span class="comment">// previous expression returns false. Otherwise partial_regex_ may</span></div><div class="line"><a name="l10350"></a><span class="lineno">10350</span>  <span class="comment">// not be properly initialized can may cause trouble when it's</span></div><div class="line"><a name="l10351"></a><span class="lineno">10351</span>  <span class="comment">// freed.</span></div><div class="line"><a name="l10352"></a><span class="lineno">10352</span>  <span class="comment">//</span></div><div class="line"><a name="l10353"></a><span class="lineno">10353</span>  <span class="comment">// Some implementation of POSIX regex (e.g. on at least some</span></div><div class="line"><a name="l10354"></a><span class="lineno">10354</span>  <span class="comment">// versions of Cygwin) doesn't accept the empty string as a valid</span></div><div class="line"><a name="l10355"></a><span class="lineno">10355</span>  <span class="comment">// regex. We change it to an equivalent form "()" to be safe.</span></div><div class="line"><a name="l10356"></a><span class="lineno">10356</span>  <span class="keywordflow">if</span> (is_valid_) {</div><div class="line"><a name="l10357"></a><span class="lineno">10357</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> partial_regex = (*regex == <span class="charliteral">'\0'</span>) ? <span class="stringliteral">"()"</span> : regex;</div><div class="line"><a name="l10358"></a><span class="lineno">10358</span>  is_valid_ = regcomp(&partial_regex_, partial_regex, REG_EXTENDED) == 0;</div><div class="line"><a name="l10359"></a><span class="lineno">10359</span>  }</div><div class="line"><a name="l10360"></a><span class="lineno">10360</span>  <a class="code" href="gtest_8h.html#ac33e7cdfb5d44a7a0f0ab552eb5c3c6a">EXPECT_TRUE</a>(is_valid_)</div><div class="line"><a name="l10361"></a><span class="lineno">10361</span>  << <span class="stringliteral">"Regular expression \""</span> << regex</div><div class="line"><a name="l10362"></a><span class="lineno">10362</span>  << <span class="stringliteral">"\" is not a valid POSIX Extended regular expression."</span>;</div><div class="line"><a name="l10363"></a><span class="lineno">10363</span> </div><div class="line"><a name="l10364"></a><span class="lineno">10364</span>  <span class="keyword">delete</span>[] full_pattern;</div><div class="line"><a name="l10365"></a><span class="lineno">10365</span> }</div><div class="line"><a name="l10366"></a><span class="lineno">10366</span> </div><div class="line"><a name="l10367"></a><span class="lineno">10367</span> <span class="preprocessor">#elif GTEST_USES_SIMPLE_RE</span></div><div class="line"><a name="l10368"></a><span class="lineno">10368</span> </div><div class="line"><a name="l10369"></a><span class="lineno">10369</span> <span class="comment">// Returns true iff ch appears anywhere in str (excluding the</span></div><div class="line"><a name="l10370"></a><span class="lineno">10370</span> <span class="comment">// terminating '\0' character).</span></div><div class="line"><a name="l10371"></a><span class="lineno">10371</span> <span class="keywordtype">bool</span> IsInSet(<span class="keywordtype">char</span> ch, <span class="keyword">const</span> <span class="keywordtype">char</span>* str) {</div><div class="line"><a name="l10372"></a><span class="lineno">10372</span>  <span class="keywordflow">return</span> ch != <span class="charliteral">'\0'</span> && strchr(str, ch) != <span class="keyword">nullptr</span>;</div><div class="line"><a name="l10373"></a><span class="lineno">10373</span> }</div><div class="line"><a name="l10374"></a><span class="lineno">10374</span> </div><div class="line"><a name="l10375"></a><span class="lineno">10375</span> <span class="comment">// Returns true iff ch belongs to the given classification. Unlike</span></div><div class="line"><a name="l10376"></a><span class="lineno">10376</span> <span class="comment">// similar functions in <ctype.h>, these aren't affected by the</span></div><div class="line"><a name="l10377"></a><span class="lineno">10377</span> <span class="comment">// current locale.</span></div><div class="line"><a name="l10378"></a><span class="lineno">10378</span> <span class="keywordtype">bool</span> IsAsciiDigit(<span class="keywordtype">char</span> ch) { <span class="keywordflow">return</span> <span class="charliteral">'0'</span> <= ch && ch <= <span class="charliteral">'9'</span>; }</div><div class="line"><a name="l10379"></a><span class="lineno">10379</span> <span class="keywordtype">bool</span> IsAsciiPunct(<span class="keywordtype">char</span> ch) {</div><div class="line"><a name="l10380"></a><span class="lineno">10380</span>  <span class="keywordflow">return</span> IsInSet(ch, <span class="stringliteral">"^-!\"#$%&'()*+,./:;<=>?@[\\]_`{|}~"</span>);</div><div class="line"><a name="l10381"></a><span class="lineno">10381</span> }</div><div class="line"><a name="l10382"></a><span class="lineno">10382</span> <span class="keywordtype">bool</span> IsRepeat(<span class="keywordtype">char</span> ch) { <span class="keywordflow">return</span> IsInSet(ch, <span class="stringliteral">"?*+"</span>); }</div><div class="line"><a name="l10383"></a><span class="lineno">10383</span> <span class="keywordtype">bool</span> IsAsciiWhiteSpace(<span class="keywordtype">char</span> ch) { <span class="keywordflow">return</span> IsInSet(ch, <span class="stringliteral">" \f\n\r\t\v"</span>); }</div><div class="line"><a name="l10384"></a><span class="lineno">10384</span> <span class="keywordtype">bool</span> IsAsciiWordChar(<span class="keywordtype">char</span> ch) {</div><div class="line"><a name="l10385"></a><span class="lineno">10385</span>  <span class="keywordflow">return</span> (<span class="charliteral">'a'</span> <= ch && ch <= <span class="charliteral">'z'</span>) || (<span class="charliteral">'A'</span> <= ch && ch <= <span class="charliteral">'Z'</span>) ||</div><div class="line"><a name="l10386"></a><span class="lineno">10386</span>  (<span class="charliteral">'0'</span> <= ch && ch <= <span class="charliteral">'9'</span>) || ch == <span class="charliteral">'_'</span>;</div><div class="line"><a name="l10387"></a><span class="lineno">10387</span> }</div><div class="line"><a name="l10388"></a><span class="lineno">10388</span> </div><div class="line"><a name="l10389"></a><span class="lineno">10389</span> <span class="comment">// Returns true iff "\\c" is a supported escape sequence.</span></div><div class="line"><a name="l10390"></a><span class="lineno">10390</span> <span class="keywordtype">bool</span> IsValidEscape(<span class="keywordtype">char</span> c) {</div><div class="line"><a name="l10391"></a><span class="lineno">10391</span>  <span class="keywordflow">return</span> (IsAsciiPunct(c) || IsInSet(c, <span class="stringliteral">"dDfnrsStvwW"</span>));</div><div class="line"><a name="l10392"></a><span class="lineno">10392</span> }</div><div class="line"><a name="l10393"></a><span class="lineno">10393</span> </div><div class="line"><a name="l10394"></a><span class="lineno">10394</span> <span class="comment">// Returns true iff the given atom (specified by escaped and pattern)</span></div><div class="line"><a name="l10395"></a><span class="lineno">10395</span> <span class="comment">// matches ch. The result is undefined if the atom is invalid.</span></div><div class="line"><a name="l10396"></a><span class="lineno">10396</span> <span class="keywordtype">bool</span> AtomMatchesChar(<span class="keywordtype">bool</span> escaped, <span class="keywordtype">char</span> pattern_char, <span class="keywordtype">char</span> ch) {</div><div class="line"><a name="l10397"></a><span class="lineno">10397</span>  <span class="keywordflow">if</span> (escaped) { <span class="comment">// "\\p" where p is pattern_char.</span></div><div class="line"><a name="l10398"></a><span class="lineno">10398</span>  <span class="keywordflow">switch</span> (pattern_char) {</div><div class="line"><a name="l10399"></a><span class="lineno">10399</span>  <span class="keywordflow">case</span> <span class="charliteral">'d'</span>: <span class="keywordflow">return</span> IsAsciiDigit(ch);</div><div class="line"><a name="l10400"></a><span class="lineno">10400</span>  <span class="keywordflow">case</span> <span class="charliteral">'D'</span>: <span class="keywordflow">return</span> !IsAsciiDigit(ch);</div><div class="line"><a name="l10401"></a><span class="lineno">10401</span>  <span class="keywordflow">case</span> <span class="charliteral">'f'</span>: <span class="keywordflow">return</span> ch == <span class="charliteral">'\f'</span>;</div><div class="line"><a name="l10402"></a><span class="lineno">10402</span>  <span class="keywordflow">case</span> <span class="charliteral">'n'</span>: <span class="keywordflow">return</span> ch == <span class="charliteral">'\n'</span>;</div><div class="line"><a name="l10403"></a><span class="lineno">10403</span>  <span class="keywordflow">case</span> <span class="charliteral">'r'</span>: <span class="keywordflow">return</span> ch == <span class="charliteral">'\r'</span>;</div><div class="line"><a name="l10404"></a><span class="lineno">10404</span>  <span class="keywordflow">case</span> <span class="charliteral">'s'</span>: <span class="keywordflow">return</span> IsAsciiWhiteSpace(ch);</div><div class="line"><a name="l10405"></a><span class="lineno">10405</span>  <span class="keywordflow">case</span> <span class="charliteral">'S'</span>: <span class="keywordflow">return</span> !IsAsciiWhiteSpace(ch);</div><div class="line"><a name="l10406"></a><span class="lineno">10406</span>  <span class="keywordflow">case</span> <span class="charliteral">'t'</span>: <span class="keywordflow">return</span> ch == <span class="charliteral">'\t'</span>;</div><div class="line"><a name="l10407"></a><span class="lineno">10407</span>  <span class="keywordflow">case</span> <span class="charliteral">'v'</span>: <span class="keywordflow">return</span> ch == <span class="charliteral">'\v'</span>;</div><div class="line"><a name="l10408"></a><span class="lineno">10408</span>  <span class="keywordflow">case</span> <span class="charliteral">'w'</span>: <span class="keywordflow">return</span> IsAsciiWordChar(ch);</div><div class="line"><a name="l10409"></a><span class="lineno">10409</span>  <span class="keywordflow">case</span> <span class="charliteral">'W'</span>: <span class="keywordflow">return</span> !IsAsciiWordChar(ch);</div><div class="line"><a name="l10410"></a><span class="lineno">10410</span>  }</div><div class="line"><a name="l10411"></a><span class="lineno">10411</span>  <span class="keywordflow">return</span> IsAsciiPunct(pattern_char) && pattern_char == ch;</div><div class="line"><a name="l10412"></a><span class="lineno">10412</span>  }</div><div class="line"><a name="l10413"></a><span class="lineno">10413</span> </div><div class="line"><a name="l10414"></a><span class="lineno">10414</span>  <span class="keywordflow">return</span> (pattern_char == <span class="charliteral">'.'</span> && ch != <span class="charliteral">'\n'</span>) || pattern_char == ch;</div><div class="line"><a name="l10415"></a><span class="lineno">10415</span> }</div><div class="line"><a name="l10416"></a><span class="lineno">10416</span> </div><div class="line"><a name="l10417"></a><span class="lineno">10417</span> <span class="comment">// Helper function used by ValidateRegex() to format error messages.</span></div><div class="line"><a name="l10418"></a><span class="lineno">10418</span> <span class="keyword">static</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> FormatRegexSyntaxError(<span class="keyword">const</span> <span class="keywordtype">char</span>* regex, <span class="keywordtype">int</span> index) {</div><div class="line"><a name="l10419"></a><span class="lineno">10419</span>  <span class="keywordflow">return</span> (Message() << <span class="stringliteral">"Syntax error at index "</span> << index</div><div class="line"><a name="l10420"></a><span class="lineno">10420</span>  << <span class="stringliteral">" in simple regular expression \""</span> << regex << <span class="stringliteral">"\": "</span>).GetString();</div><div class="line"><a name="l10421"></a><span class="lineno">10421</span> }</div><div class="line"><a name="l10422"></a><span class="lineno">10422</span> </div><div class="line"><a name="l10423"></a><span class="lineno">10423</span> <span class="comment">// Generates non-fatal failures and returns false if regex is invalid;</span></div><div class="line"><a name="l10424"></a><span class="lineno">10424</span> <span class="comment">// otherwise returns true.</span></div><div class="line"><a name="l10425"></a><span class="lineno">10425</span> <span class="keywordtype">bool</span> ValidateRegex(<span class="keyword">const</span> <span class="keywordtype">char</span>* regex) {</div><div class="line"><a name="l10426"></a><span class="lineno">10426</span>  <span class="keywordflow">if</span> (regex == <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l10427"></a><span class="lineno">10427</span>  <a class="code" href="gtest_8h.html#adc16b5b0a740c39084ea5c9e960e3063">ADD_FAILURE</a>() << <span class="stringliteral">"NULL is not a valid simple regular expression."</span>;</div><div class="line"><a name="l10428"></a><span class="lineno">10428</span>  <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l10429"></a><span class="lineno">10429</span>  }</div><div class="line"><a name="l10430"></a><span class="lineno">10430</span> </div><div class="line"><a name="l10431"></a><span class="lineno">10431</span>  <span class="keywordtype">bool</span> is_valid = <span class="keyword">true</span>;</div><div class="line"><a name="l10432"></a><span class="lineno">10432</span> </div><div class="line"><a name="l10433"></a><span class="lineno">10433</span>  <span class="comment">// True iff ?, *, or + can follow the previous atom.</span></div><div class="line"><a name="l10434"></a><span class="lineno">10434</span>  <span class="keywordtype">bool</span> prev_repeatable = <span class="keyword">false</span>;</div><div class="line"><a name="l10435"></a><span class="lineno">10435</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; regex[i]; i++) {</div><div class="line"><a name="l10436"></a><span class="lineno">10436</span>  <span class="keywordflow">if</span> (regex[i] == <span class="charliteral">'\\'</span>) { <span class="comment">// An escape sequence</span></div><div class="line"><a name="l10437"></a><span class="lineno">10437</span>  i++;</div><div class="line"><a name="l10438"></a><span class="lineno">10438</span>  <span class="keywordflow">if</span> (regex[i] == <span class="charliteral">'\0'</span>) {</div><div class="line"><a name="l10439"></a><span class="lineno">10439</span>  <a class="code" href="gtest_8h.html#adc16b5b0a740c39084ea5c9e960e3063">ADD_FAILURE</a>() << FormatRegexSyntaxError(regex, i - 1)</div><div class="line"><a name="l10440"></a><span class="lineno">10440</span>  << <span class="stringliteral">"'\\' cannot appear at the end."</span>;</div><div class="line"><a name="l10441"></a><span class="lineno">10441</span>  <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l10442"></a><span class="lineno">10442</span>  }</div><div class="line"><a name="l10443"></a><span class="lineno">10443</span> </div><div class="line"><a name="l10444"></a><span class="lineno">10444</span>  <span class="keywordflow">if</span> (!IsValidEscape(regex[i])) {</div><div class="line"><a name="l10445"></a><span class="lineno">10445</span>  <a class="code" href="gtest_8h.html#adc16b5b0a740c39084ea5c9e960e3063">ADD_FAILURE</a>() << FormatRegexSyntaxError(regex, i - 1)</div><div class="line"><a name="l10446"></a><span class="lineno">10446</span>  << <span class="stringliteral">"invalid escape sequence \"\\"</span> << regex[i] << <span class="stringliteral">"\"."</span>;</div><div class="line"><a name="l10447"></a><span class="lineno">10447</span>  is_valid = <span class="keyword">false</span>;</div><div class="line"><a name="l10448"></a><span class="lineno">10448</span>  }</div><div class="line"><a name="l10449"></a><span class="lineno">10449</span>  prev_repeatable = <span class="keyword">true</span>;</div><div class="line"><a name="l10450"></a><span class="lineno">10450</span>  } <span class="keywordflow">else</span> { <span class="comment">// Not an escape sequence.</span></div><div class="line"><a name="l10451"></a><span class="lineno">10451</span>  <span class="keyword">const</span> <span class="keywordtype">char</span> ch = regex[i];</div><div class="line"><a name="l10452"></a><span class="lineno">10452</span> </div><div class="line"><a name="l10453"></a><span class="lineno">10453</span>  <span class="keywordflow">if</span> (ch == <span class="charliteral">'^'</span> && i > 0) {</div><div class="line"><a name="l10454"></a><span class="lineno">10454</span>  <a class="code" href="gtest_8h.html#adc16b5b0a740c39084ea5c9e960e3063">ADD_FAILURE</a>() << FormatRegexSyntaxError(regex, i)</div><div class="line"><a name="l10455"></a><span class="lineno">10455</span>  << <span class="stringliteral">"'^' can only appear at the beginning."</span>;</div><div class="line"><a name="l10456"></a><span class="lineno">10456</span>  is_valid = <span class="keyword">false</span>;</div><div class="line"><a name="l10457"></a><span class="lineno">10457</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ch == <span class="charliteral">'$'</span> && regex[i + 1] != <span class="charliteral">'\0'</span>) {</div><div class="line"><a name="l10458"></a><span class="lineno">10458</span>  <a class="code" href="gtest_8h.html#adc16b5b0a740c39084ea5c9e960e3063">ADD_FAILURE</a>() << FormatRegexSyntaxError(regex, i)</div><div class="line"><a name="l10459"></a><span class="lineno">10459</span>  << <span class="stringliteral">"'$' can only appear at the end."</span>;</div><div class="line"><a name="l10460"></a><span class="lineno">10460</span>  is_valid = <span class="keyword">false</span>;</div><div class="line"><a name="l10461"></a><span class="lineno">10461</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (IsInSet(ch, <span class="stringliteral">"()[]{}|"</span>)) {</div><div class="line"><a name="l10462"></a><span class="lineno">10462</span>  <a class="code" href="gtest_8h.html#adc16b5b0a740c39084ea5c9e960e3063">ADD_FAILURE</a>() << FormatRegexSyntaxError(regex, i)</div><div class="line"><a name="l10463"></a><span class="lineno">10463</span>  << <span class="stringliteral">"'"</span> << ch << <span class="stringliteral">"' is unsupported."</span>;</div><div class="line"><a name="l10464"></a><span class="lineno">10464</span>  is_valid = <span class="keyword">false</span>;</div><div class="line"><a name="l10465"></a><span class="lineno">10465</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (IsRepeat(ch) && !prev_repeatable) {</div><div class="line"><a name="l10466"></a><span class="lineno">10466</span>  <a class="code" href="gtest_8h.html#adc16b5b0a740c39084ea5c9e960e3063">ADD_FAILURE</a>() << FormatRegexSyntaxError(regex, i)</div><div class="line"><a name="l10467"></a><span class="lineno">10467</span>  << <span class="stringliteral">"'"</span> << ch << <span class="stringliteral">"' can only follow a repeatable token."</span>;</div><div class="line"><a name="l10468"></a><span class="lineno">10468</span>  is_valid = <span class="keyword">false</span>;</div><div class="line"><a name="l10469"></a><span class="lineno">10469</span>  }</div><div class="line"><a name="l10470"></a><span class="lineno">10470</span> </div><div class="line"><a name="l10471"></a><span class="lineno">10471</span>  prev_repeatable = !IsInSet(ch, <span class="stringliteral">"^$?*+"</span>);</div><div class="line"><a name="l10472"></a><span class="lineno">10472</span>  }</div><div class="line"><a name="l10473"></a><span class="lineno">10473</span>  }</div><div class="line"><a name="l10474"></a><span class="lineno">10474</span> </div><div class="line"><a name="l10475"></a><span class="lineno">10475</span>  <span class="keywordflow">return</span> is_valid;</div><div class="line"><a name="l10476"></a><span class="lineno">10476</span> }</div><div class="line"><a name="l10477"></a><span class="lineno">10477</span> </div><div class="line"><a name="l10478"></a><span class="lineno">10478</span> <span class="comment">// Matches a repeated regex atom followed by a valid simple regular</span></div><div class="line"><a name="l10479"></a><span class="lineno">10479</span> <span class="comment">// expression. The regex atom is defined as c if escaped is false,</span></div><div class="line"><a name="l10480"></a><span class="lineno">10480</span> <span class="comment">// or \c otherwise. repeat is the repetition meta character (?, *,</span></div><div class="line"><a name="l10481"></a><span class="lineno">10481</span> <span class="comment">// or +). The behavior is undefined if str contains too many</span></div><div class="line"><a name="l10482"></a><span class="lineno">10482</span> <span class="comment">// characters to be indexable by size_t, in which case the test will</span></div><div class="line"><a name="l10483"></a><span class="lineno">10483</span> <span class="comment">// probably time out anyway. We are fine with this limitation as</span></div><div class="line"><a name="l10484"></a><span class="lineno">10484</span> <span class="comment">// std::string has it too.</span></div><div class="line"><a name="l10485"></a><span class="lineno">10485</span> <span class="keywordtype">bool</span> MatchRepetitionAndRegexAtHead(</div><div class="line"><a name="l10486"></a><span class="lineno">10486</span>  <span class="keywordtype">bool</span> escaped, <span class="keywordtype">char</span> c, <span class="keywordtype">char</span> <a class="code" href="namespaceutl_1_1meta.html#aa013c45afb59b5c132a72be54ba145fb">repeat</a>, <span class="keyword">const</span> <span class="keywordtype">char</span>* regex,</div><div class="line"><a name="l10487"></a><span class="lineno">10487</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* str) {</div><div class="line"><a name="l10488"></a><span class="lineno">10488</span>  <span class="keyword">const</span> <span class="keywordtype">size_t</span> min_count = (<a class="code" href="namespaceutl_1_1meta.html#aa013c45afb59b5c132a72be54ba145fb">repeat</a> == <span class="charliteral">'+'</span>) ? 1 : 0;</div><div class="line"><a name="l10489"></a><span class="lineno">10489</span>  <span class="keyword">const</span> <span class="keywordtype">size_t</span> max_count = (<a class="code" href="namespaceutl_1_1meta.html#aa013c45afb59b5c132a72be54ba145fb">repeat</a> == <span class="charliteral">'?'</span>) ? 1 :</div><div class="line"><a name="l10490"></a><span class="lineno">10490</span>  static_cast<size_t>(-1) - 1;</div><div class="line"><a name="l10491"></a><span class="lineno">10491</span>  <span class="comment">// We cannot call numeric_limits::max() as it conflicts with the</span></div><div class="line"><a name="l10492"></a><span class="lineno">10492</span>  <span class="comment">// max() macro on Windows.</span></div><div class="line"><a name="l10493"></a><span class="lineno">10493</span> </div><div class="line"><a name="l10494"></a><span class="lineno">10494</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i <= max_count; ++i) {</div><div class="line"><a name="l10495"></a><span class="lineno">10495</span>  <span class="comment">// We know that the atom matches each of the first i characters in str.</span></div><div class="line"><a name="l10496"></a><span class="lineno">10496</span>  <span class="keywordflow">if</span> (i >= min_count && MatchRegexAtHead(regex, str + i)) {</div><div class="line"><a name="l10497"></a><span class="lineno">10497</span>  <span class="comment">// We have enough matches at the head, and the tail matches too.</span></div><div class="line"><a name="l10498"></a><span class="lineno">10498</span>  <span class="comment">// Since we only care about *whether* the pattern matches str</span></div><div class="line"><a name="l10499"></a><span class="lineno">10499</span>  <span class="comment">// (as opposed to *how* it matches), there is no need to find a</span></div><div class="line"><a name="l10500"></a><span class="lineno">10500</span>  <span class="comment">// greedy match.</span></div><div class="line"><a name="l10501"></a><span class="lineno">10501</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l10502"></a><span class="lineno">10502</span>  }</div><div class="line"><a name="l10503"></a><span class="lineno">10503</span>  <span class="keywordflow">if</span> (str[i] == <span class="charliteral">'\0'</span> || !AtomMatchesChar(escaped, c, str[i]))</div><div class="line"><a name="l10504"></a><span class="lineno">10504</span>  <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l10505"></a><span class="lineno">10505</span>  }</div><div class="line"><a name="l10506"></a><span class="lineno">10506</span>  <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l10507"></a><span class="lineno">10507</span> }</div><div class="line"><a name="l10508"></a><span class="lineno">10508</span> </div><div class="line"><a name="l10509"></a><span class="lineno">10509</span> <span class="comment">// Returns true iff regex matches a prefix of str. regex must be a</span></div><div class="line"><a name="l10510"></a><span class="lineno">10510</span> <span class="comment">// valid simple regular expression and not start with "^", or the</span></div><div class="line"><a name="l10511"></a><span class="lineno">10511</span> <span class="comment">// result is undefined.</span></div><div class="line"><a name="l10512"></a><span class="lineno">10512</span> <span class="keywordtype">bool</span> MatchRegexAtHead(<span class="keyword">const</span> <span class="keywordtype">char</span>* regex, <span class="keyword">const</span> <span class="keywordtype">char</span>* str) {</div><div class="line"><a name="l10513"></a><span class="lineno">10513</span>  <span class="keywordflow">if</span> (*regex == <span class="charliteral">'\0'</span>) <span class="comment">// An empty regex matches a prefix of anything.</span></div><div class="line"><a name="l10514"></a><span class="lineno">10514</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l10515"></a><span class="lineno">10515</span> </div><div class="line"><a name="l10516"></a><span class="lineno">10516</span>  <span class="comment">// "$" only matches the end of a string. Note that regex being</span></div><div class="line"><a name="l10517"></a><span class="lineno">10517</span>  <span class="comment">// valid guarantees that there's nothing after "$" in it.</span></div><div class="line"><a name="l10518"></a><span class="lineno">10518</span>  <span class="keywordflow">if</span> (*regex == <span class="charliteral">'$'</span>)</div><div class="line"><a name="l10519"></a><span class="lineno">10519</span>  <span class="keywordflow">return</span> *str == <span class="charliteral">'\0'</span>;</div><div class="line"><a name="l10520"></a><span class="lineno">10520</span> </div><div class="line"><a name="l10521"></a><span class="lineno">10521</span>  <span class="comment">// Is the first thing in regex an escape sequence?</span></div><div class="line"><a name="l10522"></a><span class="lineno">10522</span>  <span class="keyword">const</span> <span class="keywordtype">bool</span> escaped = *regex == <span class="charliteral">'\\'</span>;</div><div class="line"><a name="l10523"></a><span class="lineno">10523</span>  <span class="keywordflow">if</span> (escaped)</div><div class="line"><a name="l10524"></a><span class="lineno">10524</span>  ++regex;</div><div class="line"><a name="l10525"></a><span class="lineno">10525</span>  <span class="keywordflow">if</span> (IsRepeat(regex[1])) {</div><div class="line"><a name="l10526"></a><span class="lineno">10526</span>  <span class="comment">// MatchRepetitionAndRegexAtHead() calls MatchRegexAtHead(), so</span></div><div class="line"><a name="l10527"></a><span class="lineno">10527</span>  <span class="comment">// here's an indirect recursion. It terminates as the regex gets</span></div><div class="line"><a name="l10528"></a><span class="lineno">10528</span>  <span class="comment">// shorter in each recursion.</span></div><div class="line"><a name="l10529"></a><span class="lineno">10529</span>  <span class="keywordflow">return</span> MatchRepetitionAndRegexAtHead(</div><div class="line"><a name="l10530"></a><span class="lineno">10530</span>  escaped, regex[0], regex[1], regex + 2, str);</div><div class="line"><a name="l10531"></a><span class="lineno">10531</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l10532"></a><span class="lineno">10532</span>  <span class="comment">// regex isn't empty, isn't "$", and doesn't start with a</span></div><div class="line"><a name="l10533"></a><span class="lineno">10533</span>  <span class="comment">// repetition. We match the first atom of regex with the first</span></div><div class="line"><a name="l10534"></a><span class="lineno">10534</span>  <span class="comment">// character of str and recurse.</span></div><div class="line"><a name="l10535"></a><span class="lineno">10535</span>  <span class="keywordflow">return</span> (*str != <span class="charliteral">'\0'</span>) && AtomMatchesChar(escaped, *regex, *str) &&</div><div class="line"><a name="l10536"></a><span class="lineno">10536</span>  MatchRegexAtHead(regex + 1, str + 1);</div><div class="line"><a name="l10537"></a><span class="lineno">10537</span>  }</div><div class="line"><a name="l10538"></a><span class="lineno">10538</span> }</div><div class="line"><a name="l10539"></a><span class="lineno">10539</span> </div><div class="line"><a name="l10540"></a><span class="lineno">10540</span> <span class="comment">// Returns true iff regex matches any substring of str. regex must be</span></div><div class="line"><a name="l10541"></a><span class="lineno">10541</span> <span class="comment">// a valid simple regular expression, or the result is undefined.</span></div><div class="line"><a name="l10542"></a><span class="lineno">10542</span> <span class="comment">//</span></div><div class="line"><a name="l10543"></a><span class="lineno">10543</span> <span class="comment">// The algorithm is recursive, but the recursion depth doesn't exceed</span></div><div class="line"><a name="l10544"></a><span class="lineno">10544</span> <span class="comment">// the regex length, so we won't need to worry about running out of</span></div><div class="line"><a name="l10545"></a><span class="lineno">10545</span> <span class="comment">// stack space normally. In rare cases the time complexity can be</span></div><div class="line"><a name="l10546"></a><span class="lineno">10546</span> <span class="comment">// exponential with respect to the regex length + the string length,</span></div><div class="line"><a name="l10547"></a><span class="lineno">10547</span> <span class="comment">// but usually it's must faster (often close to linear).</span></div><div class="line"><a name="l10548"></a><span class="lineno">10548</span> <span class="keywordtype">bool</span> MatchRegexAnywhere(<span class="keyword">const</span> <span class="keywordtype">char</span>* regex, <span class="keyword">const</span> <span class="keywordtype">char</span>* str) {</div><div class="line"><a name="l10549"></a><span class="lineno">10549</span>  <span class="keywordflow">if</span> (regex == <span class="keyword">nullptr</span> || str == <span class="keyword">nullptr</span>) <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l10550"></a><span class="lineno">10550</span> </div><div class="line"><a name="l10551"></a><span class="lineno">10551</span>  <span class="keywordflow">if</span> (*regex == <span class="charliteral">'^'</span>)</div><div class="line"><a name="l10552"></a><span class="lineno">10552</span>  <span class="keywordflow">return</span> MatchRegexAtHead(regex + 1, str);</div><div class="line"><a name="l10553"></a><span class="lineno">10553</span> </div><div class="line"><a name="l10554"></a><span class="lineno">10554</span>  <span class="comment">// A successful match can be anywhere in str.</span></div><div class="line"><a name="l10555"></a><span class="lineno">10555</span>  <span class="keywordflow">do</span> {</div><div class="line"><a name="l10556"></a><span class="lineno">10556</span>  <span class="keywordflow">if</span> (MatchRegexAtHead(regex, str))</div><div class="line"><a name="l10557"></a><span class="lineno">10557</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l10558"></a><span class="lineno">10558</span>  } <span class="keywordflow">while</span> (*str++ != <span class="charliteral">'\0'</span>);</div><div class="line"><a name="l10559"></a><span class="lineno">10559</span>  <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l10560"></a><span class="lineno">10560</span> }</div><div class="line"><a name="l10561"></a><span class="lineno">10561</span> </div><div class="line"><a name="l10562"></a><span class="lineno">10562</span> <span class="comment">// Implements the RE class.</span></div><div class="line"><a name="l10563"></a><span class="lineno">10563</span> </div><div class="line"><a name="l10564"></a><span class="lineno">10564</span> RE::~RE() {</div><div class="line"><a name="l10565"></a><span class="lineno">10565</span>  free(const_cast<char*>(pattern_));</div><div class="line"><a name="l10566"></a><span class="lineno">10566</span>  free(const_cast<char*>(full_pattern_));</div><div class="line"><a name="l10567"></a><span class="lineno">10567</span> }</div><div class="line"><a name="l10568"></a><span class="lineno">10568</span> </div><div class="line"><a name="l10569"></a><span class="lineno">10569</span> <span class="comment">// Returns true iff regular expression re matches the entire str.</span></div><div class="line"><a name="l10570"></a><span class="lineno">10570</span> <span class="keywordtype">bool</span> RE::FullMatch(<span class="keyword">const</span> <span class="keywordtype">char</span>* str, <span class="keyword">const</span> RE& re) {</div><div class="line"><a name="l10571"></a><span class="lineno">10571</span>  <span class="keywordflow">return</span> re.is_valid_ && MatchRegexAnywhere(re.full_pattern_, str);</div><div class="line"><a name="l10572"></a><span class="lineno">10572</span> }</div><div class="line"><a name="l10573"></a><span class="lineno">10573</span> </div><div class="line"><a name="l10574"></a><span class="lineno">10574</span> <span class="comment">// Returns true iff regular expression re matches a substring of str</span></div><div class="line"><a name="l10575"></a><span class="lineno">10575</span> <span class="comment">// (including str itself).</span></div><div class="line"><a name="l10576"></a><span class="lineno">10576</span> <span class="keywordtype">bool</span> RE::PartialMatch(<span class="keyword">const</span> <span class="keywordtype">char</span>* str, <span class="keyword">const</span> RE& re) {</div><div class="line"><a name="l10577"></a><span class="lineno">10577</span>  <span class="keywordflow">return</span> re.is_valid_ && MatchRegexAnywhere(re.pattern_, str);</div><div class="line"><a name="l10578"></a><span class="lineno">10578</span> }</div><div class="line"><a name="l10579"></a><span class="lineno">10579</span> </div><div class="line"><a name="l10580"></a><span class="lineno">10580</span> <span class="comment">// Initializes an RE from its string representation.</span></div><div class="line"><a name="l10581"></a><span class="lineno">10581</span> <span class="keywordtype">void</span> RE::Init(<span class="keyword">const</span> <span class="keywordtype">char</span>* regex) {</div><div class="line"><a name="l10582"></a><span class="lineno">10582</span>  pattern_ = full_pattern_ = <span class="keyword">nullptr</span>;</div><div class="line"><a name="l10583"></a><span class="lineno">10583</span>  <span class="keywordflow">if</span> (regex != <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l10584"></a><span class="lineno">10584</span>  pattern_ = <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a8e352884793a65ae8be144676f1a9136">posix::StrDup</a>(regex);</div><div class="line"><a name="l10585"></a><span class="lineno">10585</span>  }</div><div class="line"><a name="l10586"></a><span class="lineno">10586</span> </div><div class="line"><a name="l10587"></a><span class="lineno">10587</span>  is_valid_ = ValidateRegex(regex);</div><div class="line"><a name="l10588"></a><span class="lineno">10588</span>  <span class="keywordflow">if</span> (!is_valid_) {</div><div class="line"><a name="l10589"></a><span class="lineno">10589</span>  <span class="comment">// No need to calculate the full pattern when the regex is invalid.</span></div><div class="line"><a name="l10590"></a><span class="lineno">10590</span>  <span class="keywordflow">return</span>;</div><div class="line"><a name="l10591"></a><span class="lineno">10591</span>  }</div><div class="line"><a name="l10592"></a><span class="lineno">10592</span> </div><div class="line"><a name="l10593"></a><span class="lineno">10593</span>  <span class="keyword">const</span> <span class="keywordtype">size_t</span> len = strlen(regex);</div><div class="line"><a name="l10594"></a><span class="lineno">10594</span>  <span class="comment">// Reserves enough bytes to hold the regular expression used for a</span></div><div class="line"><a name="l10595"></a><span class="lineno">10595</span>  <span class="comment">// full match: we need space to prepend a '^', append a '$', and</span></div><div class="line"><a name="l10596"></a><span class="lineno">10596</span>  <span class="comment">// terminate the string with '\0'.</span></div><div class="line"><a name="l10597"></a><span class="lineno">10597</span>  <span class="keywordtype">char</span>* buffer = <span class="keyword">static_cast<</span><span class="keywordtype">char</span>*<span class="keyword">></span>(malloc(len + 3));</div><div class="line"><a name="l10598"></a><span class="lineno">10598</span>  full_pattern_ = buffer;</div><div class="line"><a name="l10599"></a><span class="lineno">10599</span> </div><div class="line"><a name="l10600"></a><span class="lineno">10600</span>  <span class="keywordflow">if</span> (*regex != <span class="charliteral">'^'</span>)</div><div class="line"><a name="l10601"></a><span class="lineno">10601</span>  *buffer++ = <span class="charliteral">'^'</span>; <span class="comment">// Makes sure full_pattern_ starts with '^'.</span></div><div class="line"><a name="l10602"></a><span class="lineno">10602</span> </div><div class="line"><a name="l10603"></a><span class="lineno">10603</span>  <span class="comment">// We don't use snprintf or strncpy, as they trigger a warning when</span></div><div class="line"><a name="l10604"></a><span class="lineno">10604</span>  <span class="comment">// compiled with VC++ 8.0.</span></div><div class="line"><a name="l10605"></a><span class="lineno">10605</span>  memcpy(buffer, regex, len);</div><div class="line"><a name="l10606"></a><span class="lineno">10606</span>  buffer += len;</div><div class="line"><a name="l10607"></a><span class="lineno">10607</span> </div><div class="line"><a name="l10608"></a><span class="lineno">10608</span>  <span class="keywordflow">if</span> (len == 0 || regex[len - 1] != <span class="charliteral">'$'</span>)</div><div class="line"><a name="l10609"></a><span class="lineno">10609</span>  *buffer++ = <span class="charliteral">'$'</span>; <span class="comment">// Makes sure full_pattern_ ends with '$'.</span></div><div class="line"><a name="l10610"></a><span class="lineno">10610</span> </div><div class="line"><a name="l10611"></a><span class="lineno">10611</span>  *buffer = <span class="charliteral">'\0'</span>;</div><div class="line"><a name="l10612"></a><span class="lineno">10612</span> }</div><div class="line"><a name="l10613"></a><span class="lineno">10613</span> </div><div class="line"><a name="l10614"></a><span class="lineno">10614</span> <span class="preprocessor">#endif // GTEST_USES_POSIX_RE</span></div><div class="line"><a name="l10615"></a><span class="lineno">10615</span> </div><div class="line"><a name="l10616"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#abae7a5775c901f2fd12b058b00d09840">10616</a></span> <span class="keyword">const</span> <span class="keywordtype">char</span> <a class="code" href="namespacetesting_1_1internal.html#abae7a5775c901f2fd12b058b00d09840">kUnknownFile</a>[] = <span class="stringliteral">"unknown file"</span>;</div><div class="line"><a name="l10617"></a><span class="lineno">10617</span> </div><div class="line"><a name="l10618"></a><span class="lineno">10618</span> <span class="comment">// Formats a source file path and a line number as they would appear</span></div><div class="line"><a name="l10619"></a><span class="lineno">10619</span> <span class="comment">// in an error message from the compiler used to compile this code.</span></div><div class="line"><a name="l10620"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#a31b7c3abed4a7c395f42c61e993989f4">10620</a></span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">GTEST_API_ ::std::string</a> <a class="code" href="namespacetesting_1_1internal.html#a31b7c3abed4a7c395f42c61e993989f4">FormatFileLocation</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* file, <span class="keywordtype">int</span> line) {</div><div class="line"><a name="l10621"></a><span class="lineno">10621</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> file_name(file == <span class="keyword">nullptr</span> ? <a class="code" href="namespacetesting_1_1internal.html#abae7a5775c901f2fd12b058b00d09840">kUnknownFile</a> : file);</div><div class="line"><a name="l10622"></a><span class="lineno">10622</span> </div><div class="line"><a name="l10623"></a><span class="lineno">10623</span>  <span class="keywordflow">if</span> (line < 0) {</div><div class="line"><a name="l10624"></a><span class="lineno">10624</span>  <span class="keywordflow">return</span> file_name + <span class="stringliteral">":"</span>;</div><div class="line"><a name="l10625"></a><span class="lineno">10625</span>  }</div><div class="line"><a name="l10626"></a><span class="lineno">10626</span> <span class="preprocessor">#ifdef _MSC_VER</span></div><div class="line"><a name="l10627"></a><span class="lineno">10627</span>  <span class="keywordflow">return</span> file_name + <span class="stringliteral">"("</span> + <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(line) + <span class="stringliteral">"):"</span>;</div><div class="line"><a name="l10628"></a><span class="lineno">10628</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l10629"></a><span class="lineno">10629</span>  <span class="keywordflow">return</span> file_name + <span class="stringliteral">":"</span> + <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(line) + <span class="stringliteral">":"</span>;</div><div class="line"><a name="l10630"></a><span class="lineno">10630</span> <span class="preprocessor">#endif // _MSC_VER</span></div><div class="line"><a name="l10631"></a><span class="lineno">10631</span> }</div><div class="line"><a name="l10632"></a><span class="lineno">10632</span> </div><div class="line"><a name="l10633"></a><span class="lineno">10633</span> <span class="comment">// Formats a file location for compiler-independent XML output.</span></div><div class="line"><a name="l10634"></a><span class="lineno">10634</span> <span class="comment">// Although this function is not platform dependent, we put it next to</span></div><div class="line"><a name="l10635"></a><span class="lineno">10635</span> <span class="comment">// FormatFileLocation in order to contrast the two functions.</span></div><div class="line"><a name="l10636"></a><span class="lineno">10636</span> <span class="comment">// Note that FormatCompilerIndependentFileLocation() does NOT append colon</span></div><div class="line"><a name="l10637"></a><span class="lineno">10637</span> <span class="comment">// to the file location it produces, unlike FormatFileLocation().</span></div><div class="line"><a name="l10638"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#a1ee4cde97868c53e442d3182496a9f3c">10638</a></span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">GTEST_API_ ::std::string</a> <a class="code" href="namespacetesting_1_1internal.html#a1ee4cde97868c53e442d3182496a9f3c">FormatCompilerIndependentFileLocation</a>(</div><div class="line"><a name="l10639"></a><span class="lineno">10639</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* file, <span class="keywordtype">int</span> line) {</div><div class="line"><a name="l10640"></a><span class="lineno">10640</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> file_name(file == <span class="keyword">nullptr</span> ? <a class="code" href="namespacetesting_1_1internal.html#abae7a5775c901f2fd12b058b00d09840">kUnknownFile</a> : file);</div><div class="line"><a name="l10641"></a><span class="lineno">10641</span> </div><div class="line"><a name="l10642"></a><span class="lineno">10642</span>  <span class="keywordflow">if</span> (line < 0)</div><div class="line"><a name="l10643"></a><span class="lineno">10643</span>  <span class="keywordflow">return</span> file_name;</div><div class="line"><a name="l10644"></a><span class="lineno">10644</span>  <span class="keywordflow">else</span></div><div class="line"><a name="l10645"></a><span class="lineno">10645</span>  <span class="keywordflow">return</span> file_name + <span class="stringliteral">":"</span> + <a class="code" href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">StreamableToString</a>(line);</div><div class="line"><a name="l10646"></a><span class="lineno">10646</span> }</div><div class="line"><a name="l10647"></a><span class="lineno">10647</span> </div><div class="line"><a name="l10648"></a><span class="lineno"><a class="line" href="classtesting_1_1internal_1_1_g_test_log.html#a364691bf972983a59cfa2891062a64af">10648</a></span> GTestLog::GTestLog(<a class="code" href="namespacetesting_1_1internal.html#aa6255ef3b023c5b4e1a2198d887fb977">GTestLogSeverity</a> severity, <span class="keyword">const</span> <span class="keywordtype">char</span>* file, <span class="keywordtype">int</span> line)</div><div class="line"><a name="l10649"></a><span class="lineno">10649</span>  : severity_(severity) {</div><div class="line"><a name="l10650"></a><span class="lineno">10650</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> marker =</div><div class="line"><a name="l10651"></a><span class="lineno">10651</span>  severity == <a class="code" href="namespacetesting_1_1internal.html#aa6255ef3b023c5b4e1a2198d887fb977aff315e0913fcda86fe4de882bf5e33e9">GTEST_INFO</a> ? <span class="stringliteral">"[ INFO ]"</span> :</div><div class="line"><a name="l10652"></a><span class="lineno">10652</span>  severity == <a class="code" href="namespacetesting_1_1internal.html#aa6255ef3b023c5b4e1a2198d887fb977a7a051bc2794f15a4bf0eab40562a304c">GTEST_WARNING</a> ? <span class="stringliteral">"[WARNING]"</span> :</div><div class="line"><a name="l10653"></a><span class="lineno">10653</span>  severity == <a class="code" href="namespacetesting_1_1internal.html#aa6255ef3b023c5b4e1a2198d887fb977a651e9cd2a904e0c8210536271b875f75">GTEST_ERROR</a> ? <span class="stringliteral">"[ ERROR ]"</span> : <span class="stringliteral">"[ FATAL ]"</span>;</div><div class="line"><a name="l10654"></a><span class="lineno">10654</span>  <a class="code" href="classtesting_1_1internal_1_1_g_test_log.html#aebb92e67d98eca69f0347d5121dab27a">GetStream</a>() << ::std::endl << marker << <span class="stringliteral">" "</span></div><div class="line"><a name="l10655"></a><span class="lineno">10655</span>  << <a class="code" href="namespacetesting_1_1internal.html#a31b7c3abed4a7c395f42c61e993989f4">FormatFileLocation</a>(file, line).c_str() << <span class="stringliteral">": "</span>;</div><div class="line"><a name="l10656"></a><span class="lineno">10656</span> }</div><div class="line"><a name="l10657"></a><span class="lineno">10657</span> </div><div class="line"><a name="l10658"></a><span class="lineno">10658</span> <span class="comment">// Flushes the buffers and, if severity is GTEST_FATAL, aborts the program.</span></div><div class="line"><a name="l10659"></a><span class="lineno"><a class="line" href="classtesting_1_1internal_1_1_g_test_log.html#a978a099703bbaa0f380216e8d7ee03d3">10659</a></span> <a class="code" href="classtesting_1_1internal_1_1_g_test_log.html#a978a099703bbaa0f380216e8d7ee03d3">GTestLog::~GTestLog</a>() {</div><div class="line"><a name="l10660"></a><span class="lineno">10660</span>  <a class="code" href="classtesting_1_1internal_1_1_g_test_log.html#aebb92e67d98eca69f0347d5121dab27a">GetStream</a>() << ::std::endl;</div><div class="line"><a name="l10661"></a><span class="lineno">10661</span>  <span class="keywordflow">if</span> (severity_ == <a class="code" href="namespacetesting_1_1internal.html#aa6255ef3b023c5b4e1a2198d887fb977a75063567740f6bf7da419b1b9197b12e">GTEST_FATAL</a>) {</div><div class="line"><a name="l10662"></a><span class="lineno">10662</span>  fflush(stderr);</div><div class="line"><a name="l10663"></a><span class="lineno">10663</span>  <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a69b8278c59359dd6a6f941b4643db9fb">posix::Abort</a>();</div><div class="line"><a name="l10664"></a><span class="lineno">10664</span>  }</div><div class="line"><a name="l10665"></a><span class="lineno">10665</span> }</div><div class="line"><a name="l10666"></a><span class="lineno">10666</span> </div><div class="line"><a name="l10667"></a><span class="lineno">10667</span> <span class="comment">// Disable Microsoft deprecation warnings for POSIX functions called from</span></div><div class="line"><a name="l10668"></a><span class="lineno">10668</span> <span class="comment">// this class (creat, dup, dup2, and close)</span></div><div class="line"><a name="l10669"></a><span class="lineno">10669</span> <a class="code" href="gtest_8h.html#a5b130138db254deaf29dbe3dffa1a2a8">GTEST_DISABLE_MSC_DEPRECATED_PUSH_</a>()</div><div class="line"><a name="l10670"></a><span class="lineno">10670</span> </div><div class="line"><a name="l10671"></a><span class="lineno">10671</span> <span class="preprocessor">#if GTEST_HAS_STREAM_REDIRECTION</span></div><div class="line"><a name="l10672"></a><span class="lineno">10672</span> </div><div class="line"><a name="l10673"></a><span class="lineno">10673</span> <span class="comment">// Object that captures an output stream (stdout/stderr).</span></div><div class="line"><a name="l10674"></a><span class="lineno"><a class="line" href="classtesting_1_1internal_1_1_captured_stream.html">10674</a></span> <span class="keyword">class </span><a class="code" href="classtesting_1_1internal_1_1_captured_stream.html">CapturedStream</a> {</div><div class="line"><a name="l10675"></a><span class="lineno">10675</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l10676"></a><span class="lineno">10676</span>  <span class="comment">// The ctor redirects the stream to a temporary file.</span></div><div class="line"><a name="l10677"></a><span class="lineno"><a class="line" href="classtesting_1_1internal_1_1_captured_stream.html#a4b05e68491831448c5c575a25146e53d">10677</a></span>  <span class="keyword">explicit</span> <a class="code" href="classtesting_1_1internal_1_1_captured_stream.html#a4b05e68491831448c5c575a25146e53d">CapturedStream</a>(<span class="keywordtype">int</span> fd) : fd_(fd), uncaptured_fd_(dup(fd)) {</div><div class="line"><a name="l10678"></a><span class="lineno">10678</span> <span class="preprocessor"># if GTEST_OS_WINDOWS</span></div><div class="line"><a name="l10679"></a><span class="lineno">10679</span>  <span class="keywordtype">char</span> temp_dir_path[MAX_PATH + 1] = { <span class="charliteral">'\0'</span> }; <span class="comment">// NOLINT</span></div><div class="line"><a name="l10680"></a><span class="lineno">10680</span>  <span class="keywordtype">char</span> temp_file_path[MAX_PATH + 1] = { <span class="charliteral">'\0'</span> }; <span class="comment">// NOLINT</span></div><div class="line"><a name="l10681"></a><span class="lineno">10681</span> </div><div class="line"><a name="l10682"></a><span class="lineno">10682</span>  ::GetTempPathA(<span class="keyword">sizeof</span>(temp_dir_path), temp_dir_path);</div><div class="line"><a name="l10683"></a><span class="lineno">10683</span>  <span class="keyword">const</span> UINT success = ::GetTempFileNameA(temp_dir_path,</div><div class="line"><a name="l10684"></a><span class="lineno">10684</span>  <span class="stringliteral">"gtest_redir"</span>,</div><div class="line"><a name="l10685"></a><span class="lineno">10685</span>  0, <span class="comment">// Generate unique file name.</span></div><div class="line"><a name="l10686"></a><span class="lineno">10686</span>  temp_file_path);</div><div class="line"><a name="l10687"></a><span class="lineno">10687</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(success != 0)</div><div class="line"><a name="l10688"></a><span class="lineno">10688</span>  << <span class="stringliteral">"Unable to create a temporary file in "</span> << temp_dir_path;</div><div class="line"><a name="l10689"></a><span class="lineno">10689</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> captured_fd = creat(temp_file_path, _S_IREAD | _S_IWRITE);</div><div class="line"><a name="l10690"></a><span class="lineno">10690</span>  <a class="code" href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a>(captured_fd != -1) << <span class="stringliteral">"Unable to open temporary file "</span></div><div class="line"><a name="l10691"></a><span class="lineno">10691</span>  << temp_file_path;</div><div class="line"><a name="l10692"></a><span class="lineno">10692</span>  filename_ = temp_file_path;</div><div class="line"><a name="l10693"></a><span class="lineno">10693</span> <span class="preprocessor"># else</span></div><div class="line"><a name="l10694"></a><span class="lineno">10694</span>  <span class="comment">// There's no guarantee that a test has write access to the current</span></div><div class="line"><a name="l10695"></a><span class="lineno">10695</span>  <span class="comment">// directory, so we create the temporary file in the /tmp directory</span></div><div class="line"><a name="l10696"></a><span class="lineno">10696</span>  <span class="comment">// instead. We use /tmp on most systems, and /sdcard on Android.</span></div><div class="line"><a name="l10697"></a><span class="lineno">10697</span>  <span class="comment">// That's because Android doesn't have /tmp.</span></div><div class="line"><a name="l10698"></a><span class="lineno">10698</span> <span class="preprocessor"># if GTEST_OS_LINUX_ANDROID</span></div><div class="line"><a name="l10699"></a><span class="lineno">10699</span>  <span class="comment">// Note: Android applications are expected to call the framework's</span></div><div class="line"><a name="l10700"></a><span class="lineno">10700</span>  <span class="comment">// Context.getExternalStorageDirectory() method through JNI to get</span></div><div class="line"><a name="l10701"></a><span class="lineno">10701</span>  <span class="comment">// the location of the world-writable SD Card directory. However,</span></div><div class="line"><a name="l10702"></a><span class="lineno">10702</span>  <span class="comment">// this requires a Context handle, which cannot be retrieved</span></div><div class="line"><a name="l10703"></a><span class="lineno">10703</span>  <span class="comment">// globally from native code. Doing so also precludes running the</span></div><div class="line"><a name="l10704"></a><span class="lineno">10704</span>  <span class="comment">// code as part of a regular standalone executable, which doesn't</span></div><div class="line"><a name="l10705"></a><span class="lineno">10705</span>  <span class="comment">// run in a Dalvik process (e.g. when running it through 'adb shell').</span></div><div class="line"><a name="l10706"></a><span class="lineno">10706</span>  <span class="comment">//</span></div><div class="line"><a name="l10707"></a><span class="lineno">10707</span>  <span class="comment">// The location /sdcard is directly accessible from native code</span></div><div class="line"><a name="l10708"></a><span class="lineno">10708</span>  <span class="comment">// and is the only location (unofficially) supported by the Android</span></div><div class="line"><a name="l10709"></a><span class="lineno">10709</span>  <span class="comment">// team. It's generally a symlink to the real SD Card mount point</span></div><div class="line"><a name="l10710"></a><span class="lineno">10710</span>  <span class="comment">// which can be /mnt/sdcard, /mnt/sdcard0, /system/media/sdcard, or</span></div><div class="line"><a name="l10711"></a><span class="lineno">10711</span>  <span class="comment">// other OEM-customized locations. Never rely on these, and always</span></div><div class="line"><a name="l10712"></a><span class="lineno">10712</span>  <span class="comment">// use /sdcard.</span></div><div class="line"><a name="l10713"></a><span class="lineno">10713</span>  <span class="keywordtype">char</span> name_template[] = <span class="stringliteral">"/sdcard/gtest_captured_stream.XXXXXX"</span>;</div><div class="line"><a name="l10714"></a><span class="lineno">10714</span> <span class="preprocessor"># else</span></div><div class="line"><a name="l10715"></a><span class="lineno">10715</span>  <span class="keywordtype">char</span> name_template[] = <span class="stringliteral">"/tmp/captured_stream.XXXXXX"</span>;</div><div class="line"><a name="l10716"></a><span class="lineno">10716</span> <span class="preprocessor"># endif // GTEST_OS_LINUX_ANDROID</span></div><div class="line"><a name="l10717"></a><span class="lineno">10717</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> captured_fd = mkstemp(name_template);</div><div class="line"><a name="l10718"></a><span class="lineno">10718</span>  filename_ = name_template;</div><div class="line"><a name="l10719"></a><span class="lineno">10719</span> <span class="preprocessor"># endif // GTEST_OS_WINDOWS</span></div><div class="line"><a name="l10720"></a><span class="lineno">10720</span>  fflush(<span class="keyword">nullptr</span>);</div><div class="line"><a name="l10721"></a><span class="lineno">10721</span>  dup2(captured_fd, fd_);</div><div class="line"><a name="l10722"></a><span class="lineno">10722</span>  close(captured_fd);</div><div class="line"><a name="l10723"></a><span class="lineno">10723</span>  }</div><div class="line"><a name="l10724"></a><span class="lineno">10724</span> </div><div class="line"><a name="l10725"></a><span class="lineno"><a class="line" href="classtesting_1_1internal_1_1_captured_stream.html#af215c7a9326cb5ca61e6b7ca8231dcf1">10725</a></span>  <a class="code" href="classtesting_1_1internal_1_1_captured_stream.html#af215c7a9326cb5ca61e6b7ca8231dcf1">~CapturedStream</a>() {</div><div class="line"><a name="l10726"></a><span class="lineno">10726</span>  <span class="keyword">remove</span>(filename_.c_str());</div><div class="line"><a name="l10727"></a><span class="lineno">10727</span>  }</div><div class="line"><a name="l10728"></a><span class="lineno">10728</span> </div><div class="line"><a name="l10729"></a><span class="lineno"><a class="line" href="classtesting_1_1internal_1_1_captured_stream.html#a48f400f12afb642387f91a5c20f7a528">10729</a></span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> <a class="code" href="classtesting_1_1internal_1_1_captured_stream.html#a48f400f12afb642387f91a5c20f7a528">GetCapturedString</a>() {</div><div class="line"><a name="l10730"></a><span class="lineno">10730</span>  <span class="keywordflow">if</span> (uncaptured_fd_ != -1) {</div><div class="line"><a name="l10731"></a><span class="lineno">10731</span>  <span class="comment">// Restores the original stream.</span></div><div class="line"><a name="l10732"></a><span class="lineno">10732</span>  fflush(<span class="keyword">nullptr</span>);</div><div class="line"><a name="l10733"></a><span class="lineno">10733</span>  dup2(uncaptured_fd_, fd_);</div><div class="line"><a name="l10734"></a><span class="lineno">10734</span>  close(uncaptured_fd_);</div><div class="line"><a name="l10735"></a><span class="lineno">10735</span>  uncaptured_fd_ = -1;</div><div class="line"><a name="l10736"></a><span class="lineno">10736</span>  }</div><div class="line"><a name="l10737"></a><span class="lineno">10737</span> </div><div class="line"><a name="l10738"></a><span class="lineno">10738</span>  FILE* <span class="keyword">const</span> file = <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a4042201dcc4932641d484e7ddf94de7d">posix::FOpen</a>(filename_.c_str(), <span class="stringliteral">"r"</span>);</div><div class="line"><a name="l10739"></a><span class="lineno">10739</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> content = <a class="code" href="namespacetesting_1_1internal.html#ab81b0af2a0131ea54dc11de00d5e6e51">ReadEntireFile</a>(file);</div><div class="line"><a name="l10740"></a><span class="lineno">10740</span>  <a class="code" href="namespacetesting_1_1internal_1_1posix.html#af4beeaaa8d62916d5e3b644a1ddfbd6b">posix::FClose</a>(file);</div><div class="line"><a name="l10741"></a><span class="lineno">10741</span>  <span class="keywordflow">return</span> content;</div><div class="line"><a name="l10742"></a><span class="lineno">10742</span>  }</div><div class="line"><a name="l10743"></a><span class="lineno">10743</span> </div><div class="line"><a name="l10744"></a><span class="lineno">10744</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l10745"></a><span class="lineno">10745</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> fd_; <span class="comment">// A stream to capture.</span></div><div class="line"><a name="l10746"></a><span class="lineno">10746</span>  <span class="keywordtype">int</span> uncaptured_fd_;</div><div class="line"><a name="l10747"></a><span class="lineno">10747</span>  <span class="comment">// Name of the temporary file holding the stderr output.</span></div><div class="line"><a name="l10748"></a><span class="lineno">10748</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">::std::string</a> filename_;</div><div class="line"><a name="l10749"></a><span class="lineno">10749</span> </div><div class="line"><a name="l10750"></a><span class="lineno">10750</span>  GTEST_DISALLOW_COPY_AND_ASSIGN_(<a class="code" href="classtesting_1_1internal_1_1_captured_stream.html">CapturedStream</a>);</div><div class="line"><a name="l10751"></a><span class="lineno">10751</span> };</div><div class="line"><a name="l10752"></a><span class="lineno">10752</span> </div><div class="line"><a name="l10753"></a><span class="lineno">10753</span> <a class="code" href="gtest_8h.html#aa0dc86dc9837f1610e91da65458f53b3">GTEST_DISABLE_MSC_DEPRECATED_POP_</a>()</div><div class="line"><a name="l10754"></a><span class="lineno">10754</span> </div><div class="line"><a name="l10755"></a><span class="lineno">10755</span> static CapturedStream* g_captured_stderr = <span class="keywordtype">nullptr</span>;</div><div class="line"><a name="l10756"></a><span class="lineno">10756</span> static CapturedStream* g_captured_stdout = <span class="keywordtype">nullptr</span>;</div><div class="line"><a name="l10757"></a><span class="lineno">10757</span> </div><div class="line"><a name="l10758"></a><span class="lineno">10758</span> <span class="comment">// Starts capturing an output stream (stdout/stderr).</span></div><div class="line"><a name="l10759"></a><span class="lineno">10759</span> static <span class="keywordtype">void</span> CaptureStream(<span class="keywordtype">int</span> fd, const <span class="keywordtype">char</span>* stream_name,</div><div class="line"><a name="l10760"></a><span class="lineno">10760</span>  CapturedStream** stream) {</div><div class="line"><a name="l10761"></a><span class="lineno">10761</span>  <span class="keywordflow">if</span> (*stream != <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l10762"></a><span class="lineno">10762</span>  <a class="code" href="gtest_8h.html#a8ef4cb4c465db8c15464aecc6d9510ef">GTEST_LOG_</a>(FATAL) << <span class="stringliteral">"Only one "</span> << stream_name</div><div class="line"><a name="l10763"></a><span class="lineno">10763</span>  << <span class="stringliteral">" capturer can exist at a time."</span>;</div><div class="line"><a name="l10764"></a><span class="lineno">10764</span>  }</div><div class="line"><a name="l10765"></a><span class="lineno">10765</span>  *stream = <span class="keyword">new</span> CapturedStream(fd);</div><div class="line"><a name="l10766"></a><span class="lineno">10766</span> }</div><div class="line"><a name="l10767"></a><span class="lineno">10767</span> </div><div class="line"><a name="l10768"></a><span class="lineno">10768</span> <span class="comment">// Stops capturing the output stream and returns the captured string.</span></div><div class="line"><a name="l10769"></a><span class="lineno">10769</span> <span class="keyword">static</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> GetCapturedStream(CapturedStream** captured_stream) {</div><div class="line"><a name="l10770"></a><span class="lineno">10770</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> content = (*captured_stream)->GetCapturedString();</div><div class="line"><a name="l10771"></a><span class="lineno">10771</span> </div><div class="line"><a name="l10772"></a><span class="lineno">10772</span>  <span class="keyword">delete</span> *captured_stream;</div><div class="line"><a name="l10773"></a><span class="lineno">10773</span>  *captured_stream = <span class="keyword">nullptr</span>;</div><div class="line"><a name="l10774"></a><span class="lineno">10774</span> </div><div class="line"><a name="l10775"></a><span class="lineno">10775</span>  <span class="keywordflow">return</span> content;</div><div class="line"><a name="l10776"></a><span class="lineno">10776</span> }</div><div class="line"><a name="l10777"></a><span class="lineno">10777</span> </div><div class="line"><a name="l10778"></a><span class="lineno">10778</span> <span class="comment">// Starts capturing stdout.</span></div><div class="line"><a name="l10779"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#acba06d4f0343dec407738ba5544af990">10779</a></span> <span class="keywordtype">void</span> <a class="code" href="namespacetesting_1_1internal.html#acba06d4f0343dec407738ba5544af990">CaptureStdout</a>() {</div><div class="line"><a name="l10780"></a><span class="lineno">10780</span>  CaptureStream(<a class="code" href="namespacetesting_1_1internal.html#a24f0a3d50cac54a9132f4828ec9b96d9">kStdOutFileno</a>, <span class="stringliteral">"stdout"</span>, &g_captured_stdout);</div><div class="line"><a name="l10781"></a><span class="lineno">10781</span> }</div><div class="line"><a name="l10782"></a><span class="lineno">10782</span> </div><div class="line"><a name="l10783"></a><span class="lineno">10783</span> <span class="comment">// Starts capturing stderr.</span></div><div class="line"><a name="l10784"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#a8ec00d458d0d442bd64af7b5f9c22dda">10784</a></span> <span class="keywordtype">void</span> <a class="code" href="namespacetesting_1_1internal.html#a8ec00d458d0d442bd64af7b5f9c22dda">CaptureStderr</a>() {</div><div class="line"><a name="l10785"></a><span class="lineno">10785</span>  CaptureStream(<a class="code" href="namespacetesting_1_1internal.html#a747eccfdbdee3ff8af3bedc476a57c85">kStdErrFileno</a>, <span class="stringliteral">"stderr"</span>, &g_captured_stderr);</div><div class="line"><a name="l10786"></a><span class="lineno">10786</span> }</div><div class="line"><a name="l10787"></a><span class="lineno">10787</span> </div><div class="line"><a name="l10788"></a><span class="lineno">10788</span> <span class="comment">// Stops capturing stdout and returns the captured string.</span></div><div class="line"><a name="l10789"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#aed657219a9856a8d249a3230de0c54ce">10789</a></span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> <a class="code" href="namespacetesting_1_1internal.html#aed657219a9856a8d249a3230de0c54ce">GetCapturedStdout</a>() {</div><div class="line"><a name="l10790"></a><span class="lineno">10790</span>  <span class="keywordflow">return</span> GetCapturedStream(&g_captured_stdout);</div><div class="line"><a name="l10791"></a><span class="lineno">10791</span> }</div><div class="line"><a name="l10792"></a><span class="lineno">10792</span> </div><div class="line"><a name="l10793"></a><span class="lineno">10793</span> <span class="comment">// Stops capturing stderr and returns the captured string.</span></div><div class="line"><a name="l10794"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#a374156401da17704099d0c33fa53adfb">10794</a></span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> <a class="code" href="namespacetesting_1_1internal.html#a374156401da17704099d0c33fa53adfb">GetCapturedStderr</a>() {</div><div class="line"><a name="l10795"></a><span class="lineno">10795</span>  <span class="keywordflow">return</span> GetCapturedStream(&g_captured_stderr);</div><div class="line"><a name="l10796"></a><span class="lineno">10796</span> }</div><div class="line"><a name="l10797"></a><span class="lineno">10797</span> </div><div class="line"><a name="l10798"></a><span class="lineno">10798</span> <span class="preprocessor">#endif // GTEST_HAS_STREAM_REDIRECTION</span></div><div class="line"><a name="l10799"></a><span class="lineno">10799</span> </div><div class="line"><a name="l10800"></a><span class="lineno">10800</span> </div><div class="line"><a name="l10801"></a><span class="lineno">10801</span> </div><div class="line"><a name="l10802"></a><span class="lineno">10802</span> </div><div class="line"><a name="l10803"></a><span class="lineno">10803</span> </div><div class="line"><a name="l10804"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#a40bcfd87e26aae36e0cc51e5db64fd89">10804</a></span> <span class="keywordtype">size_t</span> <a class="code" href="namespacetesting_1_1internal.html#a40bcfd87e26aae36e0cc51e5db64fd89">GetFileSize</a>(FILE* file) {</div><div class="line"><a name="l10805"></a><span class="lineno">10805</span>  fseek(file, 0, SEEK_END);</div><div class="line"><a name="l10806"></a><span class="lineno">10806</span>  <span class="keywordflow">return</span> <span class="keyword">static_cast<</span><span class="keywordtype">size_t</span><span class="keyword">></span>(ftell(file));</div><div class="line"><a name="l10807"></a><span class="lineno">10807</span> }</div><div class="line"><a name="l10808"></a><span class="lineno">10808</span> </div><div class="line"><a name="l10809"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#ab81b0af2a0131ea54dc11de00d5e6e51">10809</a></span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> <a class="code" href="namespacetesting_1_1internal.html#ab81b0af2a0131ea54dc11de00d5e6e51">ReadEntireFile</a>(FILE* file) {</div><div class="line"><a name="l10810"></a><span class="lineno">10810</span>  <span class="keyword">const</span> <span class="keywordtype">size_t</span> file_size = <a class="code" href="namespacetesting_1_1internal.html#a40bcfd87e26aae36e0cc51e5db64fd89">GetFileSize</a>(file);</div><div class="line"><a name="l10811"></a><span class="lineno">10811</span>  <span class="keywordtype">char</span>* <span class="keyword">const</span> buffer = <span class="keyword">new</span> <span class="keywordtype">char</span>[file_size];</div><div class="line"><a name="l10812"></a><span class="lineno">10812</span> </div><div class="line"><a name="l10813"></a><span class="lineno">10813</span>  <span class="keywordtype">size_t</span> bytes_last_read = 0; <span class="comment">// # of bytes read in the last fread()</span></div><div class="line"><a name="l10814"></a><span class="lineno">10814</span>  <span class="keywordtype">size_t</span> bytes_read = 0; <span class="comment">// # of bytes read so far</span></div><div class="line"><a name="l10815"></a><span class="lineno">10815</span> </div><div class="line"><a name="l10816"></a><span class="lineno">10816</span>  fseek(file, 0, SEEK_SET);</div><div class="line"><a name="l10817"></a><span class="lineno">10817</span> </div><div class="line"><a name="l10818"></a><span class="lineno">10818</span>  <span class="comment">// Keeps reading the file until we cannot read further or the</span></div><div class="line"><a name="l10819"></a><span class="lineno">10819</span>  <span class="comment">// pre-determined file size is reached.</span></div><div class="line"><a name="l10820"></a><span class="lineno">10820</span>  <span class="keywordflow">do</span> {</div><div class="line"><a name="l10821"></a><span class="lineno">10821</span>  bytes_last_read = fread(buffer+bytes_read, 1, file_size-bytes_read, file);</div><div class="line"><a name="l10822"></a><span class="lineno">10822</span>  bytes_read += bytes_last_read;</div><div class="line"><a name="l10823"></a><span class="lineno">10823</span>  } <span class="keywordflow">while</span> (bytes_last_read > 0 && bytes_read < file_size);</div><div class="line"><a name="l10824"></a><span class="lineno">10824</span> </div><div class="line"><a name="l10825"></a><span class="lineno">10825</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> content(buffer, bytes_read);</div><div class="line"><a name="l10826"></a><span class="lineno">10826</span>  <span class="keyword">delete</span>[] buffer;</div><div class="line"><a name="l10827"></a><span class="lineno">10827</span> </div><div class="line"><a name="l10828"></a><span class="lineno">10828</span>  <span class="keywordflow">return</span> content;</div><div class="line"><a name="l10829"></a><span class="lineno">10829</span> }</div><div class="line"><a name="l10830"></a><span class="lineno">10830</span> </div><div class="line"><a name="l10831"></a><span class="lineno">10831</span> <span class="preprocessor">#if GTEST_HAS_DEATH_TEST</span></div><div class="line"><a name="l10832"></a><span class="lineno">10832</span> <span class="keyword">static</span> <span class="keyword">const</span> std::vector<std::string>* g_injected_test_argvs =</div><div class="line"><a name="l10833"></a><span class="lineno">10833</span>  <span class="keyword">nullptr</span>; <span class="comment">// Owned.</span></div><div class="line"><a name="l10834"></a><span class="lineno">10834</span> </div><div class="line"><a name="l10835"></a><span class="lineno">10835</span> std::vector<std::string> GetInjectableArgvs() {</div><div class="line"><a name="l10836"></a><span class="lineno">10836</span>  <span class="keywordflow">if</span> (g_injected_test_argvs != <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l10837"></a><span class="lineno">10837</span>  <span class="keywordflow">return</span> *g_injected_test_argvs;</div><div class="line"><a name="l10838"></a><span class="lineno">10838</span>  }</div><div class="line"><a name="l10839"></a><span class="lineno">10839</span>  <span class="keywordflow">return</span> <a class="code" href="namespacetesting_1_1internal.html#a8d8ed3acadedd9c0db28d35a188973ea">GetArgvs</a>();</div><div class="line"><a name="l10840"></a><span class="lineno">10840</span> }</div><div class="line"><a name="l10841"></a><span class="lineno">10841</span> </div><div class="line"><a name="l10842"></a><span class="lineno">10842</span> <span class="keywordtype">void</span> SetInjectableArgvs(<span class="keyword">const</span> std::vector<std::string>* new_argvs) {</div><div class="line"><a name="l10843"></a><span class="lineno">10843</span>  <span class="keywordflow">if</span> (g_injected_test_argvs != new_argvs) <span class="keyword">delete</span> g_injected_test_argvs;</div><div class="line"><a name="l10844"></a><span class="lineno">10844</span>  g_injected_test_argvs = new_argvs;</div><div class="line"><a name="l10845"></a><span class="lineno">10845</span> }</div><div class="line"><a name="l10846"></a><span class="lineno">10846</span> </div><div class="line"><a name="l10847"></a><span class="lineno">10847</span> <span class="keywordtype">void</span> SetInjectableArgvs(<span class="keyword">const</span> std::vector<std::string>& new_argvs) {</div><div class="line"><a name="l10848"></a><span class="lineno">10848</span>  SetInjectableArgvs(</div><div class="line"><a name="l10849"></a><span class="lineno">10849</span>  <span class="keyword">new</span> std::vector<std::string>(new_argvs.begin(), new_argvs.end()));</div><div class="line"><a name="l10850"></a><span class="lineno">10850</span> }</div><div class="line"><a name="l10851"></a><span class="lineno">10851</span> </div><div class="line"><a name="l10852"></a><span class="lineno">10852</span> <span class="preprocessor">#if GTEST_HAS_GLOBAL_STRING</span></div><div class="line"><a name="l10853"></a><span class="lineno">10853</span> <span class="keywordtype">void</span> SetInjectableArgvs(<span class="keyword">const</span> std::vector< ::string>& new_argvs) {</div><div class="line"><a name="l10854"></a><span class="lineno">10854</span>  SetInjectableArgvs(</div><div class="line"><a name="l10855"></a><span class="lineno">10855</span>  <span class="keyword">new</span> std::vector<std::string>(new_argvs.begin(), new_argvs.end()));</div><div class="line"><a name="l10856"></a><span class="lineno">10856</span> }</div><div class="line"><a name="l10857"></a><span class="lineno">10857</span> <span class="preprocessor">#endif // GTEST_HAS_GLOBAL_STRING</span></div><div class="line"><a name="l10858"></a><span class="lineno">10858</span> </div><div class="line"><a name="l10859"></a><span class="lineno">10859</span> <span class="keywordtype">void</span> ClearInjectableArgvs() {</div><div class="line"><a name="l10860"></a><span class="lineno">10860</span>  <span class="keyword">delete</span> g_injected_test_argvs;</div><div class="line"><a name="l10861"></a><span class="lineno">10861</span>  g_injected_test_argvs = <span class="keyword">nullptr</span>;</div><div class="line"><a name="l10862"></a><span class="lineno">10862</span> }</div><div class="line"><a name="l10863"></a><span class="lineno">10863</span> <span class="preprocessor">#endif // GTEST_HAS_DEATH_TEST</span></div><div class="line"><a name="l10864"></a><span class="lineno">10864</span> </div><div class="line"><a name="l10865"></a><span class="lineno">10865</span> <span class="preprocessor">#if GTEST_OS_WINDOWS_MOBILE</span></div><div class="line"><a name="l10866"></a><span class="lineno">10866</span> <span class="keyword">namespace </span>posix {</div><div class="line"><a name="l10867"></a><span class="lineno">10867</span> <span class="keywordtype">void</span> <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a69b8278c59359dd6a6f941b4643db9fb">Abort</a>() {</div><div class="line"><a name="l10868"></a><span class="lineno">10868</span>  DebugBreak();</div><div class="line"><a name="l10869"></a><span class="lineno">10869</span>  TerminateProcess(GetCurrentProcess(), 1);</div><div class="line"><a name="l10870"></a><span class="lineno">10870</span> }</div><div class="line"><a name="l10871"></a><span class="lineno">10871</span> } <span class="comment">// namespace posix</span></div><div class="line"><a name="l10872"></a><span class="lineno">10872</span> <span class="preprocessor">#endif // GTEST_OS_WINDOWS_MOBILE</span></div><div class="line"><a name="l10873"></a><span class="lineno">10873</span> </div><div class="line"><a name="l10874"></a><span class="lineno">10874</span> <span class="comment">// Returns the name of the environment variable corresponding to the</span></div><div class="line"><a name="l10875"></a><span class="lineno">10875</span> <span class="comment">// given flag. For example, FlagToEnvVar("foo") will return</span></div><div class="line"><a name="l10876"></a><span class="lineno">10876</span> <span class="comment">// "GTEST_FOO" in the open-source version.</span></div><div class="line"><a name="l10877"></a><span class="lineno">10877</span> <span class="keyword">static</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> FlagToEnvVar(<span class="keyword">const</span> <span class="keywordtype">char</span>* flag) {</div><div class="line"><a name="l10878"></a><span class="lineno">10878</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> full_flag =</div><div class="line"><a name="l10879"></a><span class="lineno">10879</span>  (Message() << <a class="code" href="gtest_8h.html#a088e84784c589ba9b1fc48602ad8eabf">GTEST_FLAG_PREFIX_</a> << flag).GetString();</div><div class="line"><a name="l10880"></a><span class="lineno">10880</span> </div><div class="line"><a name="l10881"></a><span class="lineno">10881</span>  Message env_var;</div><div class="line"><a name="l10882"></a><span class="lineno">10882</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i != full_flag.length(); i++) {</div><div class="line"><a name="l10883"></a><span class="lineno">10883</span>  env_var << <a class="code" href="namespacetesting_1_1internal.html#ac1b876a8133895bd553d4780ecaa1e3a">ToUpper</a>(full_flag.c_str()[i]);</div><div class="line"><a name="l10884"></a><span class="lineno">10884</span>  }</div><div class="line"><a name="l10885"></a><span class="lineno">10885</span> </div><div class="line"><a name="l10886"></a><span class="lineno">10886</span>  <span class="keywordflow">return</span> env_var.GetString();</div><div class="line"><a name="l10887"></a><span class="lineno">10887</span> }</div><div class="line"><a name="l10888"></a><span class="lineno">10888</span> </div><div class="line"><a name="l10889"></a><span class="lineno">10889</span> <span class="comment">// Parses 'str' for a 32-bit signed integer. If successful, writes</span></div><div class="line"><a name="l10890"></a><span class="lineno">10890</span> <span class="comment">// the result to *value and returns true; otherwise leaves *value</span></div><div class="line"><a name="l10891"></a><span class="lineno">10891</span> <span class="comment">// unchanged and returns false.</span></div><div class="line"><a name="l10892"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#ac06fc81336a3d80755f4020d34321766">10892</a></span> <span class="keywordtype">bool</span> <a class="code" href="namespacetesting_1_1internal.html#ac06fc81336a3d80755f4020d34321766">ParseInt32</a>(<span class="keyword">const</span> <a class="code" href="classtesting_1_1_message.html">Message</a>& src_text, <span class="keyword">const</span> <span class="keywordtype">char</span>* str, <a class="code" href="namespacetesting_1_1internal.html#a8ee38faaf875f133358abaf9bc056cec">Int32</a>* value) {</div><div class="line"><a name="l10893"></a><span class="lineno">10893</span>  <span class="comment">// Parses the environment variable as a decimal integer.</span></div><div class="line"><a name="l10894"></a><span class="lineno">10894</span>  <span class="keywordtype">char</span>* end = <span class="keyword">nullptr</span>;</div><div class="line"><a name="l10895"></a><span class="lineno">10895</span>  <span class="keyword">const</span> <span class="keywordtype">long</span> long_value = strtol(str, &end, 10); <span class="comment">// NOLINT</span></div><div class="line"><a name="l10896"></a><span class="lineno">10896</span> </div><div class="line"><a name="l10897"></a><span class="lineno">10897</span>  <span class="comment">// Has strtol() consumed all characters in the string?</span></div><div class="line"><a name="l10898"></a><span class="lineno">10898</span>  <span class="keywordflow">if</span> (*end != <span class="charliteral">'\0'</span>) {</div><div class="line"><a name="l10899"></a><span class="lineno">10899</span>  <span class="comment">// No - an invalid character was encountered.</span></div><div class="line"><a name="l10900"></a><span class="lineno">10900</span>  <a class="code" href="classtesting_1_1_message.html">Message</a> msg;</div><div class="line"><a name="l10901"></a><span class="lineno">10901</span>  msg << <span class="stringliteral">"WARNING: "</span> << src_text</div><div class="line"><a name="l10902"></a><span class="lineno">10902</span>  << <span class="stringliteral">" is expected to be a 32-bit integer, but actually"</span></div><div class="line"><a name="l10903"></a><span class="lineno">10903</span>  << <span class="stringliteral">" has value \""</span> << str << <span class="stringliteral">"\".\n"</span>;</div><div class="line"><a name="l10904"></a><span class="lineno">10904</span>  printf(<span class="stringliteral">"%s"</span>, msg.<a class="code" href="classtesting_1_1_message.html#a2cdc4df62bdcc9df37651a1cf527704e">GetString</a>().c_str());</div><div class="line"><a name="l10905"></a><span class="lineno">10905</span>  fflush(stdout);</div><div class="line"><a name="l10906"></a><span class="lineno">10906</span>  <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l10907"></a><span class="lineno">10907</span>  }</div><div class="line"><a name="l10908"></a><span class="lineno">10908</span> </div><div class="line"><a name="l10909"></a><span class="lineno">10909</span>  <span class="comment">// Is the parsed value in the range of an Int32?</span></div><div class="line"><a name="l10910"></a><span class="lineno">10910</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8ee38faaf875f133358abaf9bc056cec">Int32</a> result = <span class="keyword">static_cast<</span><a class="code" href="namespacetesting_1_1internal.html#a8ee38faaf875f133358abaf9bc056cec">Int32</a><span class="keyword">></span>(long_value);</div><div class="line"><a name="l10911"></a><span class="lineno">10911</span>  <span class="keywordflow">if</span> (long_value == LONG_MAX || long_value == LONG_MIN ||</div><div class="line"><a name="l10912"></a><span class="lineno">10912</span>  <span class="comment">// The parsed value overflows as a long. (strtol() returns</span></div><div class="line"><a name="l10913"></a><span class="lineno">10913</span>  <span class="comment">// LONG_MAX or LONG_MIN when the input overflows.)</span></div><div class="line"><a name="l10914"></a><span class="lineno">10914</span>  result != long_value</div><div class="line"><a name="l10915"></a><span class="lineno">10915</span>  <span class="comment">// The parsed value overflows as an Int32.</span></div><div class="line"><a name="l10916"></a><span class="lineno">10916</span>  ) {</div><div class="line"><a name="l10917"></a><span class="lineno">10917</span>  <a class="code" href="classtesting_1_1_message.html">Message</a> msg;</div><div class="line"><a name="l10918"></a><span class="lineno">10918</span>  msg << <span class="stringliteral">"WARNING: "</span> << src_text</div><div class="line"><a name="l10919"></a><span class="lineno">10919</span>  << <span class="stringliteral">" is expected to be a 32-bit integer, but actually"</span></div><div class="line"><a name="l10920"></a><span class="lineno">10920</span>  << <span class="stringliteral">" has value "</span> << str << <span class="stringliteral">", which overflows.\n"</span>;</div><div class="line"><a name="l10921"></a><span class="lineno">10921</span>  printf(<span class="stringliteral">"%s"</span>, msg.<a class="code" href="classtesting_1_1_message.html#a2cdc4df62bdcc9df37651a1cf527704e">GetString</a>().c_str());</div><div class="line"><a name="l10922"></a><span class="lineno">10922</span>  fflush(stdout);</div><div class="line"><a name="l10923"></a><span class="lineno">10923</span>  <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l10924"></a><span class="lineno">10924</span>  }</div><div class="line"><a name="l10925"></a><span class="lineno">10925</span> </div><div class="line"><a name="l10926"></a><span class="lineno">10926</span>  *value = result;</div><div class="line"><a name="l10927"></a><span class="lineno">10927</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l10928"></a><span class="lineno">10928</span> }</div><div class="line"><a name="l10929"></a><span class="lineno">10929</span> </div><div class="line"><a name="l10930"></a><span class="lineno">10930</span> <span class="comment">// Reads and returns the Boolean environment variable corresponding to</span></div><div class="line"><a name="l10931"></a><span class="lineno">10931</span> <span class="comment">// the given flag; if it's not set, returns default_value.</span></div><div class="line"><a name="l10932"></a><span class="lineno">10932</span> <span class="comment">//</span></div><div class="line"><a name="l10933"></a><span class="lineno">10933</span> <span class="comment">// The value is considered true iff it's not "0".</span></div><div class="line"><a name="l10934"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#a1055088bb9b867e1b7b8f096f519d7c5">10934</a></span> <span class="keywordtype">bool</span> <a class="code" href="namespacetesting_1_1internal.html#a1055088bb9b867e1b7b8f096f519d7c5">BoolFromGTestEnv</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* flag, <span class="keywordtype">bool</span> default_value) {</div><div class="line"><a name="l10935"></a><span class="lineno">10935</span> <span class="preprocessor">#if defined(GTEST_GET_BOOL_FROM_ENV_)</span></div><div class="line"><a name="l10936"></a><span class="lineno">10936</span>  <span class="keywordflow">return</span> GTEST_GET_BOOL_FROM_ENV_(flag, default_value);</div><div class="line"><a name="l10937"></a><span class="lineno">10937</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l10938"></a><span class="lineno">10938</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> env_var = FlagToEnvVar(flag);</div><div class="line"><a name="l10939"></a><span class="lineno">10939</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> string_value = <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a1d5e3da5a27eed25986859fa83cafe95">posix::GetEnv</a>(env_var.c_str());</div><div class="line"><a name="l10940"></a><span class="lineno">10940</span>  <span class="keywordflow">return</span> string_value == <span class="keyword">nullptr</span> ? default_value</div><div class="line"><a name="l10941"></a><span class="lineno">10941</span>  : strcmp(string_value, <span class="stringliteral">"0"</span>) != 0;</div><div class="line"><a name="l10942"></a><span class="lineno">10942</span> <span class="preprocessor">#endif // defined(GTEST_GET_BOOL_FROM_ENV_)</span></div><div class="line"><a name="l10943"></a><span class="lineno">10943</span> }</div><div class="line"><a name="l10944"></a><span class="lineno">10944</span> </div><div class="line"><a name="l10945"></a><span class="lineno">10945</span> <span class="comment">// Reads and returns a 32-bit integer stored in the environment</span></div><div class="line"><a name="l10946"></a><span class="lineno">10946</span> <span class="comment">// variable corresponding to the given flag; if it isn't set or</span></div><div class="line"><a name="l10947"></a><span class="lineno">10947</span> <span class="comment">// doesn't represent a valid 32-bit integer, returns default_value.</span></div><div class="line"><a name="l10948"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#a2196f070b2d28bceb45c7ad3b565b9ba">10948</a></span> <a class="code" href="namespacetesting_1_1internal.html#a8ee38faaf875f133358abaf9bc056cec">Int32</a> <a class="code" href="namespacetesting_1_1internal.html#a2196f070b2d28bceb45c7ad3b565b9ba">Int32FromGTestEnv</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* flag, <a class="code" href="namespacetesting_1_1internal.html#a8ee38faaf875f133358abaf9bc056cec">Int32</a> default_value) {</div><div class="line"><a name="l10949"></a><span class="lineno">10949</span> <span class="preprocessor">#if defined(GTEST_GET_INT32_FROM_ENV_)</span></div><div class="line"><a name="l10950"></a><span class="lineno">10950</span>  <span class="keywordflow">return</span> GTEST_GET_INT32_FROM_ENV_(flag, default_value);</div><div class="line"><a name="l10951"></a><span class="lineno">10951</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l10952"></a><span class="lineno">10952</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> env_var = FlagToEnvVar(flag);</div><div class="line"><a name="l10953"></a><span class="lineno">10953</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> string_value = <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a1d5e3da5a27eed25986859fa83cafe95">posix::GetEnv</a>(env_var.c_str());</div><div class="line"><a name="l10954"></a><span class="lineno">10954</span>  <span class="keywordflow">if</span> (string_value == <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l10955"></a><span class="lineno">10955</span>  <span class="comment">// The environment variable is not set.</span></div><div class="line"><a name="l10956"></a><span class="lineno">10956</span>  <span class="keywordflow">return</span> default_value;</div><div class="line"><a name="l10957"></a><span class="lineno">10957</span>  }</div><div class="line"><a name="l10958"></a><span class="lineno">10958</span> </div><div class="line"><a name="l10959"></a><span class="lineno">10959</span>  <a class="code" href="namespacetesting_1_1internal.html#a8ee38faaf875f133358abaf9bc056cec">Int32</a> result = default_value;</div><div class="line"><a name="l10960"></a><span class="lineno">10960</span>  <span class="keywordflow">if</span> (!<a class="code" href="namespacetesting_1_1internal.html#ac06fc81336a3d80755f4020d34321766">ParseInt32</a>(<a class="code" href="classtesting_1_1_message.html">Message</a>() << <span class="stringliteral">"Environment variable "</span> << env_var,</div><div class="line"><a name="l10961"></a><span class="lineno">10961</span>  string_value, &result)) {</div><div class="line"><a name="l10962"></a><span class="lineno">10962</span>  printf(<span class="stringliteral">"The default value %s is used.\n"</span>,</div><div class="line"><a name="l10963"></a><span class="lineno">10963</span>  (<a class="code" href="classtesting_1_1_message.html">Message</a>() << default_value).GetString().c_str());</div><div class="line"><a name="l10964"></a><span class="lineno">10964</span>  fflush(stdout);</div><div class="line"><a name="l10965"></a><span class="lineno">10965</span>  <span class="keywordflow">return</span> default_value;</div><div class="line"><a name="l10966"></a><span class="lineno">10966</span>  }</div><div class="line"><a name="l10967"></a><span class="lineno">10967</span> </div><div class="line"><a name="l10968"></a><span class="lineno">10968</span>  <span class="keywordflow">return</span> result;</div><div class="line"><a name="l10969"></a><span class="lineno">10969</span> <span class="preprocessor">#endif // defined(GTEST_GET_INT32_FROM_ENV_)</span></div><div class="line"><a name="l10970"></a><span class="lineno">10970</span> }</div><div class="line"><a name="l10971"></a><span class="lineno">10971</span> </div><div class="line"><a name="l10972"></a><span class="lineno">10972</span> <span class="comment">// As a special case for the 'output' flag, if GTEST_OUTPUT is not</span></div><div class="line"><a name="l10973"></a><span class="lineno">10973</span> <span class="comment">// set, we look for XML_OUTPUT_FILE, which is set by the Bazel build</span></div><div class="line"><a name="l10974"></a><span class="lineno">10974</span> <span class="comment">// system. The value of XML_OUTPUT_FILE is a filename without the</span></div><div class="line"><a name="l10975"></a><span class="lineno">10975</span> <span class="comment">// "xml:" prefix of GTEST_OUTPUT.</span></div><div class="line"><a name="l10976"></a><span class="lineno">10976</span> <span class="comment">// Note that this is meant to be called at the call site so it does</span></div><div class="line"><a name="l10977"></a><span class="lineno">10977</span> <span class="comment">// not check that the flag is 'output'</span></div><div class="line"><a name="l10978"></a><span class="lineno">10978</span> <span class="comment">// In essence this checks an env variable called XML_OUTPUT_FILE</span></div><div class="line"><a name="l10979"></a><span class="lineno">10979</span> <span class="comment">// and if it is set we prepend "xml:" to its value, if it not set we return ""</span></div><div class="line"><a name="l10980"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#a0c793c6d84760d900299916c077a1af4">10980</a></span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> <a class="code" href="namespacetesting_1_1internal.html#a0c793c6d84760d900299916c077a1af4">OutputFlagAlsoCheckEnvVar</a>(){</div><div class="line"><a name="l10981"></a><span class="lineno">10981</span>  <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> default_value_for_output_flag = <span class="stringliteral">""</span>;</div><div class="line"><a name="l10982"></a><span class="lineno">10982</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* xml_output_file_env = <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a1d5e3da5a27eed25986859fa83cafe95">posix::GetEnv</a>(<span class="stringliteral">"XML_OUTPUT_FILE"</span>);</div><div class="line"><a name="l10983"></a><span class="lineno">10983</span>  <span class="keywordflow">if</span> (<span class="keyword">nullptr</span> != xml_output_file_env) {</div><div class="line"><a name="l10984"></a><span class="lineno">10984</span>  default_value_for_output_flag = <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(<span class="stringliteral">"xml:"</span>) + xml_output_file_env;</div><div class="line"><a name="l10985"></a><span class="lineno">10985</span>  }</div><div class="line"><a name="l10986"></a><span class="lineno">10986</span>  <span class="keywordflow">return</span> default_value_for_output_flag;</div><div class="line"><a name="l10987"></a><span class="lineno">10987</span> }</div><div class="line"><a name="l10988"></a><span class="lineno">10988</span> </div><div class="line"><a name="l10989"></a><span class="lineno">10989</span> <span class="comment">// Reads and returns the string environment variable corresponding to</span></div><div class="line"><a name="l10990"></a><span class="lineno">10990</span> <span class="comment">// the given flag; if it's not set, returns default_value.</span></div><div class="line"><a name="l10991"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#a0967cbf18fb1594f82512d8d822aba21">10991</a></span> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="namespacetesting_1_1internal.html#a0967cbf18fb1594f82512d8d822aba21">StringFromGTestEnv</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* flag, <span class="keyword">const</span> <span class="keywordtype">char</span>* default_value) {</div><div class="line"><a name="l10992"></a><span class="lineno">10992</span> <span class="preprocessor">#if defined(GTEST_GET_STRING_FROM_ENV_)</span></div><div class="line"><a name="l10993"></a><span class="lineno">10993</span>  <span class="keywordflow">return</span> GTEST_GET_STRING_FROM_ENV_(flag, default_value);</div><div class="line"><a name="l10994"></a><span class="lineno">10994</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l10995"></a><span class="lineno">10995</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> env_var = FlagToEnvVar(flag);</div><div class="line"><a name="l10996"></a><span class="lineno">10996</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> value = <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a1d5e3da5a27eed25986859fa83cafe95">posix::GetEnv</a>(env_var.c_str());</div><div class="line"><a name="l10997"></a><span class="lineno">10997</span>  <span class="keywordflow">return</span> value == <span class="keyword">nullptr</span> ? default_value : value;</div><div class="line"><a name="l10998"></a><span class="lineno">10998</span> <span class="preprocessor">#endif // defined(GTEST_GET_STRING_FROM_ENV_)</span></div><div class="line"><a name="l10999"></a><span class="lineno">10999</span> }</div><div class="line"><a name="l11000"></a><span class="lineno">11000</span> </div><div class="line"><a name="l11001"></a><span class="lineno">11001</span> } <span class="comment">// namespace internal</span></div><div class="line"><a name="l11002"></a><span class="lineno">11002</span> } <span class="comment">// namespace testing</span></div><div class="line"><a name="l11003"></a><span class="lineno">11003</span> <span class="comment">// Copyright 2007, Google Inc.</span></div><div class="line"><a name="l11004"></a><span class="lineno">11004</span> <span class="comment">// All rights reserved.</span></div><div class="line"><a name="l11005"></a><span class="lineno">11005</span> <span class="comment">//</span></div><div class="line"><a name="l11006"></a><span class="lineno">11006</span> <span class="comment">// Redistribution and use in source and binary forms, with or without</span></div><div class="line"><a name="l11007"></a><span class="lineno">11007</span> <span class="comment">// modification, are permitted provided that the following conditions are</span></div><div class="line"><a name="l11008"></a><span class="lineno">11008</span> <span class="comment">// met:</span></div><div class="line"><a name="l11009"></a><span class="lineno">11009</span> <span class="comment">//</span></div><div class="line"><a name="l11010"></a><span class="lineno">11010</span> <span class="comment">// * Redistributions of source code must retain the above copyright</span></div><div class="line"><a name="l11011"></a><span class="lineno">11011</span> <span class="comment">// notice, this list of conditions and the following disclaimer.</span></div><div class="line"><a name="l11012"></a><span class="lineno">11012</span> <span class="comment">// * Redistributions in binary form must reproduce the above</span></div><div class="line"><a name="l11013"></a><span class="lineno">11013</span> <span class="comment">// copyright notice, this list of conditions and the following disclaimer</span></div><div class="line"><a name="l11014"></a><span class="lineno">11014</span> <span class="comment">// in the documentation and/or other materials provided with the</span></div><div class="line"><a name="l11015"></a><span class="lineno">11015</span> <span class="comment">// distribution.</span></div><div class="line"><a name="l11016"></a><span class="lineno">11016</span> <span class="comment">// * Neither the name of Google Inc. nor the names of its</span></div><div class="line"><a name="l11017"></a><span class="lineno">11017</span> <span class="comment">// contributors may be used to endorse or promote products derived from</span></div><div class="line"><a name="l11018"></a><span class="lineno">11018</span> <span class="comment">// this software without specific prior written permission.</span></div><div class="line"><a name="l11019"></a><span class="lineno">11019</span> <span class="comment">//</span></div><div class="line"><a name="l11020"></a><span class="lineno">11020</span> <span class="comment">// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span></div><div class="line"><a name="l11021"></a><span class="lineno">11021</span> <span class="comment">// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</span></div><div class="line"><a name="l11022"></a><span class="lineno">11022</span> <span class="comment">// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR</span></div><div class="line"><a name="l11023"></a><span class="lineno">11023</span> <span class="comment">// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT</span></div><div class="line"><a name="l11024"></a><span class="lineno">11024</span> <span class="comment">// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span></div><div class="line"><a name="l11025"></a><span class="lineno">11025</span> <span class="comment">// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</span></div><div class="line"><a name="l11026"></a><span class="lineno">11026</span> <span class="comment">// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</span></div><div class="line"><a name="l11027"></a><span class="lineno">11027</span> <span class="comment">// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY</span></div><div class="line"><a name="l11028"></a><span class="lineno">11028</span> <span class="comment">// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span></div><div class="line"><a name="l11029"></a><span class="lineno">11029</span> <span class="comment">// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE</span></div><div class="line"><a name="l11030"></a><span class="lineno">11030</span> <span class="comment">// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span></div><div class="line"><a name="l11031"></a><span class="lineno">11031</span> </div><div class="line"><a name="l11032"></a><span class="lineno">11032</span> </div><div class="line"><a name="l11033"></a><span class="lineno">11033</span> <span class="comment">// Google Test - The Google C++ Testing and Mocking Framework</span></div><div class="line"><a name="l11034"></a><span class="lineno">11034</span> <span class="comment">//</span></div><div class="line"><a name="l11035"></a><span class="lineno">11035</span> <span class="comment">// This file implements a universal value printer that can print a</span></div><div class="line"><a name="l11036"></a><span class="lineno">11036</span> <span class="comment">// value of any type T:</span></div><div class="line"><a name="l11037"></a><span class="lineno">11037</span> <span class="comment">//</span></div><div class="line"><a name="l11038"></a><span class="lineno">11038</span> <span class="comment">// void ::testing::internal::UniversalPrinter<T>::Print(value, ostream_ptr);</span></div><div class="line"><a name="l11039"></a><span class="lineno">11039</span> <span class="comment">//</span></div><div class="line"><a name="l11040"></a><span class="lineno">11040</span> <span class="comment">// It uses the << operator when possible, and prints the bytes in the</span></div><div class="line"><a name="l11041"></a><span class="lineno">11041</span> <span class="comment">// object otherwise. A user can override its behavior for a class</span></div><div class="line"><a name="l11042"></a><span class="lineno">11042</span> <span class="comment">// type Foo by defining either operator<<(::std::ostream&, const Foo&)</span></div><div class="line"><a name="l11043"></a><span class="lineno">11043</span> <span class="comment">// or void PrintTo(const Foo&, ::std::ostream*) in the namespace that</span></div><div class="line"><a name="l11044"></a><span class="lineno">11044</span> <span class="comment">// defines Foo.</span></div><div class="line"><a name="l11045"></a><span class="lineno">11045</span> </div><div class="line"><a name="l11046"></a><span class="lineno">11046</span> <span class="preprocessor">#include <stdio.h></span></div><div class="line"><a name="l11047"></a><span class="lineno">11047</span> <span class="preprocessor">#include <cctype></span></div><div class="line"><a name="l11048"></a><span class="lineno">11048</span> <span class="preprocessor">#include <cwchar></span></div><div class="line"><a name="l11049"></a><span class="lineno">11049</span> <span class="preprocessor">#include <ostream></span> <span class="comment">// NOLINT</span></div><div class="line"><a name="l11050"></a><span class="lineno">11050</span> <span class="preprocessor">#include <string></span></div><div class="line"><a name="l11051"></a><span class="lineno">11051</span> </div><div class="line"><a name="l11052"></a><span class="lineno">11052</span> <span class="keyword">namespace </span><a class="code" href="namespacetesting.html">testing</a> {</div><div class="line"><a name="l11053"></a><span class="lineno">11053</span> </div><div class="line"><a name="l11054"></a><span class="lineno">11054</span> <span class="keyword">namespace </span>{</div><div class="line"><a name="l11055"></a><span class="lineno">11055</span> </div><div class="line"><a name="l11056"></a><span class="lineno">11056</span> using ::std::ostream;</div><div class="line"><a name="l11057"></a><span class="lineno">11057</span> </div><div class="line"><a name="l11058"></a><span class="lineno">11058</span> <span class="comment">// Prints a segment of bytes in the given object.</span></div><div class="line"><a name="l11059"></a><span class="lineno">11059</span> <a class="code" href="gtest_8h.html#a2a83dd79037e53814a509cc3f5702650">GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_</a></div><div class="line"><a name="l11060"></a><span class="lineno">11060</span> <a class="code" href="gtest_8h.html#af18b465f4ba6e36eea7a8d2d79521873">GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_</a></div><div class="line"><a name="l11061"></a><span class="lineno">11061</span> <a class="code" href="gtest_8h.html#abf30a6b1b3a12ecb2cc1bc1a6f5f9646">GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_</a></div><div class="line"><a name="l11062"></a><span class="lineno">11062</span> <span class="keywordtype">void</span> PrintByteSegmentInObjectTo(<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>* obj_bytes, <span class="keywordtype">size_t</span> start,</div><div class="line"><a name="l11063"></a><span class="lineno">11063</span>  <span class="keywordtype">size_t</span> <a class="code" href="namespaceutl_1_1meta.html#ab5508236016638fa8e6b97cd17dfc9c2">count</a>, ostream* os) {</div><div class="line"><a name="l11064"></a><span class="lineno">11064</span>  <span class="keywordtype">char</span> text[5] = <span class="stringliteral">""</span>;</div><div class="line"><a name="l11065"></a><span class="lineno">11065</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i != <a class="code" href="namespaceutl_1_1meta.html#ab5508236016638fa8e6b97cd17dfc9c2">count</a>; i++) {</div><div class="line"><a name="l11066"></a><span class="lineno">11066</span>  <span class="keyword">const</span> <span class="keywordtype">size_t</span> j = start + i;</div><div class="line"><a name="l11067"></a><span class="lineno">11067</span>  <span class="keywordflow">if</span> (i != 0) {</div><div class="line"><a name="l11068"></a><span class="lineno">11068</span>  <span class="comment">// Organizes the bytes into groups of 2 for easy parsing by</span></div><div class="line"><a name="l11069"></a><span class="lineno">11069</span>  <span class="comment">// human.</span></div><div class="line"><a name="l11070"></a><span class="lineno">11070</span>  <span class="keywordflow">if</span> ((j % 2) == 0)</div><div class="line"><a name="l11071"></a><span class="lineno">11071</span>  *os << <span class="charliteral">' '</span>;</div><div class="line"><a name="l11072"></a><span class="lineno">11072</span>  <span class="keywordflow">else</span></div><div class="line"><a name="l11073"></a><span class="lineno">11073</span>  *os << <span class="charliteral">'-'</span>;</div><div class="line"><a name="l11074"></a><span class="lineno">11074</span>  }</div><div class="line"><a name="l11075"></a><span class="lineno">11075</span>  <a class="code" href="gtest_8h.html#aed1cc8143222d7a845a1269448ec203e">GTEST_SNPRINTF_</a>(text, <span class="keyword">sizeof</span>(text), <span class="stringliteral">"%02X"</span>, obj_bytes[j]);</div><div class="line"><a name="l11076"></a><span class="lineno">11076</span>  *os << text;</div><div class="line"><a name="l11077"></a><span class="lineno">11077</span>  }</div><div class="line"><a name="l11078"></a><span class="lineno">11078</span> }</div><div class="line"><a name="l11079"></a><span class="lineno">11079</span> </div><div class="line"><a name="l11080"></a><span class="lineno">11080</span> <span class="comment">// Prints the bytes in the given value to the given ostream.</span></div><div class="line"><a name="l11081"></a><span class="lineno">11081</span> <span class="keywordtype">void</span> PrintBytesInObjectToImpl(<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>* obj_bytes, <span class="keywordtype">size_t</span> <a class="code" href="namespaceutl_1_1meta.html#ab5508236016638fa8e6b97cd17dfc9c2">count</a>,</div><div class="line"><a name="l11082"></a><span class="lineno">11082</span>  ostream* os) {</div><div class="line"><a name="l11083"></a><span class="lineno">11083</span>  <span class="comment">// Tells the user how big the object is.</span></div><div class="line"><a name="l11084"></a><span class="lineno">11084</span>  *os << <a class="code" href="namespaceutl_1_1meta.html#ab5508236016638fa8e6b97cd17dfc9c2">count</a> << <span class="stringliteral">"-byte object <"</span>;</div><div class="line"><a name="l11085"></a><span class="lineno">11085</span> </div><div class="line"><a name="l11086"></a><span class="lineno">11086</span>  <span class="keyword">const</span> <span class="keywordtype">size_t</span> kThreshold = 132;</div><div class="line"><a name="l11087"></a><span class="lineno">11087</span>  <span class="keyword">const</span> <span class="keywordtype">size_t</span> kChunkSize = 64;</div><div class="line"><a name="l11088"></a><span class="lineno">11088</span>  <span class="comment">// If the object size is bigger than kThreshold, we'll have to omit</span></div><div class="line"><a name="l11089"></a><span class="lineno">11089</span>  <span class="comment">// some details by printing only the first and the last kChunkSize</span></div><div class="line"><a name="l11090"></a><span class="lineno">11090</span>  <span class="comment">// bytes.</span></div><div class="line"><a name="l11091"></a><span class="lineno">11091</span>  <span class="keywordflow">if</span> (<a class="code" href="namespaceutl_1_1meta.html#ab5508236016638fa8e6b97cd17dfc9c2">count</a> < kThreshold) {</div><div class="line"><a name="l11092"></a><span class="lineno">11092</span>  PrintByteSegmentInObjectTo(obj_bytes, 0, <a class="code" href="namespaceutl_1_1meta.html#ab5508236016638fa8e6b97cd17dfc9c2">count</a>, os);</div><div class="line"><a name="l11093"></a><span class="lineno">11093</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l11094"></a><span class="lineno">11094</span>  PrintByteSegmentInObjectTo(obj_bytes, 0, kChunkSize, os);</div><div class="line"><a name="l11095"></a><span class="lineno">11095</span>  *os << <span class="stringliteral">" ... "</span>;</div><div class="line"><a name="l11096"></a><span class="lineno">11096</span>  <span class="comment">// Rounds up to 2-byte boundary.</span></div><div class="line"><a name="l11097"></a><span class="lineno">11097</span>  <span class="keyword">const</span> <span class="keywordtype">size_t</span> resume_pos = (<a class="code" href="namespaceutl_1_1meta.html#ab5508236016638fa8e6b97cd17dfc9c2">count</a> - kChunkSize + 1)/2*2;</div><div class="line"><a name="l11098"></a><span class="lineno">11098</span>  PrintByteSegmentInObjectTo(obj_bytes, resume_pos, <a class="code" href="namespaceutl_1_1meta.html#ab5508236016638fa8e6b97cd17dfc9c2">count</a> - resume_pos, os);</div><div class="line"><a name="l11099"></a><span class="lineno">11099</span>  }</div><div class="line"><a name="l11100"></a><span class="lineno">11100</span>  *os << <span class="stringliteral">">"</span>;</div><div class="line"><a name="l11101"></a><span class="lineno">11101</span> }</div><div class="line"><a name="l11102"></a><span class="lineno">11102</span> </div><div class="line"><a name="l11103"></a><span class="lineno">11103</span> } <span class="comment">// namespace</span></div><div class="line"><a name="l11104"></a><span class="lineno">11104</span> </div><div class="line"><a name="l11105"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal2.html">11105</a></span> <span class="keyword">namespace </span>internal2 {</div><div class="line"><a name="l11106"></a><span class="lineno">11106</span> </div><div class="line"><a name="l11107"></a><span class="lineno">11107</span> <span class="comment">// Delegates to PrintBytesInObjectToImpl() to print the bytes in the</span></div><div class="line"><a name="l11108"></a><span class="lineno">11108</span> <span class="comment">// given object. The delegation simplifies the implementation, which</span></div><div class="line"><a name="l11109"></a><span class="lineno">11109</span> <span class="comment">// uses the << operator and thus is easier done outside of the</span></div><div class="line"><a name="l11110"></a><span class="lineno">11110</span> <span class="comment">// ::testing::internal namespace, which contains a << operator that</span></div><div class="line"><a name="l11111"></a><span class="lineno">11111</span> <span class="comment">// sometimes conflicts with the one in STL.</span></div><div class="line"><a name="l11112"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal2.html#abfb9aa80365f93b952e9a4bea09947a8">11112</a></span> <span class="keywordtype">void</span> <a class="code" href="namespacetesting_1_1internal2.html#abfb9aa80365f93b952e9a4bea09947a8">PrintBytesInObjectTo</a>(<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>* obj_bytes, <span class="keywordtype">size_t</span> <a class="code" href="namespaceutl_1_1meta.html#ab5508236016638fa8e6b97cd17dfc9c2">count</a>,</div><div class="line"><a name="l11113"></a><span class="lineno">11113</span>  ostream* os) {</div><div class="line"><a name="l11114"></a><span class="lineno">11114</span>  PrintBytesInObjectToImpl(obj_bytes, <a class="code" href="namespaceutl_1_1meta.html#ab5508236016638fa8e6b97cd17dfc9c2">count</a>, os);</div><div class="line"><a name="l11115"></a><span class="lineno">11115</span> }</div><div class="line"><a name="l11116"></a><span class="lineno">11116</span> </div><div class="line"><a name="l11117"></a><span class="lineno">11117</span> } <span class="comment">// namespace internal2</span></div><div class="line"><a name="l11118"></a><span class="lineno">11118</span> </div><div class="line"><a name="l11119"></a><span class="lineno">11119</span> <span class="keyword">namespace </span>internal {</div><div class="line"><a name="l11120"></a><span class="lineno">11120</span> </div><div class="line"><a name="l11121"></a><span class="lineno">11121</span> <span class="comment">// Depending on the value of a char (or wchar_t), we print it in one</span></div><div class="line"><a name="l11122"></a><span class="lineno">11122</span> <span class="comment">// of three formats:</span></div><div class="line"><a name="l11123"></a><span class="lineno">11123</span> <span class="comment">// - as is if it's a printable ASCII (e.g. 'a', '2', ' '),</span></div><div class="line"><a name="l11124"></a><span class="lineno">11124</span> <span class="comment">// - as a hexadecimal escape sequence (e.g. '\x7F'), or</span></div><div class="line"><a name="l11125"></a><span class="lineno">11125</span> <span class="comment">// - as a special escape sequence (e.g. '\r', '\n').</span></div><div class="line"><a name="l11126"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#ae2ef98247c76a50cdc80ceb4a6c81793">11126</a></span> <span class="keyword">enum</span> <a class="code" href="namespacetesting_1_1internal.html#ae2ef98247c76a50cdc80ceb4a6c81793">CharFormat</a> {</div><div class="line"><a name="l11127"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#ae2ef98247c76a50cdc80ceb4a6c81793af7038866be92e9978360b831e376ffaa">11127</a></span>  <a class="code" href="namespacetesting_1_1internal.html#ae2ef98247c76a50cdc80ceb4a6c81793af7038866be92e9978360b831e376ffaa">kAsIs</a>,</div><div class="line"><a name="l11128"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#ae2ef98247c76a50cdc80ceb4a6c81793aebfa5293302338a8e8678744c103f113">11128</a></span>  <a class="code" href="namespacetesting_1_1internal.html#ae2ef98247c76a50cdc80ceb4a6c81793aebfa5293302338a8e8678744c103f113">kHexEscape</a>,</div><div class="line"><a name="l11129"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#ae2ef98247c76a50cdc80ceb4a6c81793ae1211108e9f35f891d9951da64794d03">11129</a></span>  <a class="code" href="namespacetesting_1_1internal.html#ae2ef98247c76a50cdc80ceb4a6c81793ae1211108e9f35f891d9951da64794d03">kSpecialEscape</a></div><div class="line"><a name="l11130"></a><span class="lineno">11130</span> };</div><div class="line"><a name="l11131"></a><span class="lineno">11131</span> </div><div class="line"><a name="l11132"></a><span class="lineno">11132</span> <span class="comment">// Returns true if c is a printable ASCII character. We test the</span></div><div class="line"><a name="l11133"></a><span class="lineno">11133</span> <span class="comment">// value of c directly instead of calling isprint(), which is buggy on</span></div><div class="line"><a name="l11134"></a><span class="lineno">11134</span> <span class="comment">// Windows Mobile.</span></div><div class="line"><a name="l11135"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#a744a6dd74c12d1e2c16b3c03e14ed4d4">11135</a></span> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="namespacetesting_1_1internal.html#a744a6dd74c12d1e2c16b3c03e14ed4d4">IsPrintableAscii</a>(<span class="keywordtype">wchar_t</span> c) {</div><div class="line"><a name="l11136"></a><span class="lineno">11136</span>  <span class="keywordflow">return</span> 0x20 <= c && c <= 0x7E;</div><div class="line"><a name="l11137"></a><span class="lineno">11137</span> }</div><div class="line"><a name="l11138"></a><span class="lineno">11138</span> </div><div class="line"><a name="l11139"></a><span class="lineno">11139</span> <span class="comment">// Prints a wide or narrow char c as a character literal without the</span></div><div class="line"><a name="l11140"></a><span class="lineno">11140</span> <span class="comment">// quotes, escaping it when necessary; returns how c was formatted.</span></div><div class="line"><a name="l11141"></a><span class="lineno">11141</span> <span class="comment">// The template argument UnsignedChar is the unsigned version of Char,</span></div><div class="line"><a name="l11142"></a><span class="lineno">11142</span> <span class="comment">// which is the type of c.</span></div><div class="line"><a name="l11143"></a><span class="lineno">11143</span> <span class="keyword">template</span> <<span class="keyword">typename</span> Un<span class="keywordtype">signed</span>Char, <span class="keyword">typename</span> Char></div><div class="line"><a name="l11144"></a><span class="lineno">11144</span> <span class="keyword">static</span> <a class="code" href="namespacetesting_1_1internal.html#ae2ef98247c76a50cdc80ceb4a6c81793">CharFormat</a> PrintAsCharLiteralTo(Char c, ostream* os) {</div><div class="line"><a name="l11145"></a><span class="lineno">11145</span>  <span class="keywordflow">switch</span> (static_cast<wchar_t>(c)) {</div><div class="line"><a name="l11146"></a><span class="lineno">11146</span>  <span class="keywordflow">case</span> L<span class="charliteral">'\0'</span>:</div><div class="line"><a name="l11147"></a><span class="lineno">11147</span>  *os << <span class="stringliteral">"\\0"</span>;</div><div class="line"><a name="l11148"></a><span class="lineno">11148</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l11149"></a><span class="lineno">11149</span>  <span class="keywordflow">case</span> L<span class="charliteral">'\''</span>:</div><div class="line"><a name="l11150"></a><span class="lineno">11150</span>  *os << <span class="stringliteral">"\\'"</span>;</div><div class="line"><a name="l11151"></a><span class="lineno">11151</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l11152"></a><span class="lineno">11152</span>  <span class="keywordflow">case</span> L<span class="charliteral">'\\'</span>:</div><div class="line"><a name="l11153"></a><span class="lineno">11153</span>  *os << <span class="stringliteral">"\\\\"</span>;</div><div class="line"><a name="l11154"></a><span class="lineno">11154</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l11155"></a><span class="lineno">11155</span>  <span class="keywordflow">case</span> L<span class="charliteral">'\a'</span>:</div><div class="line"><a name="l11156"></a><span class="lineno">11156</span>  *os << <span class="stringliteral">"\\a"</span>;</div><div class="line"><a name="l11157"></a><span class="lineno">11157</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l11158"></a><span class="lineno">11158</span>  <span class="keywordflow">case</span> L<span class="charliteral">'\b'</span>:</div><div class="line"><a name="l11159"></a><span class="lineno">11159</span>  *os << <span class="stringliteral">"\\b"</span>;</div><div class="line"><a name="l11160"></a><span class="lineno">11160</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l11161"></a><span class="lineno">11161</span>  <span class="keywordflow">case</span> L<span class="charliteral">'\f'</span>:</div><div class="line"><a name="l11162"></a><span class="lineno">11162</span>  *os << <span class="stringliteral">"\\f"</span>;</div><div class="line"><a name="l11163"></a><span class="lineno">11163</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l11164"></a><span class="lineno">11164</span>  <span class="keywordflow">case</span> L<span class="charliteral">'\n'</span>:</div><div class="line"><a name="l11165"></a><span class="lineno">11165</span>  *os << <span class="stringliteral">"\\n"</span>;</div><div class="line"><a name="l11166"></a><span class="lineno">11166</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l11167"></a><span class="lineno">11167</span>  <span class="keywordflow">case</span> L<span class="charliteral">'\r'</span>:</div><div class="line"><a name="l11168"></a><span class="lineno">11168</span>  *os << <span class="stringliteral">"\\r"</span>;</div><div class="line"><a name="l11169"></a><span class="lineno">11169</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l11170"></a><span class="lineno">11170</span>  <span class="keywordflow">case</span> L<span class="charliteral">'\t'</span>:</div><div class="line"><a name="l11171"></a><span class="lineno">11171</span>  *os << <span class="stringliteral">"\\t"</span>;</div><div class="line"><a name="l11172"></a><span class="lineno">11172</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l11173"></a><span class="lineno">11173</span>  <span class="keywordflow">case</span> L<span class="charliteral">'\v'</span>:</div><div class="line"><a name="l11174"></a><span class="lineno">11174</span>  *os << <span class="stringliteral">"\\v"</span>;</div><div class="line"><a name="l11175"></a><span class="lineno">11175</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l11176"></a><span class="lineno">11176</span>  <span class="keywordflow">default</span>:</div><div class="line"><a name="l11177"></a><span class="lineno">11177</span>  <span class="keywordflow">if</span> (<a class="code" href="namespacetesting_1_1internal.html#a744a6dd74c12d1e2c16b3c03e14ed4d4">IsPrintableAscii</a>(c)) {</div><div class="line"><a name="l11178"></a><span class="lineno">11178</span>  *os << static_cast<char>(c);</div><div class="line"><a name="l11179"></a><span class="lineno">11179</span>  <span class="keywordflow">return</span> <a class="code" href="namespacetesting_1_1internal.html#ae2ef98247c76a50cdc80ceb4a6c81793af7038866be92e9978360b831e376ffaa">kAsIs</a>;</div><div class="line"><a name="l11180"></a><span class="lineno">11180</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l11181"></a><span class="lineno">11181</span>  ostream::fmtflags flags = os->flags();</div><div class="line"><a name="l11182"></a><span class="lineno">11182</span>  *os << <span class="stringliteral">"\\x"</span> << std::hex << std::uppercase</div><div class="line"><a name="l11183"></a><span class="lineno">11183</span>  << <span class="keyword">static_cast<</span><span class="keywordtype">int</span><span class="keyword">></span>(<span class="keyword">static_cast<</span>UnsignedChar<span class="keyword">></span>(c));</div><div class="line"><a name="l11184"></a><span class="lineno">11184</span>  os->flags(flags);</div><div class="line"><a name="l11185"></a><span class="lineno">11185</span>  <span class="keywordflow">return</span> <a class="code" href="namespacetesting_1_1internal.html#ae2ef98247c76a50cdc80ceb4a6c81793aebfa5293302338a8e8678744c103f113">kHexEscape</a>;</div><div class="line"><a name="l11186"></a><span class="lineno">11186</span>  }</div><div class="line"><a name="l11187"></a><span class="lineno">11187</span>  }</div><div class="line"><a name="l11188"></a><span class="lineno">11188</span>  <span class="keywordflow">return</span> <a class="code" href="namespacetesting_1_1internal.html#ae2ef98247c76a50cdc80ceb4a6c81793ae1211108e9f35f891d9951da64794d03">kSpecialEscape</a>;</div><div class="line"><a name="l11189"></a><span class="lineno">11189</span> }</div><div class="line"><a name="l11190"></a><span class="lineno">11190</span> </div><div class="line"><a name="l11191"></a><span class="lineno">11191</span> <span class="comment">// Prints a wchar_t c as if it's part of a string literal, escaping it when</span></div><div class="line"><a name="l11192"></a><span class="lineno">11192</span> <span class="comment">// necessary; returns how c was formatted.</span></div><div class="line"><a name="l11193"></a><span class="lineno">11193</span> <span class="keyword">static</span> <a class="code" href="namespacetesting_1_1internal.html#ae2ef98247c76a50cdc80ceb4a6c81793">CharFormat</a> PrintAsStringLiteralTo(<span class="keywordtype">wchar_t</span> c, ostream* os) {</div><div class="line"><a name="l11194"></a><span class="lineno">11194</span>  <span class="keywordflow">switch</span> (c) {</div><div class="line"><a name="l11195"></a><span class="lineno">11195</span>  <span class="keywordflow">case</span> L<span class="charliteral">'\''</span>:</div><div class="line"><a name="l11196"></a><span class="lineno">11196</span>  *os << <span class="stringliteral">"'"</span>;</div><div class="line"><a name="l11197"></a><span class="lineno">11197</span>  <span class="keywordflow">return</span> <a class="code" href="namespacetesting_1_1internal.html#ae2ef98247c76a50cdc80ceb4a6c81793af7038866be92e9978360b831e376ffaa">kAsIs</a>;</div><div class="line"><a name="l11198"></a><span class="lineno">11198</span>  <span class="keywordflow">case</span> L<span class="charliteral">'"'</span>:</div><div class="line"><a name="l11199"></a><span class="lineno">11199</span>  *os << <span class="stringliteral">"\\\""</span>;</div><div class="line"><a name="l11200"></a><span class="lineno">11200</span>  <span class="keywordflow">return</span> <a class="code" href="namespacetesting_1_1internal.html#ae2ef98247c76a50cdc80ceb4a6c81793ae1211108e9f35f891d9951da64794d03">kSpecialEscape</a>;</div><div class="line"><a name="l11201"></a><span class="lineno">11201</span>  <span class="keywordflow">default</span>:</div><div class="line"><a name="l11202"></a><span class="lineno">11202</span>  <span class="keywordflow">return</span> PrintAsCharLiteralTo<wchar_t>(c, os);</div><div class="line"><a name="l11203"></a><span class="lineno">11203</span>  }</div><div class="line"><a name="l11204"></a><span class="lineno">11204</span> }</div><div class="line"><a name="l11205"></a><span class="lineno">11205</span> </div><div class="line"><a name="l11206"></a><span class="lineno">11206</span> <span class="comment">// Prints a char c as if it's part of a string literal, escaping it when</span></div><div class="line"><a name="l11207"></a><span class="lineno">11207</span> <span class="comment">// necessary; returns how c was formatted.</span></div><div class="line"><a name="l11208"></a><span class="lineno">11208</span> <span class="keyword">static</span> <a class="code" href="namespacetesting_1_1internal.html#ae2ef98247c76a50cdc80ceb4a6c81793">CharFormat</a> PrintAsStringLiteralTo(<span class="keywordtype">char</span> c, ostream* os) {</div><div class="line"><a name="l11209"></a><span class="lineno">11209</span>  <span class="keywordflow">return</span> PrintAsStringLiteralTo(</div><div class="line"><a name="l11210"></a><span class="lineno">11210</span>  static_cast<wchar_t>(static_cast<unsigned char>(c)), os);</div><div class="line"><a name="l11211"></a><span class="lineno">11211</span> }</div><div class="line"><a name="l11212"></a><span class="lineno">11212</span> </div><div class="line"><a name="l11213"></a><span class="lineno">11213</span> <span class="comment">// Prints a wide or narrow character c and its code. '\0' is printed</span></div><div class="line"><a name="l11214"></a><span class="lineno">11214</span> <span class="comment">// as "'\\0'", other unprintable characters are also properly escaped</span></div><div class="line"><a name="l11215"></a><span class="lineno">11215</span> <span class="comment">// using the standard C++ escape sequence. The template argument</span></div><div class="line"><a name="l11216"></a><span class="lineno">11216</span> <span class="comment">// UnsignedChar is the unsigned version of Char, which is the type of c.</span></div><div class="line"><a name="l11217"></a><span class="lineno">11217</span> <span class="keyword">template</span> <<span class="keyword">typename</span> Un<span class="keywordtype">signed</span>Char, <span class="keyword">typename</span> Char></div><div class="line"><a name="l11218"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#a0c577e598e61d339ba45dd6643fb1969">11218</a></span> <span class="keywordtype">void</span> <a class="code" href="namespacetesting_1_1internal.html#a0c577e598e61d339ba45dd6643fb1969">PrintCharAndCodeTo</a>(Char c, ostream* os) {</div><div class="line"><a name="l11219"></a><span class="lineno">11219</span>  <span class="comment">// First, print c as a literal in the most readable form we can find.</span></div><div class="line"><a name="l11220"></a><span class="lineno">11220</span>  *os << ((sizeof(c) > 1) ? <span class="stringliteral">"L'"</span> : <span class="stringliteral">"'"</span>);</div><div class="line"><a name="l11221"></a><span class="lineno">11221</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#ae2ef98247c76a50cdc80ceb4a6c81793">CharFormat</a> format = PrintAsCharLiteralTo<UnsignedChar>(c, os);</div><div class="line"><a name="l11222"></a><span class="lineno">11222</span>  *os << <span class="stringliteral">"'"</span>;</div><div class="line"><a name="l11223"></a><span class="lineno">11223</span> </div><div class="line"><a name="l11224"></a><span class="lineno">11224</span>  <span class="comment">// To aid user debugging, we also print c's code in decimal, unless</span></div><div class="line"><a name="l11225"></a><span class="lineno">11225</span>  <span class="comment">// it's 0 (in which case c was printed as '\\0', making the code</span></div><div class="line"><a name="l11226"></a><span class="lineno">11226</span>  <span class="comment">// obvious).</span></div><div class="line"><a name="l11227"></a><span class="lineno">11227</span>  <span class="keywordflow">if</span> (c == 0)</div><div class="line"><a name="l11228"></a><span class="lineno">11228</span>  <span class="keywordflow">return</span>;</div><div class="line"><a name="l11229"></a><span class="lineno">11229</span>  *os << <span class="stringliteral">" ("</span> << <span class="keyword">static_cast<</span><span class="keywordtype">int</span><span class="keyword">></span>(c);</div><div class="line"><a name="l11230"></a><span class="lineno">11230</span> </div><div class="line"><a name="l11231"></a><span class="lineno">11231</span>  <span class="comment">// For more convenience, we print c's code again in hexadecimal,</span></div><div class="line"><a name="l11232"></a><span class="lineno">11232</span>  <span class="comment">// unless c was already printed in the form '\x##' or the code is in</span></div><div class="line"><a name="l11233"></a><span class="lineno">11233</span>  <span class="comment">// [1, 9].</span></div><div class="line"><a name="l11234"></a><span class="lineno">11234</span>  <span class="keywordflow">if</span> (format == <a class="code" href="namespacetesting_1_1internal.html#ae2ef98247c76a50cdc80ceb4a6c81793aebfa5293302338a8e8678744c103f113">kHexEscape</a> || (1 <= c && c <= 9)) {</div><div class="line"><a name="l11235"></a><span class="lineno">11235</span>  <span class="comment">// Do nothing.</span></div><div class="line"><a name="l11236"></a><span class="lineno">11236</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l11237"></a><span class="lineno">11237</span>  *os << <span class="stringliteral">", 0x"</span> << String::FormatHexInt(static_cast<UnsignedChar>(c));</div><div class="line"><a name="l11238"></a><span class="lineno">11238</span>  }</div><div class="line"><a name="l11239"></a><span class="lineno">11239</span>  *os << <span class="stringliteral">")"</span>;</div><div class="line"><a name="l11240"></a><span class="lineno">11240</span> }</div><div class="line"><a name="l11241"></a><span class="lineno">11241</span> </div><div class="line"><a name="l11242"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#aa7e70a85d66f0c109e3e69629ef577f2">11242</a></span> <span class="keywordtype">void</span> <a class="code" href="namespacetesting_1_1internal.html#aa7e70a85d66f0c109e3e69629ef577f2">PrintTo</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> c, ::std::ostream* os) {</div><div class="line"><a name="l11243"></a><span class="lineno">11243</span>  PrintCharAndCodeTo<unsigned char>(c, os);</div><div class="line"><a name="l11244"></a><span class="lineno">11244</span> }</div><div class="line"><a name="l11245"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#abf6c518b437569187c1218166c702807">11245</a></span> <span class="keywordtype">void</span> <a class="code" href="namespacetesting_1_1internal.html#aa7e70a85d66f0c109e3e69629ef577f2">PrintTo</a>(<span class="keywordtype">signed</span> <span class="keywordtype">char</span> c, ::std::ostream* os) {</div><div class="line"><a name="l11246"></a><span class="lineno">11246</span>  PrintCharAndCodeTo<unsigned char>(c, os);</div><div class="line"><a name="l11247"></a><span class="lineno">11247</span> }</div><div class="line"><a name="l11248"></a><span class="lineno">11248</span> </div><div class="line"><a name="l11249"></a><span class="lineno">11249</span> <span class="comment">// Prints a wchar_t as a symbol if it is printable or as its internal</span></div><div class="line"><a name="l11250"></a><span class="lineno">11250</span> <span class="comment">// code otherwise and also as its code. L'\0' is printed as "L'\\0'".</span></div><div class="line"><a name="l11251"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#aa74ea9d64f76ce69eceb225ca5ebef58">11251</a></span> <span class="keywordtype">void</span> <a class="code" href="namespacetesting_1_1internal.html#aa7e70a85d66f0c109e3e69629ef577f2">PrintTo</a>(<span class="keywordtype">wchar_t</span> wc, ostream* os) {</div><div class="line"><a name="l11252"></a><span class="lineno">11252</span>  PrintCharAndCodeTo<wchar_t>(wc, os);</div><div class="line"><a name="l11253"></a><span class="lineno">11253</span> }</div><div class="line"><a name="l11254"></a><span class="lineno">11254</span> </div><div class="line"><a name="l11255"></a><span class="lineno">11255</span> <span class="comment">// Prints the given array of characters to the ostream. CharType must be either</span></div><div class="line"><a name="l11256"></a><span class="lineno">11256</span> <span class="comment">// char or wchar_t.</span></div><div class="line"><a name="l11257"></a><span class="lineno">11257</span> <span class="comment">// The array starts at begin, the length is len, it may include '\0' characters</span></div><div class="line"><a name="l11258"></a><span class="lineno">11258</span> <span class="comment">// and may not be NUL-terminated.</span></div><div class="line"><a name="l11259"></a><span class="lineno">11259</span> <span class="keyword">template</span> <<span class="keyword">typename</span> CharType></div><div class="line"><a name="l11260"></a><span class="lineno">11260</span> <a class="code" href="gtest_8h.html#a2a83dd79037e53814a509cc3f5702650">GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_</a></div><div class="line"><a name="l11261"></a><span class="lineno">11261</span> <a class="code" href="gtest_8h.html#af18b465f4ba6e36eea7a8d2d79521873">GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_</a></div><div class="line"><a name="l11262"></a><span class="lineno">11262</span> <a class="code" href="gtest_8h.html#abf30a6b1b3a12ecb2cc1bc1a6f5f9646">GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_</a></div><div class="line"><a name="l11263"></a><span class="lineno">11263</span> <span class="keyword">static</span> <a class="code" href="namespacetesting_1_1internal.html#ae2ef98247c76a50cdc80ceb4a6c81793">CharFormat</a> PrintCharsAsStringTo(</div><div class="line"><a name="l11264"></a><span class="lineno">11264</span>  <span class="keyword">const</span> CharType* begin, <span class="keywordtype">size_t</span> len, ostream* os) {</div><div class="line"><a name="l11265"></a><span class="lineno">11265</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> kQuoteBegin = <span class="keyword">sizeof</span>(CharType) == 1 ? <span class="stringliteral">"\""</span> : <span class="stringliteral">"L\""</span>;</div><div class="line"><a name="l11266"></a><span class="lineno">11266</span>  *os << kQuoteBegin;</div><div class="line"><a name="l11267"></a><span class="lineno">11267</span>  <span class="keywordtype">bool</span> is_previous_hex = <span class="keyword">false</span>;</div><div class="line"><a name="l11268"></a><span class="lineno">11268</span>  <a class="code" href="namespacetesting_1_1internal.html#ae2ef98247c76a50cdc80ceb4a6c81793">CharFormat</a> print_format = <a class="code" href="namespacetesting_1_1internal.html#ae2ef98247c76a50cdc80ceb4a6c81793af7038866be92e9978360b831e376ffaa">kAsIs</a>;</div><div class="line"><a name="l11269"></a><span class="lineno">11269</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> index = 0; index < len; ++index) {</div><div class="line"><a name="l11270"></a><span class="lineno">11270</span>  <span class="keyword">const</span> CharType cur = begin[index];</div><div class="line"><a name="l11271"></a><span class="lineno">11271</span>  <span class="keywordflow">if</span> (is_previous_hex && <a class="code" href="namespacetesting_1_1internal.html#aa234ef141278263fb143b616c74c86e7">IsXDigit</a>(cur)) {</div><div class="line"><a name="l11272"></a><span class="lineno">11272</span>  <span class="comment">// Previous character is of '\x..' form and this character can be</span></div><div class="line"><a name="l11273"></a><span class="lineno">11273</span>  <span class="comment">// interpreted as another hexadecimal digit in its number. Break string to</span></div><div class="line"><a name="l11274"></a><span class="lineno">11274</span>  <span class="comment">// disambiguate.</span></div><div class="line"><a name="l11275"></a><span class="lineno">11275</span>  *os << <span class="stringliteral">"\" "</span> << kQuoteBegin;</div><div class="line"><a name="l11276"></a><span class="lineno">11276</span>  }</div><div class="line"><a name="l11277"></a><span class="lineno">11277</span>  is_previous_hex = PrintAsStringLiteralTo(cur, os) == <a class="code" href="namespacetesting_1_1internal.html#ae2ef98247c76a50cdc80ceb4a6c81793aebfa5293302338a8e8678744c103f113">kHexEscape</a>;</div><div class="line"><a name="l11278"></a><span class="lineno">11278</span>  <span class="comment">// Remember if any characters required hex escaping.</span></div><div class="line"><a name="l11279"></a><span class="lineno">11279</span>  <span class="keywordflow">if</span> (is_previous_hex) {</div><div class="line"><a name="l11280"></a><span class="lineno">11280</span>  print_format = <a class="code" href="namespacetesting_1_1internal.html#ae2ef98247c76a50cdc80ceb4a6c81793aebfa5293302338a8e8678744c103f113">kHexEscape</a>;</div><div class="line"><a name="l11281"></a><span class="lineno">11281</span>  }</div><div class="line"><a name="l11282"></a><span class="lineno">11282</span>  }</div><div class="line"><a name="l11283"></a><span class="lineno">11283</span>  *os << <span class="stringliteral">"\""</span>;</div><div class="line"><a name="l11284"></a><span class="lineno">11284</span>  <span class="keywordflow">return</span> print_format;</div><div class="line"><a name="l11285"></a><span class="lineno">11285</span> }</div><div class="line"><a name="l11286"></a><span class="lineno">11286</span> </div><div class="line"><a name="l11287"></a><span class="lineno">11287</span> <span class="comment">// Prints a (const) char/wchar_t array of 'len' elements, starting at address</span></div><div class="line"><a name="l11288"></a><span class="lineno">11288</span> <span class="comment">// 'begin'. CharType must be either char or wchar_t.</span></div><div class="line"><a name="l11289"></a><span class="lineno">11289</span> <span class="keyword">template</span> <<span class="keyword">typename</span> CharType></div><div class="line"><a name="l11290"></a><span class="lineno">11290</span> <a class="code" href="gtest_8h.html#a2a83dd79037e53814a509cc3f5702650">GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_</a></div><div class="line"><a name="l11291"></a><span class="lineno">11291</span> <a class="code" href="gtest_8h.html#af18b465f4ba6e36eea7a8d2d79521873">GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_</a></div><div class="line"><a name="l11292"></a><span class="lineno">11292</span> <a class="code" href="gtest_8h.html#abf30a6b1b3a12ecb2cc1bc1a6f5f9646">GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_</a></div><div class="line"><a name="l11293"></a><span class="lineno">11293</span> <span class="keyword">static</span> <span class="keywordtype">void</span> UniversalPrintCharArray(</div><div class="line"><a name="l11294"></a><span class="lineno">11294</span>  <span class="keyword">const</span> CharType* begin, <span class="keywordtype">size_t</span> len, ostream* os) {</div><div class="line"><a name="l11295"></a><span class="lineno">11295</span>  <span class="comment">// The code</span></div><div class="line"><a name="l11296"></a><span class="lineno">11296</span>  <span class="comment">// const char kFoo[] = "foo";</span></div><div class="line"><a name="l11297"></a><span class="lineno">11297</span>  <span class="comment">// generates an array of 4, not 3, elements, with the last one being '\0'.</span></div><div class="line"><a name="l11298"></a><span class="lineno">11298</span>  <span class="comment">//</span></div><div class="line"><a name="l11299"></a><span class="lineno">11299</span>  <span class="comment">// Therefore when printing a char array, we don't print the last element if</span></div><div class="line"><a name="l11300"></a><span class="lineno">11300</span>  <span class="comment">// it's '\0', such that the output matches the string literal as it's</span></div><div class="line"><a name="l11301"></a><span class="lineno">11301</span>  <span class="comment">// written in the source code.</span></div><div class="line"><a name="l11302"></a><span class="lineno">11302</span>  <span class="keywordflow">if</span> (len > 0 && begin[len - 1] == <span class="charliteral">'\0'</span>) {</div><div class="line"><a name="l11303"></a><span class="lineno">11303</span>  PrintCharsAsStringTo(begin, len - 1, os);</div><div class="line"><a name="l11304"></a><span class="lineno">11304</span>  <span class="keywordflow">return</span>;</div><div class="line"><a name="l11305"></a><span class="lineno">11305</span>  }</div><div class="line"><a name="l11306"></a><span class="lineno">11306</span> </div><div class="line"><a name="l11307"></a><span class="lineno">11307</span>  <span class="comment">// If, however, the last element in the array is not '\0', e.g.</span></div><div class="line"><a name="l11308"></a><span class="lineno">11308</span>  <span class="comment">// const char kFoo[] = { 'f', 'o', 'o' };</span></div><div class="line"><a name="l11309"></a><span class="lineno">11309</span>  <span class="comment">// we must print the entire array. We also print a message to indicate</span></div><div class="line"><a name="l11310"></a><span class="lineno">11310</span>  <span class="comment">// that the array is not NUL-terminated.</span></div><div class="line"><a name="l11311"></a><span class="lineno">11311</span>  PrintCharsAsStringTo(begin, len, os);</div><div class="line"><a name="l11312"></a><span class="lineno">11312</span>  *os << <span class="stringliteral">" (no terminating NUL)"</span>;</div><div class="line"><a name="l11313"></a><span class="lineno">11313</span> }</div><div class="line"><a name="l11314"></a><span class="lineno">11314</span> </div><div class="line"><a name="l11315"></a><span class="lineno">11315</span> <span class="comment">// Prints a (const) char array of 'len' elements, starting at address 'begin'.</span></div><div class="line"><a name="l11316"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#a070107e7a8205ad6ec4d538d52b15b38">11316</a></span> <span class="keywordtype">void</span> <a class="code" href="namespacetesting_1_1internal.html#a070107e7a8205ad6ec4d538d52b15b38">UniversalPrintArray</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* begin, <span class="keywordtype">size_t</span> len, ostream* os) {</div><div class="line"><a name="l11317"></a><span class="lineno">11317</span>  UniversalPrintCharArray(begin, len, os);</div><div class="line"><a name="l11318"></a><span class="lineno">11318</span> }</div><div class="line"><a name="l11319"></a><span class="lineno">11319</span> </div><div class="line"><a name="l11320"></a><span class="lineno">11320</span> <span class="comment">// Prints a (const) wchar_t array of 'len' elements, starting at address</span></div><div class="line"><a name="l11321"></a><span class="lineno">11321</span> <span class="comment">// 'begin'.</span></div><div class="line"><a name="l11322"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#a52394019018eb5079f9f1bcca23dcd60">11322</a></span> <span class="keywordtype">void</span> <a class="code" href="namespacetesting_1_1internal.html#a070107e7a8205ad6ec4d538d52b15b38">UniversalPrintArray</a>(<span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* begin, <span class="keywordtype">size_t</span> len, ostream* os) {</div><div class="line"><a name="l11323"></a><span class="lineno">11323</span>  UniversalPrintCharArray(begin, len, os);</div><div class="line"><a name="l11324"></a><span class="lineno">11324</span> }</div><div class="line"><a name="l11325"></a><span class="lineno">11325</span> </div><div class="line"><a name="l11326"></a><span class="lineno">11326</span> <span class="comment">// Prints the given C string to the ostream.</span></div><div class="line"><a name="l11327"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#adc6c98306d40b53fd07be4e295102a0a">11327</a></span> <span class="keywordtype">void</span> <a class="code" href="namespacetesting_1_1internal.html#aa7e70a85d66f0c109e3e69629ef577f2">PrintTo</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* s, ostream* os) {</div><div class="line"><a name="l11328"></a><span class="lineno">11328</span>  <span class="keywordflow">if</span> (s == <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l11329"></a><span class="lineno">11329</span>  *os << <span class="stringliteral">"NULL"</span>;</div><div class="line"><a name="l11330"></a><span class="lineno">11330</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l11331"></a><span class="lineno">11331</span>  *os << ImplicitCast_<const void*>(s) << <span class="stringliteral">" pointing to "</span>;</div><div class="line"><a name="l11332"></a><span class="lineno">11332</span>  PrintCharsAsStringTo(s, strlen(s), os);</div><div class="line"><a name="l11333"></a><span class="lineno">11333</span>  }</div><div class="line"><a name="l11334"></a><span class="lineno">11334</span> }</div><div class="line"><a name="l11335"></a><span class="lineno">11335</span> </div><div class="line"><a name="l11336"></a><span class="lineno">11336</span> <span class="comment">// MSVC compiler can be configured to define whar_t as a typedef</span></div><div class="line"><a name="l11337"></a><span class="lineno">11337</span> <span class="comment">// of unsigned short. Defining an overload for const wchar_t* in that case</span></div><div class="line"><a name="l11338"></a><span class="lineno">11338</span> <span class="comment">// would cause pointers to unsigned shorts be printed as wide strings,</span></div><div class="line"><a name="l11339"></a><span class="lineno">11339</span> <span class="comment">// possibly accessing more memory than intended and causing invalid</span></div><div class="line"><a name="l11340"></a><span class="lineno">11340</span> <span class="comment">// memory accesses. MSVC defines _NATIVE_WCHAR_T_DEFINED symbol when</span></div><div class="line"><a name="l11341"></a><span class="lineno">11341</span> <span class="comment">// wchar_t is implemented as a native type.</span></div><div class="line"><a name="l11342"></a><span class="lineno">11342</span> <span class="preprocessor">#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)</span></div><div class="line"><a name="l11343"></a><span class="lineno">11343</span> <span class="comment">// Prints the given wide C string to the ostream.</span></div><div class="line"><a name="l11344"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#afc20fb56b2547a8f91f9ff99650f2024">11344</a></span> <span class="keywordtype">void</span> <a class="code" href="namespacetesting_1_1internal.html#aa7e70a85d66f0c109e3e69629ef577f2">PrintTo</a>(<span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* s, ostream* os) {</div><div class="line"><a name="l11345"></a><span class="lineno">11345</span>  <span class="keywordflow">if</span> (s == <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l11346"></a><span class="lineno">11346</span>  *os << <span class="stringliteral">"NULL"</span>;</div><div class="line"><a name="l11347"></a><span class="lineno">11347</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l11348"></a><span class="lineno">11348</span>  *os << ImplicitCast_<const void*>(s) << <span class="stringliteral">" pointing to "</span>;</div><div class="line"><a name="l11349"></a><span class="lineno">11349</span>  PrintCharsAsStringTo(s, wcslen(s), os);</div><div class="line"><a name="l11350"></a><span class="lineno">11350</span>  }</div><div class="line"><a name="l11351"></a><span class="lineno">11351</span> }</div><div class="line"><a name="l11352"></a><span class="lineno">11352</span> <span class="preprocessor">#endif // wchar_t is native</span></div><div class="line"><a name="l11353"></a><span class="lineno">11353</span> </div><div class="line"><a name="l11354"></a><span class="lineno">11354</span> <span class="keyword">namespace </span>{</div><div class="line"><a name="l11355"></a><span class="lineno">11355</span> </div><div class="line"><a name="l11356"></a><span class="lineno">11356</span> <span class="keywordtype">bool</span> ContainsUnprintableControlCodes(<span class="keyword">const</span> <span class="keywordtype">char</span>* str, <span class="keywordtype">size_t</span> length) {</div><div class="line"><a name="l11357"></a><span class="lineno">11357</span>  <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *s = <span class="keyword">reinterpret_cast<</span><span class="keyword">const </span><span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *<span class="keyword">></span>(str);</div><div class="line"><a name="l11358"></a><span class="lineno">11358</span> </div><div class="line"><a name="l11359"></a><span class="lineno">11359</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i < length; i++) {</div><div class="line"><a name="l11360"></a><span class="lineno">11360</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> ch = *s++;</div><div class="line"><a name="l11361"></a><span class="lineno">11361</span>  <span class="keywordflow">if</span> (std::iscntrl(ch)) {</div><div class="line"><a name="l11362"></a><span class="lineno">11362</span>  <span class="keywordflow">switch</span> (ch) {</div><div class="line"><a name="l11363"></a><span class="lineno">11363</span>  <span class="keywordflow">case</span> <span class="charliteral">'\t'</span>:</div><div class="line"><a name="l11364"></a><span class="lineno">11364</span>  <span class="keywordflow">case</span> <span class="charliteral">'\n'</span>:</div><div class="line"><a name="l11365"></a><span class="lineno">11365</span>  <span class="keywordflow">case</span> <span class="charliteral">'\r'</span>:</div><div class="line"><a name="l11366"></a><span class="lineno">11366</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l11367"></a><span class="lineno">11367</span>  <span class="keywordflow">default</span>:</div><div class="line"><a name="l11368"></a><span class="lineno">11368</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l11369"></a><span class="lineno">11369</span>  }</div><div class="line"><a name="l11370"></a><span class="lineno">11370</span>  }</div><div class="line"><a name="l11371"></a><span class="lineno">11371</span>  }</div><div class="line"><a name="l11372"></a><span class="lineno">11372</span>  <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l11373"></a><span class="lineno">11373</span> }</div><div class="line"><a name="l11374"></a><span class="lineno">11374</span> </div><div class="line"><a name="l11375"></a><span class="lineno">11375</span> <span class="keywordtype">bool</span> IsUTF8TrailByte(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> t) { <span class="keywordflow">return</span> 0x80 <= t && t<= 0xbf; }</div><div class="line"><a name="l11376"></a><span class="lineno">11376</span> </div><div class="line"><a name="l11377"></a><span class="lineno">11377</span> <span class="keywordtype">bool</span> IsValidUTF8(<span class="keyword">const</span> <span class="keywordtype">char</span>* str, <span class="keywordtype">size_t</span> length) {</div><div class="line"><a name="l11378"></a><span class="lineno">11378</span>  <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *s = <span class="keyword">reinterpret_cast<</span><span class="keyword">const </span><span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *<span class="keyword">></span>(str);</div><div class="line"><a name="l11379"></a><span class="lineno">11379</span> </div><div class="line"><a name="l11380"></a><span class="lineno">11380</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i < length;) {</div><div class="line"><a name="l11381"></a><span class="lineno">11381</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> lead = s[i++];</div><div class="line"><a name="l11382"></a><span class="lineno">11382</span> </div><div class="line"><a name="l11383"></a><span class="lineno">11383</span>  <span class="keywordflow">if</span> (lead <= 0x7f) {</div><div class="line"><a name="l11384"></a><span class="lineno">11384</span>  <span class="keywordflow">continue</span>; <span class="comment">// single-byte character (ASCII) 0..7F</span></div><div class="line"><a name="l11385"></a><span class="lineno">11385</span>  }</div><div class="line"><a name="l11386"></a><span class="lineno">11386</span>  <span class="keywordflow">if</span> (lead < 0xc2) {</div><div class="line"><a name="l11387"></a><span class="lineno">11387</span>  <span class="keywordflow">return</span> <span class="keyword">false</span>; <span class="comment">// trail byte or non-shortest form</span></div><div class="line"><a name="l11388"></a><span class="lineno">11388</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (lead <= 0xdf && (i + 1) <= length && IsUTF8TrailByte(s[i])) {</div><div class="line"><a name="l11389"></a><span class="lineno">11389</span>  ++i; <span class="comment">// 2-byte character</span></div><div class="line"><a name="l11390"></a><span class="lineno">11390</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (0xe0 <= lead && lead <= 0xef && (i + 2) <= length &&</div><div class="line"><a name="l11391"></a><span class="lineno">11391</span>  IsUTF8TrailByte(s[i]) &&</div><div class="line"><a name="l11392"></a><span class="lineno">11392</span>  IsUTF8TrailByte(s[i + 1]) &&</div><div class="line"><a name="l11393"></a><span class="lineno">11393</span>  <span class="comment">// check for non-shortest form and surrogate</span></div><div class="line"><a name="l11394"></a><span class="lineno">11394</span>  (lead != 0xe0 || s[i] >= 0xa0) &&</div><div class="line"><a name="l11395"></a><span class="lineno">11395</span>  (lead != 0xed || s[i] < 0xa0)) {</div><div class="line"><a name="l11396"></a><span class="lineno">11396</span>  i += 2; <span class="comment">// 3-byte character</span></div><div class="line"><a name="l11397"></a><span class="lineno">11397</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (0xf0 <= lead && lead <= 0xf4 && (i + 3) <= length &&</div><div class="line"><a name="l11398"></a><span class="lineno">11398</span>  IsUTF8TrailByte(s[i]) &&</div><div class="line"><a name="l11399"></a><span class="lineno">11399</span>  IsUTF8TrailByte(s[i + 1]) &&</div><div class="line"><a name="l11400"></a><span class="lineno">11400</span>  IsUTF8TrailByte(s[i + 2]) &&</div><div class="line"><a name="l11401"></a><span class="lineno">11401</span>  <span class="comment">// check for non-shortest form</span></div><div class="line"><a name="l11402"></a><span class="lineno">11402</span>  (lead != 0xf0 || s[i] >= 0x90) &&</div><div class="line"><a name="l11403"></a><span class="lineno">11403</span>  (lead != 0xf4 || s[i] < 0x90)) {</div><div class="line"><a name="l11404"></a><span class="lineno">11404</span>  i += 3; <span class="comment">// 4-byte character</span></div><div class="line"><a name="l11405"></a><span class="lineno">11405</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l11406"></a><span class="lineno">11406</span>  <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l11407"></a><span class="lineno">11407</span>  }</div><div class="line"><a name="l11408"></a><span class="lineno">11408</span>  }</div><div class="line"><a name="l11409"></a><span class="lineno">11409</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l11410"></a><span class="lineno">11410</span> }</div><div class="line"><a name="l11411"></a><span class="lineno">11411</span> </div><div class="line"><a name="l11412"></a><span class="lineno">11412</span> <span class="keywordtype">void</span> ConditionalPrintAsText(<span class="keyword">const</span> <span class="keywordtype">char</span>* str, <span class="keywordtype">size_t</span> length, ostream* os) {</div><div class="line"><a name="l11413"></a><span class="lineno">11413</span>  <span class="keywordflow">if</span> (!ContainsUnprintableControlCodes(str, length) &&</div><div class="line"><a name="l11414"></a><span class="lineno">11414</span>  IsValidUTF8(str, length)) {</div><div class="line"><a name="l11415"></a><span class="lineno">11415</span>  *os << <span class="stringliteral">"\n As Text: \""</span> << str << <span class="stringliteral">"\""</span>;</div><div class="line"><a name="l11416"></a><span class="lineno">11416</span>  }</div><div class="line"><a name="l11417"></a><span class="lineno">11417</span> }</div><div class="line"><a name="l11418"></a><span class="lineno">11418</span> </div><div class="line"><a name="l11419"></a><span class="lineno">11419</span> } <span class="comment">// anonymous namespace</span></div><div class="line"><a name="l11420"></a><span class="lineno">11420</span> </div><div class="line"><a name="l11421"></a><span class="lineno">11421</span> <span class="comment">// Prints a ::string object.</span></div><div class="line"><a name="l11422"></a><span class="lineno">11422</span> <span class="preprocessor">#if GTEST_HAS_GLOBAL_STRING</span></div><div class="line"><a name="l11423"></a><span class="lineno">11423</span> <span class="keywordtype">void</span> <a class="code" href="namespacetesting_1_1internal.html#ad609167d8d6792b0fb186539e0e159bd">PrintStringTo</a>(<a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">const ::string</a>& s, ostream* os) {</div><div class="line"><a name="l11424"></a><span class="lineno">11424</span>  <span class="keywordflow">if</span> (PrintCharsAsStringTo(s.data(), s.size(), os) == <a class="code" href="namespacetesting_1_1internal.html#ae2ef98247c76a50cdc80ceb4a6c81793aebfa5293302338a8e8678744c103f113">kHexEscape</a>) {</div><div class="line"><a name="l11425"></a><span class="lineno">11425</span>  <span class="keywordflow">if</span> (<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(print_utf8)) {</div><div class="line"><a name="l11426"></a><span class="lineno">11426</span>  ConditionalPrintAsText(s.data(), s.size(), os);</div><div class="line"><a name="l11427"></a><span class="lineno">11427</span>  }</div><div class="line"><a name="l11428"></a><span class="lineno">11428</span>  }</div><div class="line"><a name="l11429"></a><span class="lineno">11429</span> }</div><div class="line"><a name="l11430"></a><span class="lineno">11430</span> <span class="preprocessor">#endif // GTEST_HAS_GLOBAL_STRING</span></div><div class="line"><a name="l11431"></a><span class="lineno">11431</span> </div><div class="line"><a name="l11432"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#ad609167d8d6792b0fb186539e0e159bd">11432</a></span> <span class="keywordtype">void</span> <a class="code" href="namespacetesting_1_1internal.html#ad609167d8d6792b0fb186539e0e159bd">PrintStringTo</a>(<a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">const ::std::string</a>& s, ostream* os) {</div><div class="line"><a name="l11433"></a><span class="lineno">11433</span>  <span class="keywordflow">if</span> (PrintCharsAsStringTo(s.data(), s.size(), os) == <a class="code" href="namespacetesting_1_1internal.html#ae2ef98247c76a50cdc80ceb4a6c81793aebfa5293302338a8e8678744c103f113">kHexEscape</a>) {</div><div class="line"><a name="l11434"></a><span class="lineno">11434</span>  <span class="keywordflow">if</span> (<a class="code" href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a>(print_utf8)) {</div><div class="line"><a name="l11435"></a><span class="lineno">11435</span>  ConditionalPrintAsText(s.data(), s.size(), os);</div><div class="line"><a name="l11436"></a><span class="lineno">11436</span>  }</div><div class="line"><a name="l11437"></a><span class="lineno">11437</span>  }</div><div class="line"><a name="l11438"></a><span class="lineno">11438</span> }</div><div class="line"><a name="l11439"></a><span class="lineno">11439</span> </div><div class="line"><a name="l11440"></a><span class="lineno">11440</span> <span class="comment">// Prints a ::wstring object.</span></div><div class="line"><a name="l11441"></a><span class="lineno">11441</span> <span class="preprocessor">#if GTEST_HAS_GLOBAL_WSTRING</span></div><div class="line"><a name="l11442"></a><span class="lineno">11442</span> <span class="keywordtype">void</span> <a class="code" href="namespacetesting_1_1internal.html#ac46308aa3c0294ae446a40115aeb32c6">PrintWideStringTo</a>(<a class="code" href="namespacetesting_1_1internal.html#a3f543179329c353aee1d7b54a9a8e335">const ::wstring</a>& s, ostream* os) {</div><div class="line"><a name="l11443"></a><span class="lineno">11443</span>  PrintCharsAsStringTo(s.data(), s.size(), os);</div><div class="line"><a name="l11444"></a><span class="lineno">11444</span> }</div><div class="line"><a name="l11445"></a><span class="lineno">11445</span> <span class="preprocessor">#endif // GTEST_HAS_GLOBAL_WSTRING</span></div><div class="line"><a name="l11446"></a><span class="lineno">11446</span> </div><div class="line"><a name="l11447"></a><span class="lineno">11447</span> <span class="preprocessor">#if GTEST_HAS_STD_WSTRING</span></div><div class="line"><a name="l11448"></a><span class="lineno"><a class="line" href="namespacetesting_1_1internal.html#ac46308aa3c0294ae446a40115aeb32c6">11448</a></span> <span class="keywordtype">void</span> <a class="code" href="namespacetesting_1_1internal.html#ac46308aa3c0294ae446a40115aeb32c6">PrintWideStringTo</a>(<a class="code" href="namespacetesting_1_1internal.html#a3f543179329c353aee1d7b54a9a8e335">const ::std::wstring</a>& s, ostream* os) {</div><div class="line"><a name="l11449"></a><span class="lineno">11449</span>  PrintCharsAsStringTo(s.data(), s.size(), os);</div><div class="line"><a name="l11450"></a><span class="lineno">11450</span> }</div><div class="line"><a name="l11451"></a><span class="lineno">11451</span> <span class="preprocessor">#endif // GTEST_HAS_STD_WSTRING</span></div><div class="line"><a name="l11452"></a><span class="lineno">11452</span> </div><div class="line"><a name="l11453"></a><span class="lineno">11453</span> } <span class="comment">// namespace internal</span></div><div class="line"><a name="l11454"></a><span class="lineno">11454</span> </div><div class="line"><a name="l11455"></a><span class="lineno">11455</span> } <span class="comment">// namespace testing</span></div><div class="line"><a name="l11456"></a><span class="lineno">11456</span> <span class="comment">// Copyright 2008, Google Inc.</span></div><div class="line"><a name="l11457"></a><span class="lineno">11457</span> <span class="comment">// All rights reserved.</span></div><div class="line"><a name="l11458"></a><span class="lineno">11458</span> <span class="comment">//</span></div><div class="line"><a name="l11459"></a><span class="lineno">11459</span> <span class="comment">// Redistribution and use in source and binary forms, with or without</span></div><div class="line"><a name="l11460"></a><span class="lineno">11460</span> <span class="comment">// modification, are permitted provided that the following conditions are</span></div><div class="line"><a name="l11461"></a><span class="lineno">11461</span> <span class="comment">// met:</span></div><div class="line"><a name="l11462"></a><span class="lineno">11462</span> <span class="comment">//</span></div><div class="line"><a name="l11463"></a><span class="lineno">11463</span> <span class="comment">// * Redistributions of source code must retain the above copyright</span></div><div class="line"><a name="l11464"></a><span class="lineno">11464</span> <span class="comment">// notice, this list of conditions and the following disclaimer.</span></div><div class="line"><a name="l11465"></a><span class="lineno">11465</span> <span class="comment">// * Redistributions in binary form must reproduce the above</span></div><div class="line"><a name="l11466"></a><span class="lineno">11466</span> <span class="comment">// copyright notice, this list of conditions and the following disclaimer</span></div><div class="line"><a name="l11467"></a><span class="lineno">11467</span> <span class="comment">// in the documentation and/or other materials provided with the</span></div><div class="line"><a name="l11468"></a><span class="lineno">11468</span> <span class="comment">// distribution.</span></div><div class="line"><a name="l11469"></a><span class="lineno">11469</span> <span class="comment">// * Neither the name of Google Inc. nor the names of its</span></div><div class="line"><a name="l11470"></a><span class="lineno">11470</span> <span class="comment">// contributors may be used to endorse or promote products derived from</span></div><div class="line"><a name="l11471"></a><span class="lineno">11471</span> <span class="comment">// this software without specific prior written permission.</span></div><div class="line"><a name="l11472"></a><span class="lineno">11472</span> <span class="comment">//</span></div><div class="line"><a name="l11473"></a><span class="lineno">11473</span> <span class="comment">// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span></div><div class="line"><a name="l11474"></a><span class="lineno">11474</span> <span class="comment">// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</span></div><div class="line"><a name="l11475"></a><span class="lineno">11475</span> <span class="comment">// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR</span></div><div class="line"><a name="l11476"></a><span class="lineno">11476</span> <span class="comment">// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT</span></div><div class="line"><a name="l11477"></a><span class="lineno">11477</span> <span class="comment">// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span></div><div class="line"><a name="l11478"></a><span class="lineno">11478</span> <span class="comment">// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</span></div><div class="line"><a name="l11479"></a><span class="lineno">11479</span> <span class="comment">// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</span></div><div class="line"><a name="l11480"></a><span class="lineno">11480</span> <span class="comment">// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY</span></div><div class="line"><a name="l11481"></a><span class="lineno">11481</span> <span class="comment">// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span></div><div class="line"><a name="l11482"></a><span class="lineno">11482</span> <span class="comment">// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE</span></div><div class="line"><a name="l11483"></a><span class="lineno">11483</span> <span class="comment">// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span></div><div class="line"><a name="l11484"></a><span class="lineno">11484</span> </div><div class="line"><a name="l11485"></a><span class="lineno">11485</span> <span class="comment">//</span></div><div class="line"><a name="l11486"></a><span class="lineno">11486</span> <span class="comment">// The Google C++ Testing and Mocking Framework (Google Test)</span></div><div class="line"><a name="l11487"></a><span class="lineno">11487</span> </div><div class="line"><a name="l11488"></a><span class="lineno">11488</span> </div><div class="line"><a name="l11489"></a><span class="lineno">11489</span> <span class="keyword">namespace </span><a class="code" href="namespacetesting.html">testing</a> {</div><div class="line"><a name="l11490"></a><span class="lineno">11490</span> </div><div class="line"><a name="l11491"></a><span class="lineno">11491</span> <span class="keyword">using</span> internal::GetUnitTestImpl;</div><div class="line"><a name="l11492"></a><span class="lineno">11492</span> </div><div class="line"><a name="l11493"></a><span class="lineno">11493</span> <span class="comment">// Gets the summary of the failure message by omitting the stack trace</span></div><div class="line"><a name="l11494"></a><span class="lineno">11494</span> <span class="comment">// in it.</span></div><div class="line"><a name="l11495"></a><span class="lineno">11495</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a> TestPartResult::ExtractSummary(<span class="keyword">const</span> <span class="keywordtype">char</span>* message) {</div><div class="line"><a name="l11496"></a><span class="lineno">11496</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> stack_trace = strstr(message, <a class="code" href="namespacetesting_1_1internal.html#a999c7ef9ff01b6d2d76669372c444aa3">internal::kStackTraceMarker</a>);</div><div class="line"><a name="l11497"></a><span class="lineno">11497</span>  <span class="keywordflow">return</span> stack_trace == <span class="keyword">nullptr</span> ? message : <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>(message, stack_trace);</div><div class="line"><a name="l11498"></a><span class="lineno">11498</span> }</div><div class="line"><a name="l11499"></a><span class="lineno">11499</span> </div><div class="line"><a name="l11500"></a><span class="lineno">11500</span> <span class="comment">// Prints a TestPartResult object.</span></div><div class="line"><a name="l11501"></a><span class="lineno"><a class="line" href="namespacetesting.html#a266e39b7c4691fedb856047673a412d8">11501</a></span> std::ostream& <a class="code" href="namespacetesting.html#a266e39b7c4691fedb856047673a412d8">operator<<</a>(std::ostream& os, <span class="keyword">const</span> TestPartResult& result) {</div><div class="line"><a name="l11502"></a><span class="lineno">11502</span>  <span class="keywordflow">return</span> os << result.file_name() << <span class="stringliteral">":"</span> << result.line_number() << <span class="stringliteral">": "</span></div><div class="line"><a name="l11503"></a><span class="lineno">11503</span>  << (result.type() == TestPartResult::kSuccess</div><div class="line"><a name="l11504"></a><span class="lineno">11504</span>  ? <span class="stringliteral">"Success"</span></div><div class="line"><a name="l11505"></a><span class="lineno">11505</span>  : result.type() == TestPartResult::kSkip</div><div class="line"><a name="l11506"></a><span class="lineno">11506</span>  ? <span class="stringliteral">"Skipped"</span></div><div class="line"><a name="l11507"></a><span class="lineno">11507</span>  : result.type() == TestPartResult::kFatalFailure</div><div class="line"><a name="l11508"></a><span class="lineno">11508</span>  ? <span class="stringliteral">"Fatal failure"</span></div><div class="line"><a name="l11509"></a><span class="lineno">11509</span>  : <span class="stringliteral">"Non-fatal failure"</span>)</div><div class="line"><a name="l11510"></a><span class="lineno">11510</span>  << <span class="stringliteral">":\n"</span></div><div class="line"><a name="l11511"></a><span class="lineno">11511</span>  << result.message() << std::endl;</div><div class="line"><a name="l11512"></a><span class="lineno">11512</span> }</div><div class="line"><a name="l11513"></a><span class="lineno">11513</span> </div><div class="line"><a name="l11514"></a><span class="lineno">11514</span> <span class="comment">// Appends a TestPartResult to the array.</span></div><div class="line"><a name="l11515"></a><span class="lineno">11515</span> <span class="keywordtype">void</span> TestPartResultArray::Append(<span class="keyword">const</span> TestPartResult& result) {</div><div class="line"><a name="l11516"></a><span class="lineno">11516</span>  array_.push_back(result);</div><div class="line"><a name="l11517"></a><span class="lineno">11517</span> }</div><div class="line"><a name="l11518"></a><span class="lineno">11518</span> </div><div class="line"><a name="l11519"></a><span class="lineno">11519</span> <span class="comment">// Returns the TestPartResult at the given index (0-based).</span></div><div class="line"><a name="l11520"></a><span class="lineno">11520</span> <span class="keyword">const</span> TestPartResult& TestPartResultArray::GetTestPartResult(<span class="keywordtype">int</span> index)<span class="keyword"> const </span>{</div><div class="line"><a name="l11521"></a><span class="lineno">11521</span>  <span class="keywordflow">if</span> (index < 0 || index >= <a class="code" href="namespaceutl_1_1meta.html#a0edfc2c15e42531e53c0822264d220ec">size</a>()) {</div><div class="line"><a name="l11522"></a><span class="lineno">11522</span>  printf(<span class="stringliteral">"\nInvalid index (%d) into TestPartResultArray.\n"</span>, index);</div><div class="line"><a name="l11523"></a><span class="lineno">11523</span>  <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a69b8278c59359dd6a6f941b4643db9fb">internal::posix::Abort</a>();</div><div class="line"><a name="l11524"></a><span class="lineno">11524</span>  }</div><div class="line"><a name="l11525"></a><span class="lineno">11525</span> </div><div class="line"><a name="l11526"></a><span class="lineno">11526</span>  <span class="keywordflow">return</span> array_[index];</div><div class="line"><a name="l11527"></a><span class="lineno">11527</span> }</div><div class="line"><a name="l11528"></a><span class="lineno">11528</span> </div><div class="line"><a name="l11529"></a><span class="lineno">11529</span> <span class="comment">// Returns the number of TestPartResult objects in the array.</span></div><div class="line"><a name="l11530"></a><span class="lineno">11530</span> <span class="keywordtype">int</span> <a class="code" href="namespaceutl_1_1meta.html#a0edfc2c15e42531e53c0822264d220ec">TestPartResultArray::size</a>()<span class="keyword"> const </span>{</div><div class="line"><a name="l11531"></a><span class="lineno">11531</span>  <span class="keywordflow">return</span> <span class="keyword">static_cast<</span><span class="keywordtype">int</span><span class="keyword">></span>(array_.size());</div><div class="line"><a name="l11532"></a><span class="lineno">11532</span> }</div><div class="line"><a name="l11533"></a><span class="lineno">11533</span> </div><div class="line"><a name="l11534"></a><span class="lineno">11534</span> <span class="keyword">namespace </span>internal {</div><div class="line"><a name="l11535"></a><span class="lineno">11535</span> </div><div class="line"><a name="l11536"></a><span class="lineno">11536</span> HasNewFatalFailureHelper::HasNewFatalFailureHelper()</div><div class="line"><a name="l11537"></a><span class="lineno">11537</span>  : has_new_fatal_failure_(false),</div><div class="line"><a name="l11538"></a><span class="lineno">11538</span>  original_reporter_(GetUnitTestImpl()-></div><div class="line"><a name="l11539"></a><span class="lineno">11539</span>  GetTestPartResultReporterForCurrentThread()) {</div><div class="line"><a name="l11540"></a><span class="lineno">11540</span>  GetUnitTestImpl()->SetTestPartResultReporterForCurrentThread(<span class="keyword">this</span>);</div><div class="line"><a name="l11541"></a><span class="lineno">11541</span> }</div><div class="line"><a name="l11542"></a><span class="lineno">11542</span> </div><div class="line"><a name="l11543"></a><span class="lineno">11543</span> HasNewFatalFailureHelper::~HasNewFatalFailureHelper() {</div><div class="line"><a name="l11544"></a><span class="lineno">11544</span>  GetUnitTestImpl()->SetTestPartResultReporterForCurrentThread(</div><div class="line"><a name="l11545"></a><span class="lineno">11545</span>  original_reporter_);</div><div class="line"><a name="l11546"></a><span class="lineno">11546</span> }</div><div class="line"><a name="l11547"></a><span class="lineno">11547</span> </div><div class="line"><a name="l11548"></a><span class="lineno">11548</span> <span class="keywordtype">void</span> HasNewFatalFailureHelper::ReportTestPartResult(</div><div class="line"><a name="l11549"></a><span class="lineno">11549</span>  <span class="keyword">const</span> TestPartResult& result) {</div><div class="line"><a name="l11550"></a><span class="lineno">11550</span>  <span class="keywordflow">if</span> (result.fatally_failed())</div><div class="line"><a name="l11551"></a><span class="lineno">11551</span>  has_new_fatal_failure_ = <span class="keyword">true</span>;</div><div class="line"><a name="l11552"></a><span class="lineno">11552</span>  original_reporter_->ReportTestPartResult(result);</div><div class="line"><a name="l11553"></a><span class="lineno">11553</span> }</div><div class="line"><a name="l11554"></a><span class="lineno">11554</span> </div><div class="line"><a name="l11555"></a><span class="lineno">11555</span> } <span class="comment">// namespace internal</span></div><div class="line"><a name="l11556"></a><span class="lineno">11556</span> </div><div class="line"><a name="l11557"></a><span class="lineno">11557</span> } <span class="comment">// namespace testing</span></div><div class="line"><a name="l11558"></a><span class="lineno">11558</span> <span class="comment">// Copyright 2008 Google Inc.</span></div><div class="line"><a name="l11559"></a><span class="lineno">11559</span> <span class="comment">// All Rights Reserved.</span></div><div class="line"><a name="l11560"></a><span class="lineno">11560</span> <span class="comment">//</span></div><div class="line"><a name="l11561"></a><span class="lineno">11561</span> <span class="comment">// Redistribution and use in source and binary forms, with or without</span></div><div class="line"><a name="l11562"></a><span class="lineno">11562</span> <span class="comment">// modification, are permitted provided that the following conditions are</span></div><div class="line"><a name="l11563"></a><span class="lineno">11563</span> <span class="comment">// met:</span></div><div class="line"><a name="l11564"></a><span class="lineno">11564</span> <span class="comment">//</span></div><div class="line"><a name="l11565"></a><span class="lineno">11565</span> <span class="comment">// * Redistributions of source code must retain the above copyright</span></div><div class="line"><a name="l11566"></a><span class="lineno">11566</span> <span class="comment">// notice, this list of conditions and the following disclaimer.</span></div><div class="line"><a name="l11567"></a><span class="lineno">11567</span> <span class="comment">// * Redistributions in binary form must reproduce the above</span></div><div class="line"><a name="l11568"></a><span class="lineno">11568</span> <span class="comment">// copyright notice, this list of conditions and the following disclaimer</span></div><div class="line"><a name="l11569"></a><span class="lineno">11569</span> <span class="comment">// in the documentation and/or other materials provided with the</span></div><div class="line"><a name="l11570"></a><span class="lineno">11570</span> <span class="comment">// distribution.</span></div><div class="line"><a name="l11571"></a><span class="lineno">11571</span> <span class="comment">// * Neither the name of Google Inc. nor the names of its</span></div><div class="line"><a name="l11572"></a><span class="lineno">11572</span> <span class="comment">// contributors may be used to endorse or promote products derived from</span></div><div class="line"><a name="l11573"></a><span class="lineno">11573</span> <span class="comment">// this software without specific prior written permission.</span></div><div class="line"><a name="l11574"></a><span class="lineno">11574</span> <span class="comment">//</span></div><div class="line"><a name="l11575"></a><span class="lineno">11575</span> <span class="comment">// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span></div><div class="line"><a name="l11576"></a><span class="lineno">11576</span> <span class="comment">// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</span></div><div class="line"><a name="l11577"></a><span class="lineno">11577</span> <span class="comment">// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR</span></div><div class="line"><a name="l11578"></a><span class="lineno">11578</span> <span class="comment">// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT</span></div><div class="line"><a name="l11579"></a><span class="lineno">11579</span> <span class="comment">// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span></div><div class="line"><a name="l11580"></a><span class="lineno">11580</span> <span class="comment">// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</span></div><div class="line"><a name="l11581"></a><span class="lineno">11581</span> <span class="comment">// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</span></div><div class="line"><a name="l11582"></a><span class="lineno">11582</span> <span class="comment">// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY</span></div><div class="line"><a name="l11583"></a><span class="lineno">11583</span> <span class="comment">// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span></div><div class="line"><a name="l11584"></a><span class="lineno">11584</span> <span class="comment">// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE</span></div><div class="line"><a name="l11585"></a><span class="lineno">11585</span> <span class="comment">// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span></div><div class="line"><a name="l11586"></a><span class="lineno">11586</span> </div><div class="line"><a name="l11587"></a><span class="lineno">11587</span> </div><div class="line"><a name="l11588"></a><span class="lineno">11588</span> </div><div class="line"><a name="l11589"></a><span class="lineno">11589</span> </div><div class="line"><a name="l11590"></a><span class="lineno">11590</span> <span class="keyword">namespace </span><a class="code" href="namespacetesting.html">testing</a> {</div><div class="line"><a name="l11591"></a><span class="lineno">11591</span> <span class="keyword">namespace </span>internal {</div><div class="line"><a name="l11592"></a><span class="lineno">11592</span> </div><div class="line"><a name="l11593"></a><span class="lineno">11593</span> <span class="preprocessor">#if GTEST_HAS_TYPED_TEST_P</span></div><div class="line"><a name="l11594"></a><span class="lineno">11594</span> </div><div class="line"><a name="l11595"></a><span class="lineno">11595</span> <span class="comment">// Skips to the first non-space char in str. Returns an empty string if str</span></div><div class="line"><a name="l11596"></a><span class="lineno">11596</span> <span class="comment">// contains only whitespace characters.</span></div><div class="line"><a name="l11597"></a><span class="lineno">11597</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* SkipSpaces(<span class="keyword">const</span> <span class="keywordtype">char</span>* str) {</div><div class="line"><a name="l11598"></a><span class="lineno">11598</span>  <span class="keywordflow">while</span> (<a class="code" href="namespacetesting_1_1internal.html#af429e04f70f9c10f6aa76a5d1ccd389f">IsSpace</a>(*str))</div><div class="line"><a name="l11599"></a><span class="lineno">11599</span>  str++;</div><div class="line"><a name="l11600"></a><span class="lineno">11600</span>  <span class="keywordflow">return</span> str;</div><div class="line"><a name="l11601"></a><span class="lineno">11601</span> }</div><div class="line"><a name="l11602"></a><span class="lineno">11602</span> </div><div class="line"><a name="l11603"></a><span class="lineno">11603</span> <span class="keyword">static</span> std::vector<std::string> SplitIntoTestNames(<span class="keyword">const</span> <span class="keywordtype">char</span>* src) {</div><div class="line"><a name="l11604"></a><span class="lineno">11604</span>  std::vector<std::string> name_vec;</div><div class="line"><a name="l11605"></a><span class="lineno">11605</span>  src = SkipSpaces(src);</div><div class="line"><a name="l11606"></a><span class="lineno">11606</span>  <span class="keywordflow">for</span> (; src != <span class="keyword">nullptr</span>; src = SkipComma(src)) {</div><div class="line"><a name="l11607"></a><span class="lineno">11607</span>  name_vec.push_back(<a class="code" href="namespacetesting_1_1internal.html#aa6afda12e567c353e2e9b9c2e8cae14f">StripTrailingSpaces</a>(GetPrefixUntilComma(src)));</div><div class="line"><a name="l11608"></a><span class="lineno">11608</span>  }</div><div class="line"><a name="l11609"></a><span class="lineno">11609</span>  <span class="keywordflow">return</span> name_vec;</div><div class="line"><a name="l11610"></a><span class="lineno">11610</span> }</div><div class="line"><a name="l11611"></a><span class="lineno">11611</span> </div><div class="line"><a name="l11612"></a><span class="lineno">11612</span> <span class="comment">// Verifies that registered_tests match the test names in</span></div><div class="line"><a name="l11613"></a><span class="lineno">11613</span> <span class="comment">// registered_tests_; returns registered_tests if successful, or</span></div><div class="line"><a name="l11614"></a><span class="lineno">11614</span> <span class="comment">// aborts the program otherwise.</span></div><div class="line"><a name="l11615"></a><span class="lineno">11615</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* TypedTestSuitePState::VerifyRegisteredTestNames(</div><div class="line"><a name="l11616"></a><span class="lineno">11616</span>  <span class="keyword">const</span> <span class="keywordtype">char</span>* file, <span class="keywordtype">int</span> line, <span class="keyword">const</span> <span class="keywordtype">char</span>* registered_tests) {</div><div class="line"><a name="l11617"></a><span class="lineno">11617</span>  <span class="keyword">typedef</span> RegisteredTestsMap::const_iterator RegisteredTestIter;</div><div class="line"><a name="l11618"></a><span class="lineno">11618</span>  registered_ = <span class="keyword">true</span>;</div><div class="line"><a name="l11619"></a><span class="lineno">11619</span> </div><div class="line"><a name="l11620"></a><span class="lineno">11620</span>  std::vector<std::string> name_vec = SplitIntoTestNames(registered_tests);</div><div class="line"><a name="l11621"></a><span class="lineno">11621</span> </div><div class="line"><a name="l11622"></a><span class="lineno">11622</span>  Message errors;</div><div class="line"><a name="l11623"></a><span class="lineno">11623</span> </div><div class="line"><a name="l11624"></a><span class="lineno">11624</span>  std::set<std::string> tests;</div><div class="line"><a name="l11625"></a><span class="lineno">11625</span>  <span class="keywordflow">for</span> (std::vector<std::string>::const_iterator name_it = name_vec.begin();</div><div class="line"><a name="l11626"></a><span class="lineno">11626</span>  name_it != name_vec.end(); ++name_it) {</div><div class="line"><a name="l11627"></a><span class="lineno">11627</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& name = *name_it;</div><div class="line"><a name="l11628"></a><span class="lineno">11628</span>  <span class="keywordflow">if</span> (tests.count(name) != 0) {</div><div class="line"><a name="l11629"></a><span class="lineno">11629</span>  errors << <span class="stringliteral">"Test "</span> << name << <span class="stringliteral">" is listed more than once.\n"</span>;</div><div class="line"><a name="l11630"></a><span class="lineno">11630</span>  <span class="keywordflow">continue</span>;</div><div class="line"><a name="l11631"></a><span class="lineno">11631</span>  }</div><div class="line"><a name="l11632"></a><span class="lineno">11632</span> </div><div class="line"><a name="l11633"></a><span class="lineno">11633</span>  <span class="keywordtype">bool</span> found = <span class="keyword">false</span>;</div><div class="line"><a name="l11634"></a><span class="lineno">11634</span>  <span class="keywordflow">for</span> (RegisteredTestIter it = registered_tests_.begin();</div><div class="line"><a name="l11635"></a><span class="lineno">11635</span>  it != registered_tests_.end();</div><div class="line"><a name="l11636"></a><span class="lineno">11636</span>  ++it) {</div><div class="line"><a name="l11637"></a><span class="lineno">11637</span>  <span class="keywordflow">if</span> (name == it->first) {</div><div class="line"><a name="l11638"></a><span class="lineno">11638</span>  found = <span class="keyword">true</span>;</div><div class="line"><a name="l11639"></a><span class="lineno">11639</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l11640"></a><span class="lineno">11640</span>  }</div><div class="line"><a name="l11641"></a><span class="lineno">11641</span>  }</div><div class="line"><a name="l11642"></a><span class="lineno">11642</span> </div><div class="line"><a name="l11643"></a><span class="lineno">11643</span>  <span class="keywordflow">if</span> (found) {</div><div class="line"><a name="l11644"></a><span class="lineno">11644</span>  tests.insert(name);</div><div class="line"><a name="l11645"></a><span class="lineno">11645</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l11646"></a><span class="lineno">11646</span>  errors << <span class="stringliteral">"No test named "</span> << name</div><div class="line"><a name="l11647"></a><span class="lineno">11647</span>  << <span class="stringliteral">" can be found in this test suite.\n"</span>;</div><div class="line"><a name="l11648"></a><span class="lineno">11648</span>  }</div><div class="line"><a name="l11649"></a><span class="lineno">11649</span>  }</div><div class="line"><a name="l11650"></a><span class="lineno">11650</span> </div><div class="line"><a name="l11651"></a><span class="lineno">11651</span>  <span class="keywordflow">for</span> (RegisteredTestIter it = registered_tests_.begin();</div><div class="line"><a name="l11652"></a><span class="lineno">11652</span>  it != registered_tests_.end();</div><div class="line"><a name="l11653"></a><span class="lineno">11653</span>  ++it) {</div><div class="line"><a name="l11654"></a><span class="lineno">11654</span>  <span class="keywordflow">if</span> (tests.count(it->first) == 0) {</div><div class="line"><a name="l11655"></a><span class="lineno">11655</span>  errors << <span class="stringliteral">"You forgot to list test "</span> << it->first << <span class="stringliteral">".\n"</span>;</div><div class="line"><a name="l11656"></a><span class="lineno">11656</span>  }</div><div class="line"><a name="l11657"></a><span class="lineno">11657</span>  }</div><div class="line"><a name="l11658"></a><span class="lineno">11658</span> </div><div class="line"><a name="l11659"></a><span class="lineno">11659</span>  <span class="keyword">const</span> <a class="code" href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">std::string</a>& errors_str = errors.GetString();</div><div class="line"><a name="l11660"></a><span class="lineno">11660</span>  <span class="keywordflow">if</span> (errors_str != <span class="stringliteral">""</span>) {</div><div class="line"><a name="l11661"></a><span class="lineno">11661</span>  fprintf(stderr, <span class="stringliteral">"%s %s"</span>, <a class="code" href="namespacetesting_1_1internal.html#a31b7c3abed4a7c395f42c61e993989f4">FormatFileLocation</a>(file, line).c_str(),</div><div class="line"><a name="l11662"></a><span class="lineno">11662</span>  errors_str.c_str());</div><div class="line"><a name="l11663"></a><span class="lineno">11663</span>  fflush(stderr);</div><div class="line"><a name="l11664"></a><span class="lineno">11664</span>  <a class="code" href="namespacetesting_1_1internal_1_1posix.html#a69b8278c59359dd6a6f941b4643db9fb">posix::Abort</a>();</div><div class="line"><a name="l11665"></a><span class="lineno">11665</span>  }</div><div class="line"><a name="l11666"></a><span class="lineno">11666</span> </div><div class="line"><a name="l11667"></a><span class="lineno">11667</span>  <span class="keywordflow">return</span> registered_tests;</div><div class="line"><a name="l11668"></a><span class="lineno">11668</span> }</div><div class="line"><a name="l11669"></a><span class="lineno">11669</span> </div><div class="line"><a name="l11670"></a><span class="lineno">11670</span> <span class="preprocessor">#endif // GTEST_HAS_TYPED_TEST_P</span></div><div class="line"><a name="l11671"></a><span class="lineno">11671</span> </div><div class="line"><a name="l11672"></a><span class="lineno">11672</span> } <span class="comment">// namespace internal</span></div><div class="line"><a name="l11673"></a><span class="lineno">11673</span> } <span class="comment">// namespace testing</span></div><div class="ttc" id="namespacetesting_1_1internal_html_aa234ef141278263fb143b616c74c86e7"><div class="ttname"><a href="namespacetesting_1_1internal.html#aa234ef141278263fb143b616c74c86e7">testing::internal::IsXDigit</a></div><div class="ttdeci">bool IsXDigit(char ch)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02251">gtest.h:2251</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a0c577e598e61d339ba45dd6643fb1969"><div class="ttname"><a href="namespacetesting_1_1internal.html#a0c577e598e61d339ba45dd6643fb1969">testing::internal::PrintCharAndCodeTo</a></div><div class="ttdeci">void PrintCharAndCodeTo(Char c, ostream *os)</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l11218">gtest-all.cc:11218</a></div></div>
- <div class="ttc" id="namespacetesting_html_a84c020b981d0eb4eabfb0feda155aaaf"><div class="ttname"><a href="namespacetesting.html#a84c020b981d0eb4eabfb0feda155aaaf">testing::DoubleLE</a></div><div class="ttdeci">GTEST_API_ AssertionResult DoubleLE(const char *expr1, const char *expr2, double val1, double val2)</div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a4d46f09c3bfe68700b7f728d2cc3782f"><div class="ttname"><a href="namespacetesting_1_1internal.html#a4d46f09c3bfe68700b7f728d2cc3782f">testing::internal::AlwaysTrue</a></div><div class="ttdeci">GTEST_API_ bool AlwaysTrue()</div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_aed657219a9856a8d249a3230de0c54ce"><div class="ttname"><a href="namespacetesting_1_1internal.html#aed657219a9856a8d249a3230de0c54ce">testing::internal::GetCapturedStdout</a></div><div class="ttdeci">std::string GetCapturedStdout()</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l10789">gtest-all.cc:10789</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_aea60207c4cedc8946a70ada62e38da8f"><div class="ttname"><a href="namespacetesting_1_1internal.html#aea60207c4cedc8946a70ada62e38da8f">testing::internal::DoubleNearPredFormat</a></div><div class="ttdeci">GTEST_API_ AssertionResult DoubleNearPredFormat(const char *expr1, const char *expr2, const char *abs_error_expr, double val1, double val2, double abs_error)</div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a374156401da17704099d0c33fa53adfb"><div class="ttname"><a href="namespacetesting_1_1internal.html#a374156401da17704099d0c33fa53adfb">testing::internal::GetCapturedStderr</a></div><div class="ttdeci">std::string GetCapturedStderr()</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l10794">gtest-all.cc:10794</a></div></div>
- <div class="ttc" id="namespacetesting_html"><div class="ttname"><a href="namespacetesting.html">testing</a></div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l07620">gtest-all.cc:7620</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_ae7ae495d3207e26968dfbd537c5e6dee"><div class="ttname"><a href="namespacetesting_1_1internal.html#ae7ae495d3207e26968dfbd537c5e6dee">testing::internal::GetCurrentOsStackTraceExceptTop</a></div><div class="ttdeci">GTEST_API_ std::string GetCurrentOsStackTraceExceptTop(UnitTest *unit_test, int skip_count)</div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a83e4e0732ac6a9dcfe6ee299dc1b9fa2"><div class="ttname"><a href="namespacetesting_1_1internal.html#a83e4e0732ac6a9dcfe6ee299dc1b9fa2">testing::internal::SetUpTestSuiteFunc</a></div><div class="ttdeci">void(*)() SetUpTestSuiteFunc</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l06926">gtest.h:6926</a></div></div>
- <div class="ttc" id="gtest_8h_html_aa5e27ad4f88278501ef71bd9ddbb44c6"><div class="ttname"><a href="gtest_8h.html#aa5e27ad4f88278501ef71bd9ddbb44c6">GTEST_INIT_GOOGLE_TEST_NAME_</a></div><div class="ttdeci">#define GTEST_INIT_GOOGLE_TEST_NAME_</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l00522">gtest.h:522</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_aac72b20299ad4a99554ce161e1769560"><div class="ttname"><a href="namespacetesting_1_1internal.html#aac72b20299ad4a99554ce161e1769560">testing::internal::SkipPrefix</a></div><div class="ttdeci">GTEST_API_ bool SkipPrefix(const char *prefix, const char **pstr)</div></div>
- <div class="ttc" id="gtest_8h_html_a88ee2f19589ffff86ca742fd33611358"><div class="ttname"><a href="gtest_8h.html#a88ee2f19589ffff86ca742fd33611358">GTEST_DEFINE_int32_</a></div><div class="ttdeci">#define GTEST_DEFINE_int32_(name, default_val, doc)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02505">gtest.h:2505</a></div></div>
- <div class="ttc" id="gtest_8h_html_a4251ff898f9f94ec6b8b9402c3436759"><div class="ttname"><a href="gtest_8h.html#a4251ff898f9f94ec6b8b9402c3436759">GTEST_FLAG_PREFIX_DASH_</a></div><div class="ttdeci">#define GTEST_FLAG_PREFIX_DASH_</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l00515">gtest.h:515</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_1_1posix_html_af4beeaaa8d62916d5e3b644a1ddfbd6b"><div class="ttname"><a href="namespacetesting_1_1internal_1_1posix.html#af4beeaaa8d62916d5e3b644a1ddfbd6b">testing::internal::posix::FClose</a></div><div class="ttdeci">int FClose(FILE *fp)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02358">gtest.h:2358</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_ae2ef98247c76a50cdc80ceb4a6c81793aebfa5293302338a8e8678744c103f113"><div class="ttname"><a href="namespacetesting_1_1internal.html#ae2ef98247c76a50cdc80ceb4a6c81793aebfa5293302338a8e8678744c103f113">testing::internal::kHexEscape</a></div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l11128">gtest-all.cc:11128</a></div></div>
- <div class="ttc" id="gtest-all_8cc_html_ad9d445747785a9271a57cf1d392b89ad"><div class="ttname"><a href="gtest-all_8cc.html#ad9d445747785a9271a57cf1d392b89ad">GTEST_PATH_MAX_</a></div><div class="ttdeci">#define GTEST_PATH_MAX_</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l09221">gtest-all.cc:9221</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a8cbd8bf820517923d7f3c4477b3af5fa"><div class="ttname"><a href="namespacetesting_1_1internal.html#a8cbd8bf820517923d7f3c4477b3af5fa">testing::internal::GetThreadCount</a></div><div class="ttdeci">size_t GetThreadCount()</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l09875">gtest-all.cc:9875</a></div></div>
- <div class="ttc" id="gtest_8h_html_a9945cbd967fbccb15f8de711f58955c7"><div class="ttname"><a href="gtest_8h.html#a9945cbd967fbccb15f8de711f58955c7">GTEST_NO_INLINE_</a></div><div class="ttdeci">#define GTEST_NO_INLINE_</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l01009">gtest.h:1009</a></div></div>
- <div class="ttc" id="namespaceutl_1_1meta_html_ac72acc616316c322e750d20a46553ba4"><div class="ttname"><a href="namespaceutl_1_1meta.html#ac72acc616316c322e750d20a46553ba4">utl::meta::filter</a></div><div class="ttdeci">eval< filter_impl::filter_< List, Pred, typelist<> > > filter</div><div class="ttdef"><b>Definition:</b> <a href="typelist_8h_source.html#l00800">typelist.h:800</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a4638c74d9b32e971f9b321af6fafc2f1"><div class="ttname"><a href="namespacetesting_1_1internal.html#a4638c74d9b32e971f9b321af6fafc2f1">testing::internal::CmpHelperEQ</a></div><div class="ttdeci">AssertionResult CmpHelperEQ(const char *lhs_expression, const char *rhs_expression, const T1 &lhs, const T2 &rhs)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l16111">gtest.h:16111</a></div></div>
- <div class="ttc" id="gtest_8h_html_a21086d276b1a64d6763ee8a94b12c1b8"><div class="ttname"><a href="gtest_8h.html#a21086d276b1a64d6763ee8a94b12c1b8">GTEST_DEV_EMAIL_</a></div><div class="ttdeci">#define GTEST_DEV_EMAIL_</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l00513">gtest.h:513</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_ab2709373c78eb8b1c22a6ba30cceba52"><div class="ttname"><a href="namespacetesting_1_1internal.html#ab2709373c78eb8b1c22a6ba30cceba52">testing::internal::IsTrue</a></div><div class="ttdeci">GTEST_API_ bool IsTrue(bool condition)</div></div>
- <div class="ttc" id="namespacetesting_html_aa5717bb1144edd1d262d310ba70c82ed"><div class="ttname"><a href="namespacetesting.html#aa5717bb1144edd1d262d310ba70c82ed">testing::PrintToString</a></div><div class="ttdeci">::std::string PrintToString(const T &value)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l08969">gtest.h:8969</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_1_1edit__distance_html_ad46aa6da12aec1a3f166310478b53a08a7bdb9c74613a94f21b7489e0b5640a63"><div class="ttname"><a href="namespacetesting_1_1internal_1_1edit__distance.html#ad46aa6da12aec1a3f166310478b53a08a7bdb9c74613a94f21b7489e0b5640a63">testing::internal::edit_distance::kMatch</a></div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l06605">gtest.h:6605</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_ab81b0af2a0131ea54dc11de00d5e6e51"><div class="ttname"><a href="namespacetesting_1_1internal.html#ab81b0af2a0131ea54dc11de00d5e6e51">testing::internal::ReadEntireFile</a></div><div class="ttdeci">std::string ReadEntireFile(FILE *file)</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l10809">gtest-all.cc:10809</a></div></div>
- <div class="ttc" id="gtest_8h_html_aa0dc86dc9837f1610e91da65458f53b3"><div class="ttname"><a href="gtest_8h.html#aa0dc86dc9837f1610e91da65458f53b3">GTEST_DISABLE_MSC_DEPRECATED_POP_</a></div><div class="ttdeci">#define GTEST_DISABLE_MSC_DEPRECATED_POP_()</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l00561">gtest.h:561</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_aa6255ef3b023c5b4e1a2198d887fb977a7a051bc2794f15a4bf0eab40562a304c"><div class="ttname"><a href="namespacetesting_1_1internal.html#aa6255ef3b023c5b4e1a2198d887fb977a7a051bc2794f15a4bf0eab40562a304c">testing::internal::GTEST_WARNING</a></div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l01221">gtest.h:1221</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a6b485231a046ff760844a0321c04870b"><div class="ttname"><a href="namespacetesting_1_1internal.html#a6b485231a046ff760844a0321c04870b">testing::internal::CmpHelperSTRNE</a></div><div class="ttdeci">GTEST_API_ AssertionResult CmpHelperSTRNE(const char *s1_expression, const char *s2_expression, const char *s1, const char *s2)</div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a1055088bb9b867e1b7b8f096f519d7c5"><div class="ttname"><a href="namespacetesting_1_1internal.html#a1055088bb9b867e1b7b8f096f519d7c5">testing::internal::BoolFromGTestEnv</a></div><div class="ttdeci">bool BoolFromGTestEnv(const char *flag, bool default_value)</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l10934">gtest-all.cc:10934</a></div></div>
- <div class="ttc" id="namespacetesting_html_a5c90a86562b2470213c07742e0eeb0fe"><div class="ttname"><a href="namespacetesting.html#a5c90a86562b2470213c07742e0eeb0fe">testing::IsSubstring</a></div><div class="ttdeci">GTEST_API_ AssertionResult IsSubstring(const char *needle_expr, const char *haystack_expr, const char *needle, const char *haystack)</div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a31b7c3abed4a7c395f42c61e993989f4"><div class="ttname"><a href="namespacetesting_1_1internal.html#a31b7c3abed4a7c395f42c61e993989f4">testing::internal::FormatFileLocation</a></div><div class="ttdeci">GTEST_API_ ::std::string FormatFileLocation(const char *file, int line)</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l10620">gtest-all.cc:10620</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_1_1edit__distance_html_ad46aa6da12aec1a3f166310478b53a08a814768ef6cd0264a0a10b1e701a63e78"><div class="ttname"><a href="namespacetesting_1_1internal_1_1edit__distance.html#ad46aa6da12aec1a3f166310478b53a08a814768ef6cd0264a0a10b1e701a63e78">testing::internal::edit_distance::kRemove</a></div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l06605">gtest.h:6605</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_1_1posix_html_a16ebe936b3a8ea462a94191635aedc27"><div class="ttname"><a href="namespacetesting_1_1internal_1_1posix.html#a16ebe936b3a8ea462a94191635aedc27">testing::internal::posix::IsATTY</a></div><div class="ttdeci">int IsATTY(int fd)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02323">gtest.h:2323</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a8e8ff5b11e64078831112677156cb111"><div class="ttname"><a href="namespacetesting_1_1internal.html#a8e8ff5b11e64078831112677156cb111">testing::internal::string</a></div><div class="ttdeci">::std::string string</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l01115">gtest.h:1115</a></div></div>
- <div class="ttc" id="gtest_8h_html_aed1cc8143222d7a845a1269448ec203e"><div class="ttname"><a href="gtest_8h.html#aed1cc8143222d7a845a1269448ec203e">GTEST_SNPRINTF_</a></div><div class="ttdeci">#define GTEST_SNPRINTF_</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02410">gtest.h:2410</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a2196f070b2d28bceb45c7ad3b565b9ba"><div class="ttname"><a href="namespacetesting_1_1internal.html#a2196f070b2d28bceb45c7ad3b565b9ba">testing::internal::Int32FromGTestEnv</a></div><div class="ttdeci">Int32 Int32FromGTestEnv(const char *flag, Int32 default_value)</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l10948">gtest-all.cc:10948</a></div></div>
- <div class="ttc" id="gtest_8h_html_a2a83dd79037e53814a509cc3f5702650"><div class="ttname"><a href="gtest_8h.html#a2a83dd79037e53814a509cc3f5702650">GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_</a></div><div class="ttdeci">#define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l01031">gtest.h:1031</a></div></div>
- <div class="ttc" id="gtest-all_8cc_html_a88f79832f9d045112a76e9da8611cc13"><div class="ttname"><a href="gtest-all_8cc.html#a88f79832f9d045112a76e9da8611cc13">GTEST_DISABLE_MSC_WARNINGS_PUSH_</a></div><div class="ttdeci">GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251) namespace testing</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l00112">gtest-all.cc:112</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_1_1edit__distance_html_ad28f23b77f716200bc6644bfc7413a63"><div class="ttname"><a href="namespacetesting_1_1internal_1_1edit__distance.html#ad28f23b77f716200bc6644bfc7413a63">testing::internal::edit_distance::CalculateOptimalEdits</a></div><div class="ttdeci">GTEST_API_ std::vector< EditType > CalculateOptimalEdits(const std::vector< size_t > &left, const std::vector< size_t > &right)</div></div>
- <div class="ttc" id="gtest_8h_html_a491d09ee62f1c9cfeafa3dbf75aaa9e2"><div class="ttname"><a href="gtest_8h.html#a491d09ee62f1c9cfeafa3dbf75aaa9e2">GTEST_DEFAULT_DEATH_TEST_STYLE</a></div><div class="ttdeci">#define GTEST_DEFAULT_DEATH_TEST_STYLE</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l01002">gtest.h:1002</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_ac06fc81336a3d80755f4020d34321766"><div class="ttname"><a href="namespacetesting_1_1internal.html#ac06fc81336a3d80755f4020d34321766">testing::internal::ParseInt32</a></div><div class="ttdeci">bool ParseInt32(const Message &src_text, const char *str, Int32 *value)</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l10892">gtest-all.cc:10892</a></div></div>
- <div class="ttc" id="namespaceutl_1_1meta_html_a0edfc2c15e42531e53c0822264d220ec"><div class="ttname"><a href="namespaceutl_1_1meta.html#a0edfc2c15e42531e53c0822264d220ec">utl::meta::size</a></div><div class="ttdeci">size_< List::size()> size</div><div class="ttdef"><b>Definition:</b> <a href="typelist_8h_source.html#l00129">typelist.h:129</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a3f543179329c353aee1d7b54a9a8e335"><div class="ttname"><a href="namespacetesting_1_1internal.html#a3f543179329c353aee1d7b54a9a8e335">testing::internal::wstring</a></div><div class="ttdeci">::std::wstring wstring</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l01121">gtest.h:1121</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a4bd96b7fa6486802d33ddc217af55a39"><div class="ttname"><a href="namespacetesting_1_1internal.html#a4bd96b7fa6486802d33ddc217af55a39">testing::internal::IsDigit</a></div><div class="ttdeci">bool IsDigit(char ch)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02239">gtest.h:2239</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_aa6255ef3b023c5b4e1a2198d887fb977a75063567740f6bf7da419b1b9197b12e"><div class="ttname"><a href="namespacetesting_1_1internal.html#aa6255ef3b023c5b4e1a2198d887fb977a75063567740f6bf7da419b1b9197b12e">testing::internal::GTEST_FATAL</a></div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l01223">gtest.h:1223</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_1_1posix_html_a2b87b7ff647a128614daf50667eb9304"><div class="ttname"><a href="namespacetesting_1_1internal_1_1posix.html#a2b87b7ff647a128614daf50667eb9304">testing::internal::posix::Stat</a></div><div class="ttdeci">int Stat(const char *path, StatStruct *buf)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02324">gtest.h:2324</a></div></div>
- <div class="ttc" id="gtest_8h_html_afbb636e91bdd50267dbef11a50490b29"><div class="ttname"><a href="gtest_8h.html#afbb636e91bdd50267dbef11a50490b29">GTEST_PATH_SEP_</a></div><div class="ttdeci">#define GTEST_PATH_SEP_</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02221">gtest.h:2221</a></div></div>
- <div class="ttc" id="namespacetesting_html_ab553b649b06ef2339cbd90f8dfa119f0"><div class="ttname"><a href="namespacetesting.html#ab553b649b06ef2339cbd90f8dfa119f0">testing::IsNotSubstring</a></div><div class="ttdeci">GTEST_API_ AssertionResult IsNotSubstring(const char *needle_expr, const char *haystack_expr, const char *needle, const char *haystack)</div></div>
- <div class="ttc" id="namespaceutl_1_1meta_html_a67329ec425c857dcaf4cde9044674c90"><div class="ttname"><a href="namespaceutl_1_1meta.html#a67329ec425c857dcaf4cde9044674c90">utl::meta::at</a></div><div class="ttdeci">at_c< List, N::type::value > at</div><div class="ttdef"><b>Definition:</b> <a href="typelist_8h_source.html#l00253">typelist.h:253</a></div></div>
- <div class="ttc" id="gtest-all_8cc_html_a789f37f9c345c2032699c194a58623d9"><div class="ttname"><a href="gtest-all_8cc.html#a789f37f9c345c2032699c194a58623d9">GTEST_DISABLE_MSC_WARNINGS_POP_</a></div><div class="ttdeci">GTEST_DISABLE_MSC_WARNINGS_POP_() GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251) namespace testing</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l00190">gtest-all.cc:190</a></div></div>
- <div class="ttc" id="namespaceutl_1_1meta_html_a2ae6bfa22f1912b0ba09d24e0ae2ccd9"><div class="ttname"><a href="namespaceutl_1_1meta.html#a2ae6bfa22f1912b0ba09d24e0ae2ccd9">utl::meta::reverse</a></div><div class="ttdeci">eval< reverse_impl::reverse_< List > > reverse</div><div class="ttdef"><b>Definition:</b> <a href="typelist_8h_source.html#l00479">typelist.h:479</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a648c1bc94c2ef9e868ff3f9dff0f9c4e"><div class="ttname"><a href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4e">testing::internal::GTestColor</a></div><div class="ttdeci">GTestColor</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l16427">gtest.h:16427</a></div></div>
- <div class="ttc" id="namespaceutl_1_1meta_html_aa013c45afb59b5c132a72be54ba145fb"><div class="ttname"><a href="namespaceutl_1_1meta.html#aa013c45afb59b5c132a72be54ba145fb">utl::meta::repeat</a></div><div class="ttdeci">repeat_c< N::type::value, Ts... > repeat</div><div class="ttdef"><b>Definition:</b> <a href="typelist_8h_source.html#l00161">typelist.h:161</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_1_1edit__distance_html_ad46aa6da12aec1a3f166310478b53a08"><div class="ttname"><a href="namespacetesting_1_1internal_1_1edit__distance.html#ad46aa6da12aec1a3f166310478b53a08">testing::internal::edit_distance::EditType</a></div><div class="ttdeci">EditType</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l06605">gtest.h:6605</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_1_1posix_html_a1d5e3da5a27eed25986859fa83cafe95"><div class="ttname"><a href="namespacetesting_1_1internal_1_1posix.html#a1d5e3da5a27eed25986859fa83cafe95">testing::internal::posix::GetEnv</a></div><div class="ttdeci">const char * GetEnv(const char *name)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02369">gtest.h:2369</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_ad609167d8d6792b0fb186539e0e159bd"><div class="ttname"><a href="namespacetesting_1_1internal.html#ad609167d8d6792b0fb186539e0e159bd">testing::internal::PrintStringTo</a></div><div class="ttdeci">void PrintStringTo(const ::std::string &s, ostream *os)</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l11432">gtest-all.cc:11432</a></div></div>
- <div class="ttc" id="gtest_8h_html"><div class="ttname"><a href="gtest_8h.html">gtest.h</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_acba06d4f0343dec407738ba5544af990"><div class="ttname"><a href="namespacetesting_1_1internal.html#acba06d4f0343dec407738ba5544af990">testing::internal::CaptureStdout</a></div><div class="ttdeci">void CaptureStdout()</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l10779">gtest-all.cc:10779</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a91ab078f10adc669f09b7f604975c518"><div class="ttname"><a href="namespacetesting_1_1internal.html#a91ab078f10adc669f09b7f604975c518">testing::internal::FormatForComparisonFailureMessage</a></div><div class="ttdeci">std::string FormatForComparisonFailureMessage(const T1 &value, const T2 &)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l08416">gtest.h:8416</a></div></div>
- <div class="ttc" id="gtest_8h_html_a5b130138db254deaf29dbe3dffa1a2a8"><div class="ttname"><a href="gtest_8h.html#a5b130138db254deaf29dbe3dffa1a2a8">GTEST_DISABLE_MSC_DEPRECATED_PUSH_</a></div><div class="ttdeci">#define GTEST_DISABLE_MSC_DEPRECATED_PUSH_()</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l00559">gtest.h:559</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a66a845df404b38fe85c5e14a069f255a"><div class="ttname"><a href="namespacetesting_1_1internal.html#a66a845df404b38fe85c5e14a069f255a">testing::internal::TimeInMillis</a></div><div class="ttdeci">TypeWithSize< 8 >::Int TimeInMillis</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02479">gtest.h:2479</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_aa6255ef3b023c5b4e1a2198d887fb977"><div class="ttname"><a href="namespacetesting_1_1internal.html#aa6255ef3b023c5b4e1a2198d887fb977">testing::internal::GTestLogSeverity</a></div><div class="ttdeci">GTestLogSeverity</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l01219">gtest.h:1219</a></div></div>
- <div class="ttc" id="namespaceutl_1_1meta_html_ac9d120f858ebfa2b0ef74c6305a9fb6d"><div class="ttname"><a href="namespaceutl_1_1meta.html#ac9d120f858ebfa2b0ef74c6305a9fb6d">utl::meta::replace</a></div><div class="ttdeci">eval< replace_if< List, same_as< T >, U > > replace</div><div class="ttdef"><b>Definition:</b> <a href="typelist_8h_source.html#l00848">typelist.h:848</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_ac61e2ba2cbf259fd6ee5ffd4e49c9445"><div class="ttname"><a href="namespacetesting_1_1internal.html#ac61e2ba2cbf259fd6ee5ffd4e49c9445">testing::internal::EqFailure</a></div><div class="ttdeci">GTEST_API_ AssertionResult EqFailure(const char *expected_expression, const char *actual_expression, const std::string &expected_value, const std::string &actual_value, bool ignoring_case)</div></div>
- <div class="ttc" id="namespaceutl_1_1meta_html_af4c9b6350bba98cc0dd73e87cb4ce413"><div class="ttname"><a href="namespaceutl_1_1meta.html#af4c9b6350bba98cc0dd73e87cb4ce413">utl::meta::find</a></div><div class="ttdeci">find_if< List, same_as< T > > find</div><div class="ttdef"><b>Definition:</b> <a href="typelist_8h_source.html#l00663">typelist.h:663</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_1_1edit__distance_html_ad46aa6da12aec1a3f166310478b53a08a63400b073f5b311a87d568b5ae27ffe8"><div class="ttname"><a href="namespacetesting_1_1internal_1_1edit__distance.html#ad46aa6da12aec1a3f166310478b53a08a63400b073f5b311a87d568b5ae27ffe8">testing::internal::edit_distance::kAdd</a></div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l06605">gtest.h:6605</a></div></div>
- <div class="ttc" id="namespacetesting_html_a266e39b7c4691fedb856047673a412d8"><div class="ttname"><a href="namespacetesting.html#a266e39b7c4691fedb856047673a412d8">testing::operator<<</a></div><div class="ttdeci">std::ostream & operator<<(std::ostream &os, const TestPartResult &result)</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l11501">gtest-all.cc:11501</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a23a8e9527d0e544e7df2d64ad549ce3e"><div class="ttname"><a href="namespacetesting_1_1internal.html#a23a8e9527d0e544e7df2d64ad549ce3e">testing::internal::kCurrentDirectoryString</a></div><div class="ttdeci">const char kCurrentDirectoryString[]</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l09247">gtest-all.cc:9247</a></div></div>
- <div class="ttc" id="gtest_8h_html_a14eb0e9c6e0df765d1fbfd2db6966d14"><div class="ttname"><a href="gtest_8h.html#a14eb0e9c6e0df765d1fbfd2db6966d14">GTEST_DECLARE_bool_</a></div><div class="ttdeci">#define GTEST_DECLARE_bool_(name)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02496">gtest.h:2496</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a40bcfd87e26aae36e0cc51e5db64fd89"><div class="ttname"><a href="namespacetesting_1_1internal.html#a40bcfd87e26aae36e0cc51e5db64fd89">testing::internal::GetFileSize</a></div><div class="ttdeci">size_t GetFileSize(FILE *file)</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l10804">gtest-all.cc:10804</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_aad4beed95d0846e6ffc5da0978ef3bb9"><div class="ttname"><a href="namespacetesting_1_1internal.html#aad4beed95d0846e6ffc5da0978ef3bb9">testing::internal::StreamableToString</a></div><div class="ttdeci">std::string StreamableToString(const T &streamable)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02769">gtest.h:2769</a></div></div>
- <div class="ttc" id="namespaceutl_1_1meta_html_ab5508236016638fa8e6b97cd17dfc9c2"><div class="ttname"><a href="namespaceutl_1_1meta.html#ab5508236016638fa8e6b97cd17dfc9c2">utl::meta::count</a></div><div class="ttdeci">count_if< List, same_as< T > > count</div><div class="ttdef"><b>Definition:</b> <a href="typelist_8h_source.html#l00761">typelist.h:761</a></div></div>
- <div class="ttc" id="gtest_8h_html_a8ef4cb4c465db8c15464aecc6d9510ef"><div class="ttname"><a href="gtest_8h.html#a8ef4cb4c465db8c15464aecc6d9510ef">GTEST_LOG_</a></div><div class="ttdeci">#define GTEST_LOG_(severity)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l01246">gtest.h:1246</a></div></div>
- <div class="ttc" id="gtest_8h_html_aa73be6f0ba4a7456180a94904ce17790"><div class="ttname"><a href="gtest_8h.html#aa73be6f0ba4a7456180a94904ce17790">GTEST_API_</a></div><div class="ttdeci">#define GTEST_API_</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l00998">gtest.h:998</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a40d4fffcd2bf56f18b1c380615aa85e3"><div class="ttname"><a href="namespacetesting_1_1internal.html#a40d4fffcd2bf56f18b1c380615aa85e3">testing::internal::UInt32</a></div><div class="ttdeci">TypeWithSize< 4 >::UInt UInt32</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02476">gtest.h:2476</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_ab1114197d3c657d8b7f8e0c5caa12d00"><div class="ttname"><a href="namespacetesting_1_1internal.html#ab1114197d3c657d8b7f8e0c5caa12d00">testing::internal::TypeId</a></div><div class="ttdeci">const void * TypeId</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l06854">gtest.h:6854</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a0967cbf18fb1594f82512d8d822aba21"><div class="ttname"><a href="namespacetesting_1_1internal.html#a0967cbf18fb1594f82512d8d822aba21">testing::internal::StringFromGTestEnv</a></div><div class="ttdeci">const char * StringFromGTestEnv(const char *flag, const char *default_value)</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l10991">gtest-all.cc:10991</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_1_1posix_html_af4acf9f78d55f815a18b43786511abef"><div class="ttname"><a href="namespacetesting_1_1internal_1_1posix.html#af4acf9f78d55f815a18b43786511abef">testing::internal::posix::Write</a></div><div class="ttdeci">int Write(int fd, const void *buf, unsigned int count)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02363">gtest.h:2363</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal2_html_abfb9aa80365f93b952e9a4bea09947a8"><div class="ttname"><a href="namespacetesting_1_1internal2.html#abfb9aa80365f93b952e9a4bea09947a8">testing::internal2::PrintBytesInObjectTo</a></div><div class="ttdeci">void PrintBytesInObjectTo(const unsigned char *obj_bytes, size_t count, ostream *os)</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l11112">gtest-all.cc:11112</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a00c3d012df6173622ef558a131bfb95d"><div class="ttname"><a href="namespacetesting_1_1internal.html#a00c3d012df6173622ef558a131bfb95d">testing::internal::CmpHelperSTRCASEEQ</a></div><div class="ttdeci">GTEST_API_ AssertionResult CmpHelperSTRCASEEQ(const char *s1_expression, const char *s2_expression, const char *s1, const char *s2)</div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a8ee38faaf875f133358abaf9bc056cec"><div class="ttname"><a href="namespacetesting_1_1internal.html#a8ee38faaf875f133358abaf9bc056cec">testing::internal::Int32</a></div><div class="ttdeci">TypeWithSize< 4 >::Int Int32</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02475">gtest.h:2475</a></div></div>
- <div class="ttc" id="gtest-all_8cc_html_aa7da32fd7da6a8cceeed6b448cb7b5f2"><div class="ttname"><a href="gtest-all_8cc.html#aa7da32fd7da6a8cceeed6b448cb7b5f2">GTEST_REVERSE_REPEATER_METHOD_</a></div><div class="ttdeci">#define GTEST_REVERSE_REPEATER_METHOD_(Name, Type)</div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_af429e04f70f9c10f6aa76a5d1ccd389f"><div class="ttname"><a href="namespacetesting_1_1internal.html#af429e04f70f9c10f6aa76a5d1ccd389f">testing::internal::IsSpace</a></div><div class="ttdeci">bool IsSpace(char ch)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02245">gtest.h:2245</a></div></div>
- <div class="ttc" id="namespaceutl_1_1meta_html_a559ad95ef39fd2c81664bd1a22dd99c1"><div class="ttname"><a href="namespaceutl_1_1meta.html#a559ad95ef39fd2c81664bd1a22dd99c1">utl::meta::add</a></div><div class="ttdeci">integral_< decltype(_Tp1()+_Tp2()), _Tp1()+_Tp2() > add</div><div class="ttdoc">Addition. </div><div class="ttdef"><b>Definition:</b> <a href="operations_8h_source.html#l00144">operations.h:144</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a40b2a93ff318f5975eb8246b01221ce8"><div class="ttname"><a href="namespacetesting_1_1internal.html#a40b2a93ff318f5975eb8246b01221ce8">testing::internal::fmt</a></div><div class="ttdeci">GTEST_API_ const char * fmt</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l16430">gtest.h:16430</a></div></div>
- <div class="ttc" id="namespacetesting_html_abcf5181cecc3c07915dceb3de46ab07f"><div class="ttname"><a href="namespacetesting.html#abcf5181cecc3c07915dceb3de46ab07f">testing::TempDir</a></div><div class="ttdeci">GTEST_API_ std::string TempDir()</div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_afc20fb56b2547a8f91f9ff99650f2024"><div class="ttname"><a href="namespacetesting_1_1internal.html#afc20fb56b2547a8f91f9ff99650f2024">testing::internal::PrintTo</a></div><div class="ttdeci">void PrintTo(const wchar_t *s, ostream *os)</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l11344">gtest-all.cc:11344</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a999c7ef9ff01b6d2d76669372c444aa3"><div class="ttname"><a href="namespacetesting_1_1internal.html#a999c7ef9ff01b6d2d76669372c444aa3">testing::internal::kStackTraceMarker</a></div><div class="ttdeci">GTEST_API_ const char kStackTraceMarker[]</div></div>
- <div class="ttc" id="namespacetesting_html_a8e954ed3f0f6ca2e90b043e419c74123"><div class="ttname"><a href="namespacetesting.html#a8e954ed3f0f6ca2e90b043e419c74123">testing::GTEST_DEFINE_string_</a></div><div class="ttdeci">GTEST_DEFINE_string_(death_test_style, internal::StringFromGTestEnv("death_test_style", kDefaultDeathTestStyle), "Indicates how to run a death test in a forked child process: " "\hreadsafe\(child process re-executes the test binary " "from the beginning, running only the specific death test) or " "\ast\(child process runs the death test immediately " "after forking).")</div></div>
- <div class="ttc" id="classtesting_1_1internal_1_1_g_test_log_html_aebb92e67d98eca69f0347d5121dab27a"><div class="ttname"><a href="classtesting_1_1internal_1_1_g_test_log.html#aebb92e67d98eca69f0347d5121dab27a">testing::internal::GTestLog::GetStream</a></div><div class="ttdeci">::std::ostream & GetStream()</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l01236">gtest.h:1236</a></div></div>
- <div class="ttc" id="classtesting_1_1internal_1_1_captured_stream_html_af215c7a9326cb5ca61e6b7ca8231dcf1"><div class="ttname"><a href="classtesting_1_1internal_1_1_captured_stream.html#af215c7a9326cb5ca61e6b7ca8231dcf1">testing::internal::CapturedStream::~CapturedStream</a></div><div class="ttdeci">~CapturedStream()</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l10725">gtest-all.cc:10725</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a20bfd9d47d8dd167ffc1c37a4c9ff73e"><div class="ttname"><a href="namespacetesting_1_1internal.html#a20bfd9d47d8dd167ffc1c37a4c9ff73e">testing::internal::GTEST_DEFINE_string_</a></div><div class="ttdeci">GTEST_DEFINE_string_(internal_run_death_test, "", "Indicates the file, line number, temporal index of " "the single death test to run, and a file descriptor to " "which a success code may be sent, all separated by " "the '|' characters. This flag is specified if and only if the current " "process is a sub-process launched for running a thread-safe " "death test. FOR INTERNAL USE ONLY.")</div></div>
- <div class="ttc" id="gtest-all_8cc_html_a4a5b6fbde5dd05e05dd6846ac5e5c18e"><div class="ttname"><a href="gtest-all_8cc.html#a4a5b6fbde5dd05e05dd6846ac5e5c18e">GTEST_IMPL_CMP_HELPER_</a></div><div class="ttdeci">#define GTEST_IMPL_CMP_HELPER_(op_name, op)</div></div>
- <div class="ttc" id="gtest_8h_html_a828f4e34a1c4b510da50ec1563e3562a"><div class="ttname"><a href="gtest_8h.html#a828f4e34a1c4b510da50ec1563e3562a">GTEST_FLAG</a></div><div class="ttdeci">#define GTEST_FLAG(name)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02485">gtest.h:2485</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a5f74b933606b0a742cd5a8ad2d7087e0"><div class="ttname"><a href="namespacetesting_1_1internal.html#a5f74b933606b0a742cd5a8ad2d7087e0">testing::internal::CmpHelperSTRCASENE</a></div><div class="ttdeci">GTEST_API_ AssertionResult CmpHelperSTRCASENE(const char *s1_expression, const char *s2_expression, const char *s1, const char *s2)</div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a648c1bc94c2ef9e868ff3f9dff0f9c4ea2cca441161aca75a208ff08d07f5b1a5"><div class="ttname"><a href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea2cca441161aca75a208ff08d07f5b1a5">testing::internal::COLOR_YELLOW</a></div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l16427">gtest.h:16427</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a8257a87aa42cebaa54b0c48a6ae657a5"><div class="ttname"><a href="namespacetesting_1_1internal.html#a8257a87aa42cebaa54b0c48a6ae657a5">testing::internal::TearDownTestSuiteFunc</a></div><div class="ttdeci">void(*)() TearDownTestSuiteFunc</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l06927">gtest.h:6927</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_1_1posix_html_a8eb9f08d3af29941c2d2a964cfff3ecb"><div class="ttname"><a href="namespacetesting_1_1internal_1_1posix.html#a8eb9f08d3af29941c2d2a964cfff3ecb">testing::internal::posix::StatStruct</a></div><div class="ttdeci">struct stat StatStruct</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02320">gtest.h:2320</a></div></div>
- <div class="ttc" id="namespacetesting_html_aee3f6f99df893f576f705f66c0559482"><div class="ttname"><a href="namespacetesting.html#aee3f6f99df893f576f705f66c0559482">testing::InitGoogleTest</a></div><div class="ttdeci">GTEST_API_ void InitGoogleTest(int *argc, char **argv)</div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_ae2ef98247c76a50cdc80ceb4a6c81793"><div class="ttname"><a href="namespacetesting_1_1internal.html#ae2ef98247c76a50cdc80ceb4a6c81793">testing::internal::CharFormat</a></div><div class="ttdeci">CharFormat</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l11126">gtest-all.cc:11126</a></div></div>
- <div class="ttc" id="classtesting_1_1internal_1_1_g_test_log_html_a978a099703bbaa0f380216e8d7ee03d3"><div class="ttname"><a href="classtesting_1_1internal_1_1_g_test_log.html#a978a099703bbaa0f380216e8d7ee03d3">testing::internal::GTestLog::~GTestLog</a></div><div class="ttdeci">~GTestLog()</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l10659">gtest-all.cc:10659</a></div></div>
- <div class="ttc" id="gtest-all_8cc_html_a87a475ab9e81de8b49525787665b9229"><div class="ttname"><a href="gtest-all_8cc.html#a87a475ab9e81de8b49525787665b9229">GTEST_REPEATER_METHOD_</a></div><div class="ttdeci">#define GTEST_REPEATER_METHOD_(Name, Type)</div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a06b1b20029fbd1dbeb59752f914fab84"><div class="ttname"><a href="namespacetesting_1_1internal.html#a06b1b20029fbd1dbeb59752f914fab84">testing::internal::LogToStderr</a></div><div class="ttdeci">void LogToStderr()</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l01250">gtest.h:1250</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a8d8ed3acadedd9c0db28d35a188973ea"><div class="ttname"><a href="namespacetesting_1_1internal.html#a8d8ed3acadedd9c0db28d35a188973ea">testing::internal::GetArgvs</a></div><div class="ttdeci">GTEST_API_ std::vector< std::string > GetArgvs()</div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a7ab4072540184e26119ad853f45059f7"><div class="ttname"><a href="namespacetesting_1_1internal.html#a7ab4072540184e26119ad853f45059f7">testing::internal::MakeAndRegisterTestInfo</a></div><div class="ttdeci">GTEST_API_ TestInfo * MakeAndRegisterTestInfo(const char *test_suite_name, const char *name, const char *type_param, const char *value_param, CodeLocation code_location, TypeId fixture_class_id, SetUpTestSuiteFunc set_up_tc, TearDownTestSuiteFunc tear_down_tc, TestFactoryBase *factory)</div></div>
- <div class="ttc" id="namespacetesting_1_1internal_1_1posix_html_a3c6ab13e581a56f1b02f3eb7536c97fd"><div class="ttname"><a href="namespacetesting_1_1internal_1_1posix.html#a3c6ab13e581a56f1b02f3eb7536c97fd">testing::internal::posix::Read</a></div><div class="ttdeci">int Read(int fd, void *buf, unsigned int count)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02360">gtest.h:2360</a></div></div>
- <div class="ttc" id="namespaceutl_html_aae56a019cdd2006c4f07d2e207289195"><div class="ttname"><a href="namespaceutl.html#aae56a019cdd2006c4f07d2e207289195">utl::Predicate</a></div><div class="ttdeci">_utlConcept Predicate</div><div class="ttdef"><b>Definition:</b> <a href="stl_8h_source.html#l00759">stl.h:759</a></div></div>
- <div class="ttc" id="gtest_8h_html_ab54343f0a36dc4cb0ce8a478dd7847b8"><div class="ttname"><a href="gtest_8h.html#ab54343f0a36dc4cb0ce8a478dd7847b8">GTEST_CHECK_</a></div><div class="ttdeci">#define GTEST_CHECK_(condition)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l01270">gtest.h:1270</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a4b24c851ab13569b1b15b3d259b60d2e"><div class="ttname"><a href="namespacetesting_1_1internal.html#a4b24c851ab13569b1b15b3d259b60d2e">testing::internal::AlwaysFalse</a></div><div class="ttdeci">bool AlwaysFalse()</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l07260">gtest.h:7260</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a08b187c6cc4e28400aadf9a32fccc8de"><div class="ttname"><a href="namespacetesting_1_1internal.html#a08b187c6cc4e28400aadf9a32fccc8de">testing::internal::MutexLock</a></div><div class="ttdeci">GTestMutexLock MutexLock</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02162">gtest.h:2162</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_aa6255ef3b023c5b4e1a2198d887fb977a651e9cd2a904e0c8210536271b875f75"><div class="ttname"><a href="namespacetesting_1_1internal.html#aa6255ef3b023c5b4e1a2198d887fb977a651e9cd2a904e0c8210536271b875f75">testing::internal::GTEST_ERROR</a></div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l01222">gtest.h:1222</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_ae2ef98247c76a50cdc80ceb4a6c81793ae1211108e9f35f891d9951da64794d03"><div class="ttname"><a href="namespacetesting_1_1internal.html#ae2ef98247c76a50cdc80ceb4a6c81793ae1211108e9f35f891d9951da64794d03">testing::internal::kSpecialEscape</a></div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l11129">gtest-all.cc:11129</a></div></div>
- <div class="ttc" id="gtest_8h_html_a7285708fa5d37d6d8ed5b5e59da08bae"><div class="ttname"><a href="gtest_8h.html#a7285708fa5d37d6d8ed5b5e59da08bae">EXPECT_PRED_FORMAT3</a></div><div class="ttdeci">#define EXPECT_PRED_FORMAT3(pred_format, v1, v2, v3)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l14846">gtest.h:14846</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_1_1posix_html_a1ef2385a7f8e4c706054da35967e76bd"><div class="ttname"><a href="namespacetesting_1_1internal_1_1posix.html#a1ef2385a7f8e4c706054da35967e76bd">testing::internal::posix::StrCaseCmp</a></div><div class="ttdeci">int StrCaseCmp(const char *s1, const char *s2)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02325">gtest.h:2325</a></div></div>
- <div class="ttc" id="classtesting_1_1internal_1_1_captured_stream_html_a4b05e68491831448c5c575a25146e53d"><div class="ttname"><a href="classtesting_1_1internal_1_1_captured_stream.html#a4b05e68491831448c5c575a25146e53d">testing::internal::CapturedStream::CapturedStream</a></div><div class="ttdeci">CapturedStream(int fd)</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l10677">gtest-all.cc:10677</a></div></div>
- <div class="ttc" id="classtesting_1_1internal_1_1_random_html_a36d72dd7063d0b5338f229e75382fdd2"><div class="ttname"><a href="classtesting_1_1internal_1_1_random.html#a36d72dd7063d0b5338f229e75382fdd2">testing::internal::Random::kMaxRange</a></div><div class="ttdeci">static const UInt32 kMaxRange</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l07278">gtest.h:7278</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a05c6bd9ede5ccdf25191a590d610dcc6"><div class="ttname"><a href="namespacetesting_1_1internal.html#a05c6bd9ede5ccdf25191a590d610dcc6">testing::internal::BiggestInt</a></div><div class="ttdeci">long long BiggestInt</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02223">gtest.h:2223</a></div></div>
- <div class="ttc" id="classtesting_1_1internal_1_1_r_e_html"><div class="ttname"><a href="classtesting_1_1internal_1_1_r_e.html">testing::internal::RE</a></div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l01136">gtest.h:1136</a></div></div>
- <div class="ttc" id="gtest_8h_html_a13d98c217176bd8722c395b9225fc19d"><div class="ttname"><a href="gtest_8h.html#a13d98c217176bd8722c395b9225fc19d">GTEST_NAME_</a></div><div class="ttdeci">#define GTEST_NAME_</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l00517">gtest.h:517</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_1_1posix_html_af0d04ed5baeed28353fa38742748a421"><div class="ttname"><a href="namespacetesting_1_1internal_1_1posix.html#af0d04ed5baeed28353fa38742748a421">testing::internal::posix::IsDir</a></div><div class="ttdeci">bool IsDir(const StatStruct &st)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02330">gtest.h:2330</a></div></div>
- <div class="ttc" id="classtesting_1_1internal_1_1_captured_stream_html"><div class="ttname"><a href="classtesting_1_1internal_1_1_captured_stream.html">testing::internal::CapturedStream</a></div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l10674">gtest-all.cc:10674</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a744a6dd74c12d1e2c16b3c03e14ed4d4"><div class="ttname"><a href="namespacetesting_1_1internal.html#a744a6dd74c12d1e2c16b3c03e14ed4d4">testing::internal::IsPrintableAscii</a></div><div class="ttdeci">bool IsPrintableAscii(wchar_t c)</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l11135">gtest-all.cc:11135</a></div></div>
- <div class="ttc" id="gtest_8h_html_aed8c1888c32b588b0681e88b95031e29"><div class="ttname"><a href="gtest_8h.html#aed8c1888c32b588b0681e88b95031e29">GTEST_DISALLOW_COPY_AND_ASSIGN_</a></div><div class="ttdeci">#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l00927">gtest.h:927</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_1_1edit__distance_html_ad46aa6da12aec1a3f166310478b53a08afdbf30ecf9f32f60c646a34a358615f2"><div class="ttname"><a href="namespacetesting_1_1internal_1_1edit__distance.html#ad46aa6da12aec1a3f166310478b53a08afdbf30ecf9f32f60c646a34a358615f2">testing::internal::edit_distance::kReplace</a></div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l06605">gtest.h:6605</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a648c1bc94c2ef9e868ff3f9dff0f9c4ea3b1e81f5b14a17b35a8672d57d166507"><div class="ttname"><a href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea3b1e81f5b14a17b35a8672d57d166507">testing::internal::COLOR_GREEN</a></div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l16427">gtest.h:16427</a></div></div>
- <div class="ttc" id="gtest_8h_html_a4018b7f288f974d022df397e2730633a"><div class="ttname"><a href="gtest_8h.html#a4018b7f288f974d022df397e2730633a">GTEST_FLAG_PREFIX_UPPER_</a></div><div class="ttdeci">#define GTEST_FLAG_PREFIX_UPPER_</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l00516">gtest.h:516</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_aa7e70a85d66f0c109e3e69629ef577f2"><div class="ttname"><a href="namespacetesting_1_1internal.html#aa7e70a85d66f0c109e3e69629ef577f2">testing::internal::PrintTo</a></div><div class="ttdeci">void PrintTo(unsigned char c, ::std::ostream *os)</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l11242">gtest-all.cc:11242</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_1_1posix_html_a3117b067e1f942a2031e666953120ccc"><div class="ttname"><a href="namespacetesting_1_1internal_1_1posix.html#a3117b067e1f942a2031e666953120ccc">testing::internal::posix::FileNo</a></div><div class="ttdeci">int FileNo(FILE *file)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02322">gtest.h:2322</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_aed8d3ad4341f8f2de53440e39c995632"><div class="ttname"><a href="namespacetesting_1_1internal.html#aed8d3ad4341f8f2de53440e39c995632">testing::internal::GetBoolAssertionFailureMessage</a></div><div class="ttdeci">GTEST_API_ std::string GetBoolAssertionFailureMessage(const AssertionResult &assertion_result, const char *expression_text, const char *actual_predicate_value, const char *expected_predicate_value)</div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a1ee4cde97868c53e442d3182496a9f3c"><div class="ttname"><a href="namespacetesting_1_1internal.html#a1ee4cde97868c53e442d3182496a9f3c">testing::internal::FormatCompilerIndependentFileLocation</a></div><div class="ttdeci">GTEST_API_ ::std::string FormatCompilerIndependentFileLocation(const char *file, int line)</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l10638">gtest-all.cc:10638</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_aa6255ef3b023c5b4e1a2198d887fb977aff315e0913fcda86fe4de882bf5e33e9"><div class="ttname"><a href="namespacetesting_1_1internal.html#aa6255ef3b023c5b4e1a2198d887fb977aff315e0913fcda86fe4de882bf5e33e9">testing::internal::GTEST_INFO</a></div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l01220">gtest.h:1220</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_1_1posix_html_a4042201dcc4932641d484e7ddf94de7d"><div class="ttname"><a href="namespacetesting_1_1internal_1_1posix.html#a4042201dcc4932641d484e7ddf94de7d">testing::internal::posix::FOpen</a></div><div class="ttdeci">FILE * FOpen(const char *path, const char *mode)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02349">gtest.h:2349</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_1_1posix_html_a15e5b8f2a535ef1b2529b85b861e4846"><div class="ttname"><a href="namespacetesting_1_1internal_1_1posix.html#a15e5b8f2a535ef1b2529b85b861e4846">testing::internal::posix::Close</a></div><div class="ttdeci">int Close(int fd)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02366">gtest.h:2366</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_abae7a5775c901f2fd12b058b00d09840"><div class="ttname"><a href="namespacetesting_1_1internal.html#abae7a5775c901f2fd12b058b00d09840">testing::internal::kUnknownFile</a></div><div class="ttdeci">const char kUnknownFile[]</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l10616">gtest-all.cc:10616</a></div></div>
- <div class="ttc" id="gtest_8h_html_a088e84784c589ba9b1fc48602ad8eabf"><div class="ttname"><a href="gtest_8h.html#a088e84784c589ba9b1fc48602ad8eabf">GTEST_FLAG_PREFIX_</a></div><div class="ttdeci">#define GTEST_FLAG_PREFIX_</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l00514">gtest.h:514</a></div></div>
- <div class="ttc" id="namespacetesting_html_a428e5944490e497df683cb8324ce4489"><div class="ttname"><a href="namespacetesting.html#a428e5944490e497df683cb8324ce4489">testing::GTEST_DEFINE_bool_</a></div><div class="ttdeci">GTEST_DEFINE_bool_(death_test_use_fork, internal::BoolFromGTestEnv("death_test_use_fork", false), "Instructs to use fork()/_exit() instead of clone() in death tests. " "Ignored and always uses fork() on POSIX systems where clone() is not " "implemented. Useful when running under valgrind or similar tools if " "those do not support clone(). Valgrind 3.3.1 will just fail if " "it sees an unsupported combination of clone() flags. " "It is not recommended to use this flag w/o valgrind though it will " "work in 99% of the cases. Once valgrind is fixed, this flag will " "most likely be removed.")</div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a070107e7a8205ad6ec4d538d52b15b38"><div class="ttname"><a href="namespacetesting_1_1internal.html#a070107e7a8205ad6ec4d538d52b15b38">testing::internal::UniversalPrintArray</a></div><div class="ttdeci">void UniversalPrintArray(const char *begin, size_t len, ostream *os)</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l11316">gtest-all.cc:11316</a></div></div>
- <div class="ttc" id="classtesting_1_1_unit_test_html_af35839566385e14f6b31232489112621"><div class="ttname"><a href="classtesting_1_1_unit_test.html#af35839566385e14f6b31232489112621">testing::UnitTest::original_working_dir</a></div><div class="ttdeci">const char * original_working_dir() const</div></div>
- <div class="ttc" id="namespaceutl_1_1meta_html_aacf124929c0cbb3b29d34679bff50a96"><div class="ttname"><a href="namespaceutl_1_1meta.html#aacf124929c0cbb3b29d34679bff50a96">utl::meta::find_if</a></div><div class="ttdeci">eval< find_if_impl::find_if_< List, Pred, 0 > > find_if</div><div class="ttdef"><b>Definition:</b> <a href="typelist_8h_source.html#l00657">typelist.h:657</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a648c1bc94c2ef9e868ff3f9dff0f9c4ea9ebb3ddab9391781f6ee5021e1e443c3"><div class="ttname"><a href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4ea9ebb3ddab9391781f6ee5021e1e443c3">testing::internal::COLOR_RED</a></div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l16427">gtest.h:16427</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a5d3e97443d23bf1824f87feb172efd39"><div class="ttname"><a href="namespacetesting_1_1internal.html#a5d3e97443d23bf1824f87feb172efd39">testing::internal::ReportInvalidTestSuiteType</a></div><div class="ttdeci">GTEST_API_ void ReportInvalidTestSuiteType(const char *test_suite_name, CodeLocation code_location)</div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_af69e146a989e8d48def39a0cc59461c9"><div class="ttname"><a href="namespacetesting_1_1internal.html#af69e146a989e8d48def39a0cc59461c9">testing::internal::AppendUserMessage</a></div><div class="ttdeci">GTEST_API_ std::string AppendUserMessage(const std::string &gtest_msg, const Message &user_msg)</div></div>
- <div class="ttc" id="classtesting_1_1internal_1_1_random_html_a9315b7fb621cbcfdf92ed4b5e584c0db"><div class="ttname"><a href="classtesting_1_1internal_1_1_random.html#a9315b7fb621cbcfdf92ed4b5e584c0db">testing::internal::Random::Generate</a></div><div class="ttdeci">UInt32 Generate(UInt32 range)</div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a93eb9d61cac7faf1faff6301ae5f4a46"><div class="ttname"><a href="namespacetesting_1_1internal.html#a93eb9d61cac7faf1faff6301ae5f4a46">testing::internal::CmpHelperSTREQ</a></div><div class="ttdeci">GTEST_API_ AssertionResult CmpHelperSTREQ(const char *s1_expression, const char *s2_expression, const char *s1, const char *s2)</div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_ac1b876a8133895bd553d4780ecaa1e3a"><div class="ttname"><a href="namespacetesting_1_1internal.html#ac1b876a8133895bd553d4780ecaa1e3a">testing::internal::ToUpper</a></div><div class="ttdeci">char ToUpper(char ch)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02262">gtest.h:2262</a></div></div>
- <div class="ttc" id="namespacetesting_html_a69106491c2e7f50e50da0ce5e8ae4374"><div class="ttname"><a href="namespacetesting.html#a69106491c2e7f50e50da0ce5e8ae4374">testing::FloatLE</a></div><div class="ttdeci">GTEST_API_ AssertionResult FloatLE(const char *expr1, const char *expr2, float val1, float val2)</div></div>
- <div class="ttc" id="classtesting_1_1internal_1_1_assert_helper_html_ac2c9334518fd4087189b4505567a3c90"><div class="ttname"><a href="classtesting_1_1internal_1_1_assert_helper.html#ac2c9334518fd4087189b4505567a3c90">testing::internal::AssertHelper::AssertHelper</a></div><div class="ttdeci">AssertHelper(TestPartResult::Type type, const char *file, int line, const char *message)</div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a8ec00d458d0d442bd64af7b5f9c22dda"><div class="ttname"><a href="namespacetesting_1_1internal.html#a8ec00d458d0d442bd64af7b5f9c22dda">testing::internal::CaptureStderr</a></div><div class="ttdeci">void CaptureStderr()</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l10784">gtest-all.cc:10784</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_1_1posix_html_a69b8278c59359dd6a6f941b4643db9fb"><div class="ttname"><a href="namespacetesting_1_1internal_1_1posix.html#a69b8278c59359dd6a6f941b4643db9fb">testing::internal::posix::Abort</a></div><div class="ttdeci">void Abort()</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02392">gtest.h:2392</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a648c1bc94c2ef9e868ff3f9dff0f9c4eafcd8803dc9e37e374d5a4486afc230b7"><div class="ttname"><a href="namespacetesting_1_1internal.html#a648c1bc94c2ef9e868ff3f9dff0f9c4eafcd8803dc9e37e374d5a4486afc230b7">testing::internal::COLOR_DEFAULT</a></div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l16427">gtest.h:16427</a></div></div>
- <div class="ttc" id="gtest_8h_html_acdd47601a9376161c349a5881ccc6918"><div class="ttname"><a href="gtest_8h.html#acdd47601a9376161c349a5881ccc6918">GTEST_ATTRIBUTE_UNUSED_</a></div><div class="ttdeci">#define GTEST_ATTRIBUTE_UNUSED_</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l00899">gtest.h:899</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a2135f223bf6b527729aeaa651115183b"><div class="ttname"><a href="namespacetesting_1_1internal.html#a2135f223bf6b527729aeaa651115183b">testing::internal::FlushInfoLog</a></div><div class="ttdeci">void FlushInfoLog()</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l01251">gtest.h:1251</a></div></div>
- <div class="ttc" id="gtest_8h_html_a69abff5a4efdd07bd5faebe3dd318d06"><div class="ttname"><a href="gtest_8h.html#a69abff5a4efdd07bd5faebe3dd318d06">GTEST_LOCK_EXCLUDED_</a></div><div class="ttdeci">#define GTEST_LOCK_EXCLUDED_(locks)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02515">gtest.h:2515</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a747eccfdbdee3ff8af3bedc476a57c85"><div class="ttname"><a href="namespacetesting_1_1internal.html#a747eccfdbdee3ff8af3bedc476a57c85">testing::internal::kStdErrFileno</a></div><div class="ttdeci">const int kStdErrFileno</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l09776">gtest-all.cc:9776</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_ac46308aa3c0294ae446a40115aeb32c6"><div class="ttname"><a href="namespacetesting_1_1internal.html#ac46308aa3c0294ae446a40115aeb32c6">testing::internal::PrintWideStringTo</a></div><div class="ttdeci">void PrintWideStringTo(const ::std::wstring &s, ostream *os)</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l11448">gtest-all.cc:11448</a></div></div>
- <div class="ttc" id="classtesting_1_1internal_1_1_captured_stream_html_a48f400f12afb642387f91a5c20f7a528"><div class="ttname"><a href="classtesting_1_1internal_1_1_captured_stream.html#a48f400f12afb642387f91a5c20f7a528">testing::internal::CapturedStream::GetCapturedString</a></div><div class="ttdeci">std::string GetCapturedString()</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l10729">gtest-all.cc:10729</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a24f0a3d50cac54a9132f4828ec9b96d9"><div class="ttname"><a href="namespacetesting_1_1internal.html#a24f0a3d50cac54a9132f4828ec9b96d9">testing::internal::kStdOutFileno</a></div><div class="ttdeci">const int kStdOutFileno</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l09775">gtest-all.cc:9775</a></div></div>
- <div class="ttc" id="gtest_8h_html_ac33e7cdfb5d44a7a0f0ab552eb5c3c6a"><div class="ttname"><a href="gtest_8h.html#ac33e7cdfb5d44a7a0f0ab552eb5c3c6a">EXPECT_TRUE</a></div><div class="ttdeci">#define EXPECT_TRUE(condition)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l16584">gtest.h:16584</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_ae2ef98247c76a50cdc80ceb4a6c81793af7038866be92e9978360b831e376ffaa"><div class="ttname"><a href="namespacetesting_1_1internal.html#ae2ef98247c76a50cdc80ceb4a6c81793af7038866be92e9978360b831e376ffaa">testing::internal::kAsIs</a></div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l11127">gtest-all.cc:11127</a></div></div>
- <div class="ttc" id="gtest_8h_html_adc16b5b0a740c39084ea5c9e960e3063"><div class="ttname"><a href="gtest_8h.html#adc16b5b0a740c39084ea5c9e960e3063">ADD_FAILURE</a></div><div class="ttdeci">#define ADD_FAILURE()</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l16533">gtest.h:16533</a></div></div>
- <div class="ttc" id="gtest_8h_html_af18b465f4ba6e36eea7a8d2d79521873"><div class="ttname"><a href="gtest_8h.html#af18b465f4ba6e36eea7a8d2d79521873">GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_</a></div><div class="ttdeci">#define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l01043">gtest.h:1043</a></div></div>
- <div class="ttc" id="gtest_8h_html_a3749ef4fba6b3c3993609b336031644d"><div class="ttname"><a href="gtest_8h.html#a3749ef4fba6b3c3993609b336031644d">GTEST_FLAG_SAVER_</a></div><div class="ttdeci">#define GTEST_FLAG_SAVER_</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02493">gtest.h:2493</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_1_1edit__distance_html_a48cffebc6d3169ad1df7849b5f7fb5ff"><div class="ttname"><a href="namespacetesting_1_1internal_1_1edit__distance.html#a48cffebc6d3169ad1df7849b5f7fb5ff">testing::internal::edit_distance::CreateUnifiedDiff</a></div><div class="ttdeci">GTEST_API_ std::string CreateUnifiedDiff(const std::vector< std::string > &left, const std::vector< std::string > &right, size_t context=2)</div></div>
- <div class="ttc" id="namespaceutl_html_ae0f873b4883af7cc18cb23dd2810f4e6"><div class="ttname"><a href="namespaceutl.html#ae0f873b4883af7cc18cb23dd2810f4e6">utl::swap</a></div><div class="ttdeci">void swap(array< _Tp, _Nm > &lhs, array< _Tp, _Nm > &rhs) noexcept(noexcept(lhs.swap(rhs)))</div><div class="ttdef"><b>Definition:</b> <a href="array_8h_source.html#l00214">array.h:214</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_1_1posix_html_af7c268eba32d5a718b36b6b3801302e0"><div class="ttname"><a href="namespacetesting_1_1internal_1_1posix.html#af7c268eba32d5a718b36b6b3801302e0">testing::internal::posix::FDOpen</a></div><div class="ttdeci">FILE * FDOpen(int fd, const char *mode)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02356">gtest.h:2356</a></div></div>
- <div class="ttc" id="classtesting_1_1_unit_test_html_af254e2e695471eb9f128bc556bae3668"><div class="ttname"><a href="classtesting_1_1_unit_test.html#af254e2e695471eb9f128bc556bae3668">testing::UnitTest::GetInstance</a></div><div class="ttdeci">static UnitTest * GetInstance()</div></div>
- <div class="ttc" id="gtest_8h_html_abf30a6b1b3a12ecb2cc1bc1a6f5f9646"><div class="ttname"><a href="gtest_8h.html#abf30a6b1b3a12ecb2cc1bc1a6f5f9646">GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_</a></div><div class="ttdeci">#define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l01055">gtest.h:1055</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_1_1posix_html_a8e352884793a65ae8be144676f1a9136"><div class="ttname"><a href="namespacetesting_1_1internal_1_1posix.html#a8e352884793a65ae8be144676f1a9136">testing::internal::posix::StrDup</a></div><div class="ttdeci">char * StrDup(const char *src)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02328">gtest.h:2328</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_1_1posix_html_a4b77b14af6f4d18f83d303b98e9349c4"><div class="ttname"><a href="namespacetesting_1_1internal_1_1posix.html#a4b77b14af6f4d18f83d303b98e9349c4">testing::internal::posix::StrError</a></div><div class="ttdeci">const char * StrError(int errnum)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02367">gtest.h:2367</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a0c793c6d84760d900299916c077a1af4"><div class="ttname"><a href="namespacetesting_1_1internal.html#a0c793c6d84760d900299916c077a1af4">testing::internal::OutputFlagAlsoCheckEnvVar</a></div><div class="ttdeci">std::string OutputFlagAlsoCheckEnvVar()</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l10980">gtest-all.cc:10980</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_a1e85cf16bb95b60f879d48ba1fbfc1c9"><div class="ttname"><a href="namespacetesting_1_1internal.html#a1e85cf16bb95b60f879d48ba1fbfc1c9">testing::internal::GetTestTypeId</a></div><div class="ttdeci">GTEST_API_ TypeId GetTestTypeId()</div></div>
- <div class="ttc" id="gtest_8h_html_a5aa3c938fc1d049f1d9c5332f6a0b1d4"><div class="ttname"><a href="gtest_8h.html#a5aa3c938fc1d049f1d9c5332f6a0b1d4">GTEST_PROJECT_URL_</a></div><div class="ttdeci">#define GTEST_PROJECT_URL_</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l00518">gtest.h:518</a></div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_aa6afda12e567c353e2e9b9c2e8cae14f"><div class="ttname"><a href="namespacetesting_1_1internal.html#aa6afda12e567c353e2e9b9c2e8cae14f">testing::internal::StripTrailingSpaces</a></div><div class="ttdeci">std::string StripTrailingSpaces(std::string str)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02266">gtest.h:2266</a></div></div>
- <div class="ttc" id="classtesting_1_1_message_html"><div class="ttname"><a href="classtesting_1_1_message.html">testing::Message</a></div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l02644">gtest.h:2644</a></div></div>
- <div class="ttc" id="namespaceutl_1_1meta_html_a58c1744750d0df133034f60a95f87e19"><div class="ttname"><a href="namespaceutl_1_1meta.html#a58c1744750d0df133034f60a95f87e19">utl::meta::empty</a></div><div class="ttdeci">bool_< List::empty()> empty</div><div class="ttdef"><b>Definition:</b> <a href="typelist_8h_source.html#l00140">typelist.h:140</a></div></div>
- <div class="ttc" id="classtesting_1_1_message_html_a2cdc4df62bdcc9df37651a1cf527704e"><div class="ttname"><a href="classtesting_1_1_message.html#a2cdc4df62bdcc9df37651a1cf527704e">testing::Message::GetString</a></div><div class="ttdeci">std::string GetString() const</div></div>
- <div class="ttc" id="namespacetesting_1_1internal_html_afcd71adaa9d1e6df7b282a17fc48125c"><div class="ttname"><a href="namespacetesting_1_1internal.html#afcd71adaa9d1e6df7b282a17fc48125c">testing::internal::kPathSeparator</a></div><div class="ttdeci">const char kPathSeparator</div><div class="ttdef"><b>Definition:</b> <a href="gtest-all_8cc_source.html#l09246">gtest-all.cc:9246</a></div></div>
- <div class="ttc" id="namespaceutl_html_a29057d2e164fe6dd3f3095f0d69c6546"><div class="ttname"><a href="namespaceutl.html#a29057d2e164fe6dd3f3095f0d69c6546">utl::get</a></div><div class="ttdeci">constexpr _Tp & get(array< _Tp, _Nm > &arr) noexcept</div><div class="ttdef"><b>Definition:</b> <a href="array_8h_source.html#l00220">array.h:220</a></div></div>
- </div><!-- fragment --></div><!-- contents -->
- </div><!-- doc-content -->
- <!-- start footer part -->
- <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
- <ul>
- <li class="navelem"><a class="el" href="dir_13e138d54eb8818da29c3992edef070a.html">test</a></li><li class="navelem"><a class="el" href="dir_aaec33bad2bb7a5d6c86281ead709be5.html">eclipse-cygwin</a></li><li class="navelem"><a class="el" href="dir_c2811dd2f770757e67563302be4130d6.html">lib</a></li><li class="navelem"><a class="el" href="dir_a96de09a69cea6234edc1a1514d133f0.html">gtest</a></li><li class="navelem"><a class="el" href="gtest-all_8cc.html">gtest-all.cc</a></li>
- <li class="footer">Generated by
- <a href="http://www.doxygen.org/index.html">
- <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.14 </li>
- </ul>
- </div>
- </body>
- </html>
|