change html

This commit is contained in:
andrew 2020-03-09 12:59:19 +02:00
parent 5afa5faf66
commit 746d2d5abb
2 changed files with 5 additions and 6 deletions

7
public/testing generated
View File

@ -47,7 +47,7 @@ typically lives in the same package as the code it tests.</p>
</td>
<td class="code leading">
<a href="http://play.golang.org/p/jCRgtgRwie3"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
<a href="http://play.golang.org/p/GFuPdlBlyMU"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
<div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span>
</pre></div>
@ -83,9 +83,8 @@ be named <code>intutils_test.go</code>.</p>
<div class="highlight"><pre><span class="kd">func</span> <span class="nx">IntMin</span><span class="p">(</span><span class="nx">a</span><span class="p">,</span> <span class="nx">b</span> <span class="kt">int</span><span class="p">)</span> <span class="kt">int</span> <span class="p">{</span>
<span class="k">if</span> <span class="nx">a</span> <span class="p">&lt;</span> <span class="nx">b</span> <span class="p">{</span>
<span class="k">return</span> <span class="nx">a</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="k">return</span> <span class="nx">b</span>
<span class="p">}</span>
<span class="k">return</span> <span class="nx">b</span>
<span class="p">}</span>
</pre></div>
@ -232,7 +231,7 @@ when executing <code>go test -v</code>.</p>
</div>
<script>
var codeLines = [];
codeLines.push('');codeLines.push('package main\u000A');codeLines.push('import (\u000A \"fmt\"\u000A \"testing\"\u000A)\u000A');codeLines.push('func IntMin(a, b int) int {\u000A if a \x3C b {\u000A return a\u000A } else {\u000A return b\u000A }\u000A}\u000A');codeLines.push('func TestIntMinBasic(t *testing.T) {\u000A ans := IntMin(2, -2)\u000A if ans != -2 {\u000A');codeLines.push(' t.Errorf(\"IntMin(2, -2) = %d; want -2\", ans)\u000A }\u000A}\u000A');codeLines.push('func TestIntMinTableDriven(t *testing.T) {\u000A var tests = []struct {\u000A a, b int\u000A want int\u000A }{\u000A {0, 1, 0},\u000A {1, 0, 0},\u000A {2, -2, -2},\u000A {0, -1, -1},\u000A {-1, 0, -1},\u000A }\u000A');codeLines.push(' for _, tt := range tests {\u000A');codeLines.push(' testname := fmt.Sprintf(\"%d,%d\", tt.a, tt.b)\u000A t.Run(testname, func(t *testing.T) {\u000A ans := IntMin(tt.a, tt.b)\u000A if ans != tt.want {\u000A t.Errorf(\"got %d, want %d\", ans, tt.want)\u000A }\u000A })\u000A }\u000A}\u000A');codeLines.push('');
codeLines.push('');codeLines.push('package main\u000A');codeLines.push('import (\u000A \"fmt\"\u000A \"testing\"\u000A)\u000A');codeLines.push('func IntMin(a, b int) int {\u000A if a \x3C b {\u000A return a\u000A }\u000A return b\u000A}\u000A');codeLines.push('func TestIntMinBasic(t *testing.T) {\u000A ans :\x3D IntMin(2, -2)\u000A if ans !\x3D -2 {\u000A');codeLines.push(' t.Errorf(\"IntMin(2, -2) \x3D %d; want -2\", ans)\u000A }\u000A}\u000A');codeLines.push('func TestIntMinTableDriven(t *testing.T) {\u000A var tests \x3D []struct {\u000A a, b int\u000A want int\u000A }{\u000A {0, 1, 0},\u000A {1, 0, 0},\u000A {2, -2, -2},\u000A {0, -1, -1},\u000A {-1, 0, -1},\u000A }\u000A');codeLines.push(' for _, tt :\x3D range tests {\u000A');codeLines.push(' testname :\x3D fmt.Sprintf(\"%d,%d\", tt.a, tt.b)\u000A t.Run(testname, func(t *testing.T) {\u000A ans :\x3D IntMin(tt.a, tt.b)\u000A if ans !\x3D tt.want {\u000A t.Errorf(\"got %d, want %d\", ans, tt.want)\u000A }\u000A })\u000A }\u000A}\u000A');codeLines.push('');
</script>
<script src="site.js" async></script>
</body>

4
public/xml generated
View File

@ -42,7 +42,7 @@ formats with the <code>encoding.xml</code> package.</p>
</td>
<td class="code leading">
<a href="http://play.golang.org/p/wlkywJsuWqL"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
<a href="http://play.golang.org/p/RsNLhMBazeX"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
<div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span>
</pre></div>
@ -281,7 +281,7 @@ to nest all <code>plant</code>s under <code>&lt;parent&gt;&lt;child&gt;...</code
</div>
<script>
var codeLines = [];
codeLines.push('');codeLines.push('package main\u000A');codeLines.push('import (\u000A \"encoding/xml\"\u000A \"fmt\"\u000A)\u000A');codeLines.push('type Plant struct {\u000A XMLName xml.Name `xml:\"plant\"`\u000A Id int `xml:\"id,attr\"`\u000A Name string `xml:\"name\"`\u000A Origin []string `xml:\"origin\"`\u000A}\u000A');codeLines.push('func (p Plant) String() string {\u000A return fmt.Sprintf(\"Plant id=%v, name=%v, origin=%v\",\u000A p.Id, p.Name, p.Origin)\u000A}\u000A');codeLines.push('func main() {\u000A coffee := &Plant{Id: 27, Name: \"Coffee\"}\u000A coffee.Origin = []string{\"Ethiopia\", \"Brazil\"}\u000A');codeLines.push(' out, _ := xml.MarshalIndent(coffee, \" \", \" \")\u000A fmt.Println(string(out))\u000A');codeLines.push(' fmt.Println(xml.Header + string(out))\u000A');codeLines.push(' var p Plant\u000A if err := xml.Unmarshal(out, &p); err != nil {\u000A panic(err)\u000A }\u000A fmt.Println(p)\u000A');codeLines.push(' tomato := &Plant{Id: 81, Name: \"Tomato\"}\u000A tomato.Origin = []string{\"Mexico\", \"California\"}\u000A');codeLines.push(' type Nesting struct {\u000A XMLName xml.Name `xml:\"nesting\"`\u000A Plants []*Plant `xml:\"parent\x3Echild\x3Eplant\"`\u000A }\u000A');codeLines.push(' nesting := &Nesting{}\u000A nesting.Plants = []*Plant{coffee, tomato}\u000A');codeLines.push(' out, _ = xml.MarshalIndent(nesting, \" \", \" \")\u000A fmt.Println(string(out))\u000A}\u000A');codeLines.push('');
codeLines.push('');codeLines.push('package main\u000A');codeLines.push('import (\u000A \"encoding/xml\"\u000A \"fmt\"\u000A)\u000A');codeLines.push('type Plant struct {\u000A XMLName xml.Name `xml:\"plant\"`\u000A Id int `xml:\"id,attr\"`\u000A Name string `xml:\"name\"`\u000A Origin []string `xml:\"origin\"`\u000A}\u000A');codeLines.push('func (p Plant) String() string {\u000A return fmt.Sprintf(\"Plant id\x3D%v, name\x3D%v, origin\x3D%v\",\u000A p.Id, p.Name, p.Origin)\u000A}\u000A');codeLines.push('func main() {\u000A coffee :\x3D \x26Plant{Id: 27, Name: \"Coffee\"}\u000A coffee.Origin \x3D []string{\"Ethiopia\", \"Brazil\"}\u000A');codeLines.push(' out, _ :\x3D xml.MarshalIndent(coffee, \" \", \" \")\u000A fmt.Println(string(out))\u000A');codeLines.push(' fmt.Println(xml.Header + string(out))\u000A');codeLines.push(' var p Plant\u000A if err :\x3D xml.Unmarshal(out, \x26p); err !\x3D nil {\u000A panic(err)\u000A }\u000A fmt.Println(p)\u000A');codeLines.push(' tomato :\x3D \x26Plant{Id: 81, Name: \"Tomato\"}\u000A tomato.Origin \x3D []string{\"Mexico\", \"California\"}\u000A');codeLines.push(' type Nesting struct {\u000A XMLName xml.Name `xml:\"nesting\"`\u000A Plants []*Plant `xml:\"parent\x3Echild\x3Eplant\"`\u000A }\u000A');codeLines.push(' nesting :\x3D \x26Nesting{}\u000A nesting.Plants \x3D []*Plant{coffee, tomato}\u000A');codeLines.push(' out, _ \x3D xml.MarshalIndent(nesting, \" \", \" \")\u000A fmt.Println(string(out))\u000A}\u000A');codeLines.push('');
</script>
<script src="site.js" async></script>
</body>