How to use Gt method of td Package

Best Go-testdeep code snippet using td.Gt

block.go

Source:block.go Github

copy

Full Screen

1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"2 "http://www.w3.org/TR/html4/transitional.dtd">3<html>4<head>5 <meta http-equiv="content-type" content="text/html; charset=utf-8">6 <title>Source file /src/pkg/crypto/aes/block.go</title>7 <link rel="stylesheet" type="text/css" href="../../../../doc/style.css">8 <script type="text/javascript" src="../../../../doc/godocs.js"></script>9</head>10<body>11 <script>12 // Catch 'enter' key down events and trigger the search form submission.13 function codesearchKeyDown(event) {14 if (event.which == 13) {15 var form = document.getElementById('codesearch');16 var query = document.getElementById('codesearchQuery');17 form.q.value = "lang:go package:go.googlecode.com " + query.value;18 document.getElementById('codesearch').submit();19} return true;20}21 // Capture the submission event and construct the query parameter.22 function codeSearchSubmit() {23 var query = document.getElementById('codesearchQuery');24 var form = document.getElementById('codesearch');25 form.q.value = "lang:go package:go.googlecode.com " + query.value;26 return true;27} </script>28<div id="topnav">29 <table summary="">30 <tr>31 <td id="headerImage">32 <a href="../../../../index.html"><img src="../../../../doc/logo-153x55.png" height="55" width="153" alt="Go Home Page" style="border:0" /></a>33 </td>34 <td>35 <div id="headerDocSetTitle">The Go Programming Language</div>36 </td>37 <td>38 <!-- <table>39 <tr>40 <td>41 <! The input box is outside of the form because we want to add42 a couple of restricts to the query before submitting. If we just43 add the restricts to the text box before submitting, then they44 appear in the box when the user presses 'back'. Thus we use a45 hidden field in the form. However, there's no way to stop the46 non-hidden text box from also submitting a value unless we move47 it outside of the form48 <input type="search" id="codesearchQuery" value="" size="30" onkeydown="return codesearchKeyDown(event);"/>49 <form method="GET" action="http://www.google.com/codesearch" id="codesearch" class="search" onsubmit="return codeSearchSubmit();" style="display:inline;">50 <input type="hidden" name="q" value=""/>51 <input type="submit" value="Code search" />52 <span style="color: red">(TODO: remove for now?)</span>53 </form>54 </td>55 </tr>56 <tr>57 <td>58 <span style="color: gray;">(e.g. &ldquo;pem&rdquo; or &ldquo;xml&rdquo;)</span>59 </td>60 </tr>61 </table> -->62 </td>63 </tr>64 </table>65</div>66<div id="linkList">67 <ul>68 <li class="navhead"><a href="../../../../index.html">Home</a></li>69 <li class="blank">&nbsp;</li>70 <li class="navhead">Documents</li>71 <li><a href="../../../../doc/go_tutorial.html">Tutorial</a></li>72 <li><a href="../../../../doc/effective_go.html">Effective Go</a></li>73 <li><a href="../../../../doc/go_faq.html">FAQ</a></li>74 <li><a href="../../../../doc/go_lang_faq.html">Language Design FAQ</a></li>75 <li><a href="http://www.youtube.com/watch?v=rKnDgT73v8s">Tech talk (1 hour)</a> (<a href="../../../../doc/go_talk-20091030.pdf">PDF</a>)</li>76 <li><a href="../../../../doc/go_spec.html">Language Specification</a></li>77 <li><a href="../../../../doc/go_mem.html">Memory Model</a></li>78 <li><a href="../../../../doc/go_for_cpp_programmers.html">Go for C++ Programmers</a></li>79 <li class="blank">&nbsp;</li>80 <li class="navhead">How To</li>81 <li><a href="../../../../doc/install.html">Install Go</a></li>82 <li><a href="../../../../doc/contribute.html">Contribute code</a></li>83 <li class="blank">&nbsp;</li>84 <li class="navhead">Programming</li>85 <li><a href="../../../../cmd/index.html">Command documentation</a></li>86 <li><a href="../../../../pkg/index.html">Package documentation</a></li>87 <li><a href="../../../index.html">Source files</a></li>88 <li class="blank">&nbsp;</li>89 <li class="navhead">Help</li>90 <li>#go-nuts on irc.freenode.net</li>91 <li><a href="http://groups.google.com/group/golang-nuts">Go Nuts mailing list</a></li>92 <li><a href="http://code.google.com/p/go/issues/list">Issue tracker</a></li>93 <li class="blank">&nbsp;</li>94 <li class="navhead">Go code search</li>95 <form method="GET" action="http://golang.org/search" class="search">96 <input type="search" name="q" value="" size="25" style="width:80%; max-width:200px" />97 <input type="submit" value="Go" />98 </form>99 <li class="blank">&nbsp;</li>100 <li class="navhead">Last update</li>101 <li>Thu Nov 12 16:01:31 PST 2009</li>102 </ul>103</div>104<div id="content">105 <h1 id="generatedHeader">Source file /src/pkg/crypto/aes/block.go</h1>106 <!-- The Table of Contents is automatically inserted in this <div>.107 Do not delete this <div>. -->108 <div id="nav"></div>109 <!-- Content is HTML-escaped elsewhere -->110 <pre>111<a id="L1"></a><span class="comment">// Copyright 2009 The Go Authors. All rights reserved.</span>112<a id="L2"></a><span class="comment">// Use of this source code is governed by a BSD-style</span>113<a id="L3"></a><span class="comment">// license that can be found in the LICENSE file.</span>114<a id="L5"></a><span class="comment">// This Go implementation is derived in part from the reference</span>115<a id="L6"></a><span class="comment">// ANSI C implementation, which carries the following notice:</span>116<a id="L7"></a><span class="comment">//</span>117<a id="L8"></a><span class="comment">// rijndael-alg-fst.c</span>118<a id="L9"></a><span class="comment">//</span>119<a id="L10"></a><span class="comment">// @version 3.0 (December 2000)</span>120<a id="L11"></a><span class="comment">//</span>121<a id="L12"></a><span class="comment">// Optimised ANSI C code for the Rijndael cipher (now AES)</span>122<a id="L13"></a><span class="comment">//</span>123<a id="L14"></a><span class="comment">// @author Vincent Rijmen &lt;vincent.rijmen@esat.kuleuven.ac.be&gt;</span>124<a id="L15"></a><span class="comment">// @author Antoon Bosselaers &lt;antoon.bosselaers@esat.kuleuven.ac.be&gt;</span>125<a id="L16"></a><span class="comment">// @author Paulo Barreto &lt;paulo.barreto@terra.com.br&gt;</span>126<a id="L17"></a><span class="comment">//</span>127<a id="L18"></a><span class="comment">// This code is hereby placed in the public domain.</span>128<a id="L19"></a><span class="comment">//</span>129<a id="L20"></a><span class="comment">// THIS SOFTWARE IS PROVIDED BY THE AUTHORS &#39;&#39;AS IS&#39;&#39; AND ANY EXPRESS</span>130<a id="L21"></a><span class="comment">// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED</span>131<a id="L22"></a><span class="comment">// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE</span>132<a id="L23"></a><span class="comment">// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE</span>133<a id="L24"></a><span class="comment">// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR</span>134<a id="L25"></a><span class="comment">// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF</span>135<a id="L26"></a><span class="comment">// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR</span>136<a id="L27"></a><span class="comment">// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,</span>137<a id="L28"></a><span class="comment">// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE</span>138<a id="L29"></a><span class="comment">// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,</span>139<a id="L30"></a><span class="comment">// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>140<a id="L31"></a><span class="comment">//</span>141<a id="L32"></a><span class="comment">// See FIPS 197 for specification, and see Daemen and Rijmen&#39;s Rijndael submission</span>142<a id="L33"></a><span class="comment">// for implementation details.</span>143<a id="L34"></a><span class="comment">// http://www.csrc.nist.gov/publications/fips/fips197/fips-197.pdf</span>144<a id="L35"></a><span class="comment">// http://csrc.nist.gov/archive/aes/rijndael/Rijndael-ammended.pdf</span>145<a id="L37"></a>package aes146<a id="L39"></a><span class="comment">// Encrypt one block from src into dst, using the expanded key xk.</span>147<a id="L40"></a>func encryptBlock(xk []uint32, src, dst []byte) {148 <a id="L41"></a>var s0, s1, s2, s3, t0, t1, t2, t3 uint32;149 <a id="L43"></a>s0 = uint32(src[0])&lt;&lt;24 | uint32(src[1])&lt;&lt;16 | uint32(src[2])&lt;&lt;8 | uint32(src[3]);150 <a id="L44"></a>s1 = uint32(src[4])&lt;&lt;24 | uint32(src[5])&lt;&lt;16 | uint32(src[6])&lt;&lt;8 | uint32(src[7]);151 <a id="L45"></a>s2 = uint32(src[8])&lt;&lt;24 | uint32(src[9])&lt;&lt;16 | uint32(src[10])&lt;&lt;8 | uint32(src[11]);152 <a id="L46"></a>s3 = uint32(src[12])&lt;&lt;24 | uint32(src[13])&lt;&lt;16 | uint32(src[14])&lt;&lt;8 | uint32(src[15]);153 <a id="L48"></a><span class="comment">// First round just XORs input with key.</span>154 <a id="L49"></a>s0 ^= xk[0];155 <a id="L50"></a>s1 ^= xk[1];156 <a id="L51"></a>s2 ^= xk[2];157 <a id="L52"></a>s3 ^= xk[3];158 <a id="L54"></a><span class="comment">// Middle rounds shuffle using tables.</span>159 <a id="L55"></a><span class="comment">// Number of rounds is set by length of expanded key.</span>160 <a id="L56"></a>nr := len(xk)/4 - 2; <span class="comment">// - 2: one above, one more below</span>161 <a id="L57"></a>k := 4;162 <a id="L58"></a>for r := 0; r &lt; nr; r++ {163 <a id="L59"></a>t0 = xk[k+0] ^ te[0][s0&gt;&gt;24] ^ te[1][s1&gt;&gt;16&amp;0xff] ^ te[2][s2&gt;&gt;8&amp;0xff] ^ te[3][s3&amp;0xff];164 <a id="L60"></a>t1 = xk[k+1] ^ te[0][s1&gt;&gt;24] ^ te[1][s2&gt;&gt;16&amp;0xff] ^ te[2][s3&gt;&gt;8&amp;0xff] ^ te[3][s0&amp;0xff];165 <a id="L61"></a>t2 = xk[k+2] ^ te[0][s2&gt;&gt;24] ^ te[1][s3&gt;&gt;16&amp;0xff] ^ te[2][s0&gt;&gt;8&amp;0xff] ^ te[3][s1&amp;0xff];166 <a id="L62"></a>t3 = xk[k+3] ^ te[0][s3&gt;&gt;24] ^ te[1][s0&gt;&gt;16&amp;0xff] ^ te[2][s1&gt;&gt;8&amp;0xff] ^ te[3][s2&amp;0xff];167 <a id="L63"></a>k += 4;168 <a id="L64"></a>s0, s1, s2, s3 = t0, t1, t2, t3;169 <a id="L65"></a>}170 <a id="L67"></a><span class="comment">// Last round uses s-box directly and XORs to produce output.</span>171 <a id="L68"></a>s0 = uint32(sbox0[t0&gt;&gt;24])&lt;&lt;24 | uint32(sbox0[t1&gt;&gt;16&amp;0xff])&lt;&lt;16 | uint32(sbox0[t2&gt;&gt;8&amp;0xff])&lt;&lt;8 | uint32(sbox0[t3&amp;0xff]);172 <a id="L69"></a>s1 = uint32(sbox0[t1&gt;&gt;24])&lt;&lt;24 | uint32(sbox0[t2&gt;&gt;16&amp;0xff])&lt;&lt;16 | uint32(sbox0[t3&gt;&gt;8&amp;0xff])&lt;&lt;8 | uint32(sbox0[t0&amp;0xff]);173 <a id="L70"></a>s2 = uint32(sbox0[t2&gt;&gt;24])&lt;&lt;24 | uint32(sbox0[t3&gt;&gt;16&amp;0xff])&lt;&lt;16 | uint32(sbox0[t0&gt;&gt;8&amp;0xff])&lt;&lt;8 | uint32(sbox0[t1&amp;0xff]);174 <a id="L71"></a>s3 = uint32(sbox0[t3&gt;&gt;24])&lt;&lt;24 | uint32(sbox0[t0&gt;&gt;16&amp;0xff])&lt;&lt;16 | uint32(sbox0[t1&gt;&gt;8&amp;0xff])&lt;&lt;8 | uint32(sbox0[t2&amp;0xff]);175 <a id="L73"></a>s0 ^= xk[k+0];176 <a id="L74"></a>s1 ^= xk[k+1];177 <a id="L75"></a>s2 ^= xk[k+2];178 <a id="L76"></a>s3 ^= xk[k+3];179 <a id="L78"></a>dst[0], dst[1], dst[2], dst[3] = byte(s0&gt;&gt;24), byte(s0&gt;&gt;16), byte(s0&gt;&gt;8), byte(s0);180 <a id="L79"></a>dst[4], dst[5], dst[6], dst[7] = byte(s1&gt;&gt;24), byte(s1&gt;&gt;16), byte(s1&gt;&gt;8), byte(s1);181 <a id="L80"></a>dst[8], dst[9], dst[10], dst[11] = byte(s2&gt;&gt;24), byte(s2&gt;&gt;16), byte(s2&gt;&gt;8), byte(s2);182 <a id="L81"></a>dst[12], dst[13], dst[14], dst[15] = byte(s3&gt;&gt;24), byte(s3&gt;&gt;16), byte(s3&gt;&gt;8), byte(s3);183<a id="L82"></a>}184<a id="L84"></a><span class="comment">// Decrypt one block from src into dst, using the expanded key xk.</span>185<a id="L85"></a>func decryptBlock(xk []uint32, src, dst []byte) {186 <a id="L86"></a>var s0, s1, s2, s3, t0, t1, t2, t3 uint32;187 <a id="L88"></a>s0 = uint32(src[0])&lt;&lt;24 | uint32(src[1])&lt;&lt;16 | uint32(src[2])&lt;&lt;8 | uint32(src[3]);188 <a id="L89"></a>s1 = uint32(src[4])&lt;&lt;24 | uint32(src[5])&lt;&lt;16 | uint32(src[6])&lt;&lt;8 | uint32(src[7]);189 <a id="L90"></a>s2 = uint32(src[8])&lt;&lt;24 | uint32(src[9])&lt;&lt;16 | uint32(src[10])&lt;&lt;8 | uint32(src[11]);190 <a id="L91"></a>s3 = uint32(src[12])&lt;&lt;24 | uint32(src[13])&lt;&lt;16 | uint32(src[14])&lt;&lt;8 | uint32(src[15]);191 <a id="L93"></a><span class="comment">// First round just XORs input with key.</span>192 <a id="L94"></a>s0 ^= xk[0];193 <a id="L95"></a>s1 ^= xk[1];194 <a id="L96"></a>s2 ^= xk[2];195 <a id="L97"></a>s3 ^= xk[3];196 <a id="L99"></a><span class="comment">// Middle rounds shuffle using tables.</span>197 <a id="L100"></a><span class="comment">// Number of rounds is set by length of expanded key.</span>198 <a id="L101"></a>nr := len(xk)/4 - 2; <span class="comment">// - 2: one above, one more below</span>199 <a id="L102"></a>k := 4;200 <a id="L103"></a>for r := 0; r &lt; nr; r++ {201 <a id="L104"></a>t0 = xk[k+0] ^ td[0][s0&gt;&gt;24] ^ td[1][s3&gt;&gt;16&amp;0xff] ^ td[2][s2&gt;&gt;8&amp;0xff] ^ td[3][s1&amp;0xff];202 <a id="L105"></a>t1 = xk[k+1] ^ td[0][s1&gt;&gt;24] ^ td[1][s0&gt;&gt;16&amp;0xff] ^ td[2][s3&gt;&gt;8&amp;0xff] ^ td[3][s2&amp;0xff];203 <a id="L106"></a>t2 = xk[k+2] ^ td[0][s2&gt;&gt;24] ^ td[1][s1&gt;&gt;16&amp;0xff] ^ td[2][s0&gt;&gt;8&amp;0xff] ^ td[3][s3&amp;0xff];204 <a id="L107"></a>t3 = xk[k+3] ^ td[0][s3&gt;&gt;24] ^ td[1][s2&gt;&gt;16&amp;0xff] ^ td[2][s1&gt;&gt;8&amp;0xff] ^ td[3][s0&amp;0xff];205 <a id="L108"></a>k += 4;206 <a id="L109"></a>s0, s1, s2, s3 = t0, t1, t2, t3;207 <a id="L110"></a>}208 <a id="L112"></a><span class="comment">// Last round uses s-box directly and XORs to produce output.</span>209 <a id="L113"></a>s0 = uint32(sbox1[t0&gt;&gt;24])&lt;&lt;24 | uint32(sbox1[t3&gt;&gt;16&amp;0xff])&lt;&lt;16 | uint32(sbox1[t2&gt;&gt;8&amp;0xff])&lt;&lt;8 | uint32(sbox1[t1&amp;0xff]);210 <a id="L114"></a>s1 = uint32(sbox1[t1&gt;&gt;24])&lt;&lt;24 | uint32(sbox1[t0&gt;&gt;16&amp;0xff])&lt;&lt;16 | uint32(sbox1[t3&gt;&gt;8&amp;0xff])&lt;&lt;8 | uint32(sbox1[t2&amp;0xff]);211 <a id="L115"></a>s2 = uint32(sbox1[t2&gt;&gt;24])&lt;&lt;24 | uint32(sbox1[t1&gt;&gt;16&amp;0xff])&lt;&lt;16 | uint32(sbox1[t0&gt;&gt;8&amp;0xff])&lt;&lt;8 | uint32(sbox1[t3&amp;0xff]);212 <a id="L116"></a>s3 = uint32(sbox1[t3&gt;&gt;24])&lt;&lt;24 | uint32(sbox1[t2&gt;&gt;16&amp;0xff])&lt;&lt;16 | uint32(sbox1[t1&gt;&gt;8&amp;0xff])&lt;&lt;8 | uint32(sbox1[t0&amp;0xff]);213 <a id="L118"></a>s0 ^= xk[k+0];214 <a id="L119"></a>s1 ^= xk[k+1];215 <a id="L120"></a>s2 ^= xk[k+2];216 <a id="L121"></a>s3 ^= xk[k+3];217 <a id="L123"></a>dst[0], dst[1], dst[2], dst[3] = byte(s0&gt;&gt;24), byte(s0&gt;&gt;16), byte(s0&gt;&gt;8), byte(s0);218 <a id="L124"></a>dst[4], dst[5], dst[6], dst[7] = byte(s1&gt;&gt;24), byte(s1&gt;&gt;16), byte(s1&gt;&gt;8), byte(s1);219 <a id="L125"></a>dst[8], dst[9], dst[10], dst[11] = byte(s2&gt;&gt;24), byte(s2&gt;&gt;16), byte(s2&gt;&gt;8), byte(s2);220 <a id="L126"></a>dst[12], dst[13], dst[14], dst[15] = byte(s3&gt;&gt;24), byte(s3&gt;&gt;16), byte(s3&gt;&gt;8), byte(s3);221<a id="L127"></a>}222<a id="L129"></a><span class="comment">// Apply sbox0 to each byte in w.</span>223<a id="L130"></a>func subw(w uint32) uint32 {224 <a id="L131"></a>return uint32(sbox0[w&gt;&gt;24])&lt;&lt;24 |225 <a id="L132"></a>uint32(sbox0[w&gt;&gt;16&amp;0xff])&lt;&lt;16 |226 <a id="L133"></a>uint32(sbox0[w&gt;&gt;8&amp;0xff])&lt;&lt;8 |227 <a id="L134"></a>uint32(sbox0[w&amp;0xff])228<a id="L135"></a>}229<a id="L137"></a><span class="comment">// Rotate</span>230<a id="L138"></a>func rotw(w uint32) uint32 { return w&lt;&lt;8 | w&gt;&gt;24 }231<a id="L140"></a><span class="comment">// Key expansion algorithm. See FIPS-197, Figure 11.</span>232<a id="L141"></a><span class="comment">// Their rcon[i] is our powx[i-1] &lt;&lt; 24.</span>233<a id="L142"></a>func expandKey(key []byte, enc, dec []uint32) {234 <a id="L143"></a><span class="comment">// Encryption key setup.</span>235 <a id="L144"></a>var i int;236 <a id="L145"></a>nk := len(key) / 4;237 <a id="L146"></a>for i = 0; i &lt; nk; i++ {238 <a id="L147"></a>enc[i] = uint32(key[4*i])&lt;&lt;24 | uint32(key[4*i+1])&lt;&lt;16 | uint32(key[4*i+2])&lt;&lt;8 | uint32(key[4*i+3])239 <a id="L148"></a>}240 <a id="L149"></a>for ; i &lt; len(enc); i++ {241 <a id="L150"></a>t := enc[i-1];242 <a id="L151"></a>if i%nk == 0 {243 <a id="L152"></a>t = subw(rotw(t)) ^ (uint32(powx[i/nk-1]) &lt;&lt; 24)244 <a id="L153"></a>} else if nk &gt; 6 &amp;&amp; i%nk == 4 {245 <a id="L154"></a>t = subw(t)246 <a id="L155"></a>}247 <a id="L156"></a>enc[i] = enc[i-nk] ^ t;248 <a id="L157"></a>}249 <a id="L159"></a><span class="comment">// Derive decryption key from encryption key.</span>250 <a id="L160"></a><span class="comment">// Reverse the 4-word round key sets from enc to produce dec.</span>251 <a id="L161"></a><span class="comment">// All sets but the first and last get the MixColumn transform applied.</span>252 <a id="L162"></a>if dec == nil {253 <a id="L163"></a>return254 <a id="L164"></a>}255 <a id="L165"></a>n := len(enc);256 <a id="L166"></a>for i := 0; i &lt; n; i += 4 {257 <a id="L167"></a>ei := n - i - 4;258 <a id="L168"></a>for j := 0; j &lt; 4; j++ {259 <a id="L169"></a>x := enc[ei+j];260 <a id="L170"></a>if i &gt; 0 &amp;&amp; i+4 &lt; n {261 <a id="L171"></a>x = td[0][sbox0[x&gt;&gt;24]] ^ td[1][sbox0[x&gt;&gt;16&amp;0xff]] ^ td[2][sbox0[x&gt;&gt;8&amp;0xff]] ^ td[3][sbox0[x&amp;0xff]]262 <a id="L172"></a>}263 <a id="L173"></a>dec[i+j] = x;264 <a id="L174"></a>}265 <a id="L175"></a>}266<a id="L176"></a>}267</pre>268</div>269<div id="footer">270<p>Except as noted, this content is271 licensed under <a href="http://creativecommons.org/licenses/by/3.0/">272 Creative Commons Attribution 3.0</a>.273</div>274<script type="text/javascript">275var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");276document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));277</script>278<script type="text/javascript">279var pageTracker = _gat._getTracker("UA-11222381-2");280pageTracker._trackPageview();281</script>282</body>283</html>284<!-- generated at Thu Nov 12 15:42:51 PST 2009 -->...

Full Screen

Full Screen

format_html_test.go

Source:format_html_test.go Github

copy

Full Screen

1// Copyright 2021 The Cockroach Authors.2//3// Use of this software is governed by the Business Source License4// included in the file licenses/BSL.txt.5//6// As of the Change Date specified in that file, in accordance with7// the Business Source License, use of this software will be governed8// by the Apache License, Version 2.0, included in the file9// licenses/APL.txt.10package clisqlexec11import (12 "bytes"13 "fmt"14 "io/ioutil"15 "testing"16 "github.com/cockroachdb/cockroach/pkg/util/leaktest"17 "github.com/cockroachdb/cockroach/pkg/util/log"18)19func TestRenderHTML(t *testing.T) {20 defer leaktest.AfterTest(t)()21 defer log.Scope(t).Close(t)22 cols := []string{"colname"}23 align := "d"24 rows := [][]string{25 {"<b>foo</b>"},26 {"bar"},27 }28 type testCase struct {29 reporter htmlReporter30 out string31 }32 testCases := []testCase{33 {34 reporter: htmlReporter{},35 out: `<table>36<thead><tr><th>colname</th></tr></thead>37<tbody>38<tr><td><b>foo</b></td></tr>39<tr><td>bar</td></tr>40</tbody>41</table>42`,43 },44 {45 reporter: htmlReporter{escape: true},46 out: `<table>47<thead><tr><th>colname</th></tr></thead>48<tbody>49<tr><td>&lt;b&gt;foo&lt;/b&gt;</td></tr>50<tr><td>bar</td></tr>51</tbody>52</table>53`,54 },55 {56 reporter: htmlReporter{rowStats: true},57 out: `<table>58<thead><tr><th>row</th><th>colname</th></tr></thead>59<tbody>60<tr><td>1</td><td><b>foo</b></td></tr>61<tr><td>2</td><td>bar</td></tr>62</tbody>63<tfoot><tr><td colspan=2>2 rows</td></tr></tfoot></table>64`,65 },66 {67 reporter: htmlReporter{escape: true, rowStats: true},68 out: `<table>69<thead><tr><th>row</th><th>colname</th></tr></thead>70<tbody>71<tr><td>1</td><td>&lt;b&gt;foo&lt;/b&gt;</td></tr>72<tr><td>2</td><td>bar</td></tr>73</tbody>74<tfoot><tr><td colspan=2>2 rows</td></tr></tfoot></table>75`,76 },77 }78 for _, tc := range testCases {79 name := fmt.Sprintf("escape=%v/rowStats=%v", tc.reporter.escape, tc.reporter.rowStats)80 t.Run(name, func(t *testing.T) {81 var buf bytes.Buffer82 err := render(&tc.reporter, &buf, ioutil.Discard,83 cols, NewRowSliceIter(rows, align),84 nil /* completedHook */, nil /* noRowsHook */)85 if err != nil {86 t.Fatal(err)87 }88 if tc.out != buf.String() {89 t.Errorf("expected:\n%s\ngot:\n%s", tc.out, buf.String())90 }91 })92 }93}...

Full Screen

Full Screen

Gt

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 table := tablewriter.NewWriter(os.Stdout)4 table.SetHeader([]string{"Name", "Age"})5 table.SetBorder(false)6 table.Append([]string{"John", "11"})7 table.Append([]string{"Sam", "15"})8 table.Append([]string{"Julia", "12"})9 table.Append([]string{"Bob", "12"})10 table.Append([]string{"Alex", "12"})11 table.Append([]string{"Jack", "12"})12 table.Append([]s

Full Screen

Full Screen

Gt

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 client := td.NewClient(td.Settings{4 })5 client.Run()6 client.Send(query.NewCheckDatabaseEncryptionKey([]byte("password")))7 for update := range client.Updates {8 switch update := update.(type) {9 if update.AuthorizationState.GetConstructor() == tg.ClassAuthorizationStateReady {10 fmt.Println("ready!")11 }12 }13 }14}15import (16func main() {17 client := td.NewClient(td.Settings{18 })19 client.Run()20 client.Send(query.NewCheckDatabaseEncryptionKey([]byte("password")))21 for update := range client.Updates {22 switch update := update.(type) {23 if update.AuthorizationState.GetConstructor() ==

Full Screen

Full Screen

Gt

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 xlFile, error := xlsx.OpenFile("test.xlsx")4 if error != nil {5 fmt.Println("Error in opening file")6 }7 for _, row := range sheet.Rows {8 for _, cell := range row.Cells {9 text := cell.String()10 fmt.Printf("%s\n", text)11 }12 }13}14import (15func main() {16 xlFile, error := xlsx.OpenFile("test.xlsx")17 if error != nil {18 fmt.Println("Error in opening file")19 }20 for _, row := range sheet.Rows {21 for _, cell := range row.Cells {22 formula := cell.GetFormula()23 fmt.Printf("%s\n", formula)24 }25 }26}27=SUM(A2:A5)28=SUM(B2:B5)29=SUM(C2:C5)30=SUM(D2:D5)31=SUM(E2:E5)32import (33func main() {

Full Screen

Full Screen

Gt

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 t1.Init(1, 2, 3)4 t2.Init(1, 2, 3)5 if t1.Gt(t2) {6 fmt.Println("t1 > t2")7 } else {8 fmt.Println("t1 <= t2")9 }10}

Full Screen

Full Screen

Gt

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 t1.Set(2, 30)4 t2.Set(3, 40)5 fmt.Println("t1=", t1)6 fmt.Println("t2=", t2)7 fmt.Println("t1>t2=", t1.Gt(t2))8}9import (10func main() {11 t1.Set(2, 30)12 t2.Set(2, 30)13 fmt.Println("t1=", t1)14 fmt.Println("t2=", t2)15 fmt.Println("t1=t2=", t1.Eq(t2))16}17import (18func main() {19 t1.Set(2, 30)20 t2.Set(3, 40)21 fmt.Println("t1=", t1)22 fmt.Println("t2=", t2)23 fmt.Println("t1!=t2=", t1.Ne(t2))24}25import (26func main() {27 t1.Set(2, 30)28 t2.Set(3, 40)29 fmt.Println("t1=", t1)30 fmt.Println("t2=", t2)31 fmt.Println("t1<=t2=", t1.Le(t2))32}

Full Screen

Full Screen

Gt

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 a.Scan("1/2")4 b.Scan("3/4")5 fmt.Println(a.Gt(b))6}

Full Screen

Full Screen

Gt

Using AI Code Generation

copy

Full Screen

1import "fmt"2import "github.com/tdlib/td"3func main() {4 t1.Set(2)5 t2.Set(3)6 fmt.Println(t1.Gt(t2))7}8import "fmt"9import "github.com/tdlib/td"10func main() {11 t1.Set(2)12 t2.Set(3)13 t1.Add(t2)14 fmt.Println(t1)15}16import "fmt"17import "github.com/tdlib/td"18func main() {19 t1.Set(2)20 t2.Set(3)21 t1.Sub(t2)22 fmt.Println(t1)23}24import "fmt"25import "github.com/tdlib/td"26func main() {27 t1.Set(2)28 t2.Set(3)29 t1.Mul(t2)30 fmt.Println(t1)31}32import "fmt"33import "github.com/tdlib/td"34func main() {35 t1.Set(2)36 t2.Set(3)37 t1.Div(t2)38 fmt.Println(t1)39}40import "fmt"41import "github.com/tdlib/td"42func main() {43 t1.Set(2)44 t2.Set(3)45 t1.Mod(t2)46 fmt.Println(t1)47}48import "fmt"49import

Full Screen

Full Screen

Gt

Using AI Code Generation

copy

Full Screen

1import "fmt"2import "github.com/td"3func main() {4 fmt.Println(td.Gt(5, 10))5}6import "fmt"7import "github.com/td"8func main() {9 fmt.Println(td.Lte(5, 10))10}11import "fmt"12import "github.com/td"13func main() {14 fmt.Println(td.Lt(5, 10))15}16import "fmt"17import "github.com/td"18func main() {19 fmt.Println(td.Eq(5, 10))20}21import "fmt"22import "github.com/td"23func main() {24 fmt.Println(td.Neq(5, 10))25}26import "fmt"27import "github.com/td"28func main() {29 fmt.Println(td.And(true, false))30}31import "fmt"32import "github.com/td"33func main() {34 fmt.Println(td.Or(true, false))35}36import "fmt"37import "github.com/td"38func main() {39 fmt.Println(td.Not(true))40}41import "fmt"42import "github.com/td"43func main() {44 fmt.Println(td.If(true, 10, 20))45}46import "fmt"47import "github.com/td"48func main() {49 fmt.Println(td.Elif(true, 10, 20))50}51import "fmt"52import "github.com/td"53func main() {54 fmt.Println(td.El

Full Screen

Full Screen

Gt

Using AI Code Generation

copy

Full Screen

1import "fmt"2import "github.com/01-edu/z01"3func main() {4 fmt.Println("Hello World!")5 z01.PrintRune('\n')6}7import "fmt"8import "github.com/01-edu/z01"9func main() {10 a := td{1, 2}11 b := td{2, 1}12 fmt.Println(a.Gt(b))13 z01.PrintRune('\n')14}15import "fmt"16import "github.com/01-edu/z01"17func main() {18 a := td{2, 1}19 b := td{1, 2}20 fmt.Println(a.Gt(b))21 z01.PrintRune('\n')22}23import "fmt"24import "github.com/01-edu/z01"25func main() {26 a := td{1, 2}27 b := td{1, 2}28 fmt.Println(a.Gt(b))29 z01.PrintRune('\n')30}31import "fmt"32import "github.com/01-edu/z01"33func main() {34 a := td{1, 2}35 b := td{2, 1}36 fmt.Println(b

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Go-testdeep automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful