Permalink
Browse files

testing

  • Loading branch information...
GoesToEleven committed Oct 23, 2016
1 parent 67f6eb2 commit 53841fcb90f8030e1c07ab1f8de1d81cbad08c4b
Showing with 52 additions and 29 deletions.
  1. +0 −29 24_testing/00_under-development/01/sample.txt
  2. +9 −0 24_testing/math.go
  3. +43 −0 24_testing/math_test.go

This file was deleted.

Oops, something went wrong.
View
@@ -0,0 +1,9 @@
package math
func Adder(xs ...int) int {
res := 0
for _, v := range xs {
res += v
}
return res
}
View
@@ -0,0 +1,43 @@
package math
import (
"fmt"
"testing"
"testing/quick"
)
func TestAdder(t *testing.T) {
result := Adder(4, 7)
if result != 11 {
t.Fatal("4 + 7 did not equal 11")
}
}
func BenchmarkAdder(b *testing.B) {
for i := 0; i < b.N; i++ {
Adder(4, 7)
}
}
func ExampleAdder() {
fmt.Println(Adder(4, 7))
// Output:
// 11
}
func ExampleAdder_multiple() {
fmt.Println(Adder(3, 6, 7, 4, 61))
// Output:
// 81
}
func TestAdderBlackbox(t *testing.T) {
err := quick.Check(a, nil)
if err != nil {
t.Fatal(err)
}
}
func a(x, y int) bool {
return Adder(x, y) == x+y
}

0 comments on commit 53841fc

Please sign in to comment.