provide a generic assert function
package verify
import (
+ "fmt"
"os"
"strings"
)
@@ -70,3 +71,10 @@ func Verify(f func()) {
f()
}
}
+
+// Assert will panic with a given formatted message if the given condition is false.
+func Assert(condition bool, msg string, v ...interface{}) {
+ if !condition {
+ panic(fmt.Sprintf("assertion failed: "+msg, v...))
+ }
+}
