Last active
August 29, 2015 14:01
-
-
Save marklap/9df458b8494760bb94f7 to your computer and use it in GitHub Desktop.
Messing around with unit testing in Go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "testing" | |
func TestMain(t *testing.T) { | |
something := -1 | |
if testing.Short() { | |
t.Skip("Skipping this stupid test") | |
} | |
if something > 0 { | |
t.Errorf("This freakin' thing is more than zero!") | |
} else if something < 0 { | |
t.Errorf("Crap! Less than zero!") | |
} | |
} | |
func BenchmarkAppendAuto(b *testing.B) { | |
j := []int{} | |
for i := 0; i < b.N; i++ { | |
j = append(j, i) | |
} | |
} | |
func BenchmarkAppendStatic(b *testing.B) { | |
j := make([]int, b.N, b.N) | |
for i := 0; i < b.N; i++ { | |
j[i] = i | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment