Skip to content

Instantly share code, notes, and snippets.

@collinvandyck
Created June 7, 2014 19:32
Show Gist options
  • Save collinvandyck/d267d9caabc97db71045 to your computer and use it in GitHub Desktop.
Save collinvandyck/d267d9caabc97db71045 to your computer and use it in GitHub Desktop.
// helper methods for testing
package test
import (
"fmt"
"path/filepath"
"runtime"
"testing"
)
func Assert(t *testing.T, condition bool, explanation interface{}) {
if !condition {
if _, file, line, ok := runtime.Caller(1); ok {
short := filepath.Base(file)
t.Fatal(fmt.Sprintf("%s:%d: %s", short, line, explanation))
}
t.Fatal(explanation)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment