Files
rippled/base64__test_8cpp_source.html
2020-04-24 01:09:47 +00:00

173 lines
21 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://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.17"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>rippled: base64_test.cpp 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="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">rippled
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;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&amp;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>
<!-- 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 id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_120ed4da3e3217b1e7fc0b4f48568e79.html">test</a></li><li class="navelem"><a class="el" href="dir_354330c8aa73f5a2ebe2c490e5cf38ef.html">basics</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">base64_test.cpp</div> </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span>&#160;<span class="comment">//------------------------------------------------------------------------------</span></div>
<div class="line"><a name="l00002"></a><span class="lineno"> 2</span>&#160;<span class="comment">/*</span></div>
<div class="line"><a name="l00003"></a><span class="lineno"> 3</span>&#160;<span class="comment"> This file is part of rippled: https://github.com/ripple/rippled</span></div>
<div class="line"><a name="l00004"></a><span class="lineno"> 4</span>&#160;<span class="comment"> Copyright (c) 2012-2018 Ripple Labs Inc.</span></div>
<div class="line"><a name="l00005"></a><span class="lineno"> 5</span>&#160;<span class="comment"></span> </div>
<div class="line"><a name="l00006"></a><span class="lineno"> 6</span>&#160;<span class="comment"> Permission to use, copy, modify, and/or distribute this software for any</span></div>
<div class="line"><a name="l00007"></a><span class="lineno"> 7</span>&#160;<span class="comment"> purpose with or without fee is hereby granted, provided that the above</span></div>
<div class="line"><a name="l00008"></a><span class="lineno"> 8</span>&#160;<span class="comment"> copyright notice and this permission notice appear in all copies.</span></div>
<div class="line"><a name="l00009"></a><span class="lineno"> 9</span>&#160;<span class="comment"></span> </div>
<div class="line"><a name="l00010"></a><span class="lineno"> 10</span>&#160;<span class="comment"> THE SOFTWARE IS PROVIDED &quot;AS IS&quot; AND THE AUTHOR DISCLAIMS ALL WARRANTIES</span></div>
<div class="line"><a name="l00011"></a><span class="lineno"> 11</span>&#160;<span class="comment"> WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF</span></div>
<div class="line"><a name="l00012"></a><span class="lineno"> 12</span>&#160;<span class="comment"> MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR</span></div>
<div class="line"><a name="l00013"></a><span class="lineno"> 13</span>&#160;<span class="comment"> ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES</span></div>
<div class="line"><a name="l00014"></a><span class="lineno"> 14</span>&#160;<span class="comment"> WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN</span></div>
<div class="line"><a name="l00015"></a><span class="lineno"> 15</span>&#160;<span class="comment"> ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF</span></div>
<div class="line"><a name="l00016"></a><span class="lineno"> 16</span>&#160;<span class="comment"> OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.</span></div>
<div class="line"><a name="l00017"></a><span class="lineno"> 17</span>&#160;<span class="comment">*/</span></div>
<div class="line"><a name="l00018"></a><span class="lineno"> 18</span>&#160;<span class="comment">//==============================================================================</span></div>
<div class="line"><a name="l00019"></a><span class="lineno"> 19</span>&#160; </div>
<div class="line"><a name="l00020"></a><span class="lineno"> 20</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00021"></a><span class="lineno"> 21</span>&#160;<span class="comment">// Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)</span></div>
<div class="line"><a name="l00022"></a><span class="lineno"> 22</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00023"></a><span class="lineno"> 23</span>&#160;<span class="comment">// Distributed under the Boost Software License, Version 1.0. (See accompanying</span></div>
<div class="line"><a name="l00024"></a><span class="lineno"> 24</span>&#160;<span class="comment">// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"><a name="l00025"></a><span class="lineno"> 25</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00026"></a><span class="lineno"> 26</span>&#160;<span class="comment">// Official repository: https://github.com/boostorg/beast</span></div>
<div class="line"><a name="l00027"></a><span class="lineno"> 27</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00028"></a><span class="lineno"> 28</span>&#160; </div>
<div class="line"><a name="l00029"></a><span class="lineno"> 29</span>&#160;<span class="preprocessor">#include &lt;ripple/basics/base64.h&gt;</span></div>
<div class="line"><a name="l00030"></a><span class="lineno"> 30</span>&#160;<span class="preprocessor">#include &lt;ripple/beast/unit_test.h&gt;</span></div>
<div class="line"><a name="l00031"></a><span class="lineno"> 31</span>&#160; </div>
<div class="line"><a name="l00032"></a><span class="lineno"> 32</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespaceripple.html">ripple</a> {</div>
<div class="line"><a name="l00033"></a><span class="lineno"> 33</span>&#160; </div>
<div class="line"><a name="l00034"></a><span class="lineno"><a class="line" href="classripple_1_1base64__test.html"> 34</a></span>&#160;<span class="keyword">class </span><a class="code" href="classripple_1_1base64__test.html">base64_test</a> : <span class="keyword">public</span> beast::unit_test::suite</div>
<div class="line"><a name="l00035"></a><span class="lineno"> 35</span>&#160;{</div>
<div class="line"><a name="l00036"></a><span class="lineno"> 36</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00037"></a><span class="lineno"> 37</span>&#160; <span class="keywordtype">void</span></div>
<div class="line"><a name="l00038"></a><span class="lineno"><a class="line" href="classripple_1_1base64__test.html#a70f5a4786f2e9171f79628a9fcefc5ab"> 38</a></span>&#160; <a class="code" href="classripple_1_1base64__test.html#a70f5a4786f2e9171f79628a9fcefc5ab">check</a>(<a class="codeRef" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a> <span class="keyword">const</span>&amp; in, <a class="codeRef" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a> <span class="keyword">const</span>&amp; out)</div>
<div class="line"><a name="l00039"></a><span class="lineno"> 39</span>&#160; {</div>
<div class="line"><a name="l00040"></a><span class="lineno"> 40</span>&#160; <span class="keyword">auto</span> <span class="keyword">const</span> encoded = <a class="code" href="namespaceripple.html#a9e4e400df889dc7cb9df0f859a8e4f18">base64_encode</a>(<a class="code" href="namespaceripple.html#a7cc64e12723fbc9606d85442a2569feda13b5bfe96f3e2fe411c9f66f4a582adf">in</a>);</div>
<div class="line"><a name="l00041"></a><span class="lineno"> 41</span>&#160; BEAST_EXPECT(encoded == <a class="code" href="namespaceripple.html#a7cc64e12723fbc9606d85442a2569fedac68271a63ddbc431c307beb7d2918275">out</a>);</div>
<div class="line"><a name="l00042"></a><span class="lineno"> 42</span>&#160; BEAST_EXPECT(<a class="code" href="namespaceripple.html#a551be32de1cc0f8a8ff1f14ee84d892b">base64_decode</a>(encoded) == <a class="code" href="namespaceripple.html#a7cc64e12723fbc9606d85442a2569feda13b5bfe96f3e2fe411c9f66f4a582adf">in</a>);</div>
<div class="line"><a name="l00043"></a><span class="lineno"> 43</span>&#160; }</div>
<div class="line"><a name="l00044"></a><span class="lineno"> 44</span>&#160; </div>
<div class="line"><a name="l00045"></a><span class="lineno"> 45</span>&#160; <span class="keywordtype">void</span></div>
<div class="line"><a name="l00046"></a><span class="lineno"><a class="line" href="classripple_1_1base64__test.html#a3fa189c95f7931e4abebca3ebcc91c6a"> 46</a></span>&#160; <a class="code" href="classripple_1_1base64__test.html#a3fa189c95f7931e4abebca3ebcc91c6a">run</a>()<span class="keyword"> override</span></div>
<div class="line"><a name="l00047"></a><span class="lineno"> 47</span>&#160;<span class="keyword"> </span>{</div>
<div class="line"><a name="l00048"></a><span class="lineno"> 48</span>&#160; <a class="code" href="classripple_1_1base64__test.html#a70f5a4786f2e9171f79628a9fcefc5ab">check</a>(<span class="stringliteral">&quot;&quot;</span>, <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a name="l00049"></a><span class="lineno"> 49</span>&#160; <a class="code" href="classripple_1_1base64__test.html#a70f5a4786f2e9171f79628a9fcefc5ab">check</a>(<span class="stringliteral">&quot;f&quot;</span>, <span class="stringliteral">&quot;Zg==&quot;</span>);</div>
<div class="line"><a name="l00050"></a><span class="lineno"> 50</span>&#160; <a class="code" href="classripple_1_1base64__test.html#a70f5a4786f2e9171f79628a9fcefc5ab">check</a>(<span class="stringliteral">&quot;fo&quot;</span>, <span class="stringliteral">&quot;Zm8=&quot;</span>);</div>
<div class="line"><a name="l00051"></a><span class="lineno"> 51</span>&#160; <a class="code" href="classripple_1_1base64__test.html#a70f5a4786f2e9171f79628a9fcefc5ab">check</a>(<span class="stringliteral">&quot;foo&quot;</span>, <span class="stringliteral">&quot;Zm9v&quot;</span>);</div>
<div class="line"><a name="l00052"></a><span class="lineno"> 52</span>&#160; <a class="code" href="classripple_1_1base64__test.html#a70f5a4786f2e9171f79628a9fcefc5ab">check</a>(<span class="stringliteral">&quot;foob&quot;</span>, <span class="stringliteral">&quot;Zm9vYg==&quot;</span>);</div>
<div class="line"><a name="l00053"></a><span class="lineno"> 53</span>&#160; <a class="code" href="classripple_1_1base64__test.html#a70f5a4786f2e9171f79628a9fcefc5ab">check</a>(<span class="stringliteral">&quot;fooba&quot;</span>, <span class="stringliteral">&quot;Zm9vYmE=&quot;</span>);</div>
<div class="line"><a name="l00054"></a><span class="lineno"> 54</span>&#160; <a class="code" href="classripple_1_1base64__test.html#a70f5a4786f2e9171f79628a9fcefc5ab">check</a>(<span class="stringliteral">&quot;foobar&quot;</span>, <span class="stringliteral">&quot;Zm9vYmFy&quot;</span>);</div>
<div class="line"><a name="l00055"></a><span class="lineno"> 55</span>&#160; </div>
<div class="line"><a name="l00056"></a><span class="lineno"> 56</span>&#160; <a class="code" href="classripple_1_1base64__test.html#a70f5a4786f2e9171f79628a9fcefc5ab">check</a>(</div>
<div class="line"><a name="l00057"></a><span class="lineno"> 57</span>&#160; <span class="stringliteral">&quot;Man is distinguished, not only by his reason, but by this &quot;</span></div>
<div class="line"><a name="l00058"></a><span class="lineno"> 58</span>&#160; <span class="stringliteral">&quot;singular passion from &quot;</span></div>
<div class="line"><a name="l00059"></a><span class="lineno"> 59</span>&#160; <span class="stringliteral">&quot;other animals, which is a lust of the mind, that by a &quot;</span></div>
<div class="line"><a name="l00060"></a><span class="lineno"> 60</span>&#160; <span class="stringliteral">&quot;perseverance of delight &quot;</span></div>
<div class="line"><a name="l00061"></a><span class="lineno"> 61</span>&#160; <span class="stringliteral">&quot;in the continued and indefatigable generation of knowledge, &quot;</span></div>
<div class="line"><a name="l00062"></a><span class="lineno"> 62</span>&#160; <span class="stringliteral">&quot;exceeds the short &quot;</span></div>
<div class="line"><a name="l00063"></a><span class="lineno"> 63</span>&#160; <span class="stringliteral">&quot;vehemence of any carnal pleasure.&quot;</span>,</div>
<div class="line"><a name="l00064"></a><span class="lineno"> 64</span>&#160; <span class="stringliteral">&quot;TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dC&quot;</span></div>
<div class="line"><a name="l00065"></a><span class="lineno"> 65</span>&#160; <span class="stringliteral">&quot;BieSB0aGlz&quot;</span></div>
<div class="line"><a name="l00066"></a><span class="lineno"> 66</span>&#160; <span class="stringliteral">&quot;IHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIG&quot;</span></div>
<div class="line"><a name="l00067"></a><span class="lineno"> 67</span>&#160; <span class="stringliteral">&quot;x1c3Qgb2Yg&quot;</span></div>
<div class="line"><a name="l00068"></a><span class="lineno"> 68</span>&#160; <span class="stringliteral">&quot;dGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aG&quot;</span></div>
<div class="line"><a name="l00069"></a><span class="lineno"> 69</span>&#160; <span class="stringliteral">&quot;UgY29udGlu&quot;</span></div>
<div class="line"><a name="l00070"></a><span class="lineno"> 70</span>&#160; <span class="stringliteral">&quot;dWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleG&quot;</span></div>
<div class="line"><a name="l00071"></a><span class="lineno"> 71</span>&#160; <span class="stringliteral">&quot;NlZWRzIHRo&quot;</span></div>
<div class="line"><a name="l00072"></a><span class="lineno"> 72</span>&#160; <span class="stringliteral">&quot;ZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=&quot;</span>);</div>
<div class="line"><a name="l00073"></a><span class="lineno"> 73</span>&#160; </div>
<div class="line"><a name="l00074"></a><span class="lineno"> 74</span>&#160; <a class="codeRef" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a> <span class="keyword">const</span> notBase64 = <span class="stringliteral">&quot;not_base64!!&quot;</span>;</div>
<div class="line"><a name="l00075"></a><span class="lineno"> 75</span>&#160; <a class="codeRef" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a> <span class="keyword">const</span> truncated = <span class="stringliteral">&quot;not&quot;</span>;</div>
<div class="line"><a name="l00076"></a><span class="lineno"> 76</span>&#160; BEAST_EXPECT(<a class="code" href="namespaceripple.html#a551be32de1cc0f8a8ff1f14ee84d892b">base64_decode</a>(notBase64) == <a class="code" href="namespaceripple.html#a551be32de1cc0f8a8ff1f14ee84d892b">base64_decode</a>(truncated));</div>
<div class="line"><a name="l00077"></a><span class="lineno"> 77</span>&#160; }</div>
<div class="line"><a name="l00078"></a><span class="lineno"> 78</span>&#160;};</div>
<div class="line"><a name="l00079"></a><span class="lineno"> 79</span>&#160; </div>
<div class="line"><a name="l00080"></a><span class="lineno"> 80</span>&#160;<a class="code" href="namespaceripple.html#a2701412a11b118c19256a4c901db2938">BEAST_DEFINE_TESTSUITE</a>(base64, ripple_basics, <a class="code" href="namespaceripple.html">ripple</a>);</div>
<div class="line"><a name="l00081"></a><span class="lineno"> 81</span>&#160; </div>
<div class="line"><a name="l00082"></a><span class="lineno"> 82</span>&#160;} <span class="comment">// namespace ripple</span></div>
</div><!-- fragment --></div><!-- contents -->
<div class="ttc" id="abasic_string_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a></div><div class="ttdoc">STL class.</div></div>
<div class="ttc" id="anamespaceripple_html_a2701412a11b118c19256a4c901db2938"><div class="ttname"><a href="namespaceripple.html#a2701412a11b118c19256a4c901db2938">ripple::BEAST_DEFINE_TESTSUITE</a></div><div class="ttdeci">BEAST_DEFINE_TESTSUITE(AccountTxPaging, app, ripple)</div></div>
<div class="ttc" id="anamespaceripple_html_a9e4e400df889dc7cb9df0f859a8e4f18"><div class="ttname"><a href="namespaceripple.html#a9e4e400df889dc7cb9df0f859a8e4f18">ripple::base64_encode</a></div><div class="ttdeci">std::string base64_encode(std::uint8_t const *data, std::size_t len)</div><div class="ttdef"><b>Definition:</b> <a href="base64_8cpp_source.html#l00236">base64.cpp:236</a></div></div>
<div class="ttc" id="anamespaceripple_html_a7cc64e12723fbc9606d85442a2569feda13b5bfe96f3e2fe411c9f66f4a582adf"><div class="ttname"><a href="namespaceripple.html#a7cc64e12723fbc9606d85442a2569feda13b5bfe96f3e2fe411c9f66f4a582adf">ripple::QualityDirection::in</a></div><div class="ttdeci">@ in</div></div>
<div class="ttc" id="aclassripple_1_1base64__test_html_a3fa189c95f7931e4abebca3ebcc91c6a"><div class="ttname"><a href="classripple_1_1base64__test.html#a3fa189c95f7931e4abebca3ebcc91c6a">ripple::base64_test::run</a></div><div class="ttdeci">void run() override</div><div class="ttdef"><b>Definition:</b> <a href="base64__test_8cpp_source.html#l00046">base64_test.cpp:46</a></div></div>
<div class="ttc" id="anamespaceripple_html_a7cc64e12723fbc9606d85442a2569fedac68271a63ddbc431c307beb7d2918275"><div class="ttname"><a href="namespaceripple.html#a7cc64e12723fbc9606d85442a2569fedac68271a63ddbc431c307beb7d2918275">ripple::QualityDirection::out</a></div><div class="ttdeci">@ out</div></div>
<div class="ttc" id="anamespaceripple_html_a551be32de1cc0f8a8ff1f14ee84d892b"><div class="ttname"><a href="namespaceripple.html#a551be32de1cc0f8a8ff1f14ee84d892b">ripple::base64_decode</a></div><div class="ttdeci">std::string base64_decode(std::string const &amp;data)</div><div class="ttdef"><b>Definition:</b> <a href="base64_8cpp_source.html#l00245">base64.cpp:245</a></div></div>
<div class="ttc" id="aclassripple_1_1base64__test_html"><div class="ttname"><a href="classripple_1_1base64__test.html">ripple::base64_test</a></div><div class="ttdef"><b>Definition:</b> <a href="base64__test_8cpp_source.html#l00034">base64_test.cpp:34</a></div></div>
<div class="ttc" id="anamespaceripple_html"><div class="ttname"><a href="namespaceripple.html">ripple</a></div><div class="ttdoc">Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.</div><div class="ttdef"><b>Definition:</b> <a href="RCLCensorshipDetector_8h_source.html#l00029">RCLCensorshipDetector.h:29</a></div></div>
<div class="ttc" id="aclassripple_1_1base64__test_html_a70f5a4786f2e9171f79628a9fcefc5ab"><div class="ttname"><a href="classripple_1_1base64__test.html#a70f5a4786f2e9171f79628a9fcefc5ab">ripple::base64_test::check</a></div><div class="ttdeci">void check(std::string const &amp;in, std::string const &amp;out)</div><div class="ttdef"><b>Definition:</b> <a href="base64__test_8cpp_source.html#l00038">base64_test.cpp:38</a></div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.17
</small></address>
</body>
</html>