update html
This commit is contained in:
parent
22ddaa5fd0
commit
421044f185
2
public/testing
generated
2
public/testing
generated
@ -231,7 +231,7 @@ when executing <code>go test -v</code>.</p>
|
|||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
var codeLines = [];
|
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 := 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('');
|
||||||
</script>
|
</script>
|
||||||
<script src="site.js" async></script>
|
<script src="site.js" async></script>
|
||||||
</body>
|
</body>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user