A package for assertions without dependency hell
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
406B

  1. package assert
  2. import (
  3. "fmt"
  4. "reflect"
  5. "runtime"
  6. "strconv"
  7. )
  8. func prepMsg(msg []interface{}, format string, args ...interface{}) []interface{} {
  9. return append(msg, "\n\n", fmt.Sprintf(format, args...))
  10. }
  11. func shell(i int) string {
  12. return "\x1B[" + strconv.Itoa(i) + "m"
  13. }
  14. var ts = map[*runtime.Func]T{}
  15. func t(a Assert) T {
  16. f := runtime.FuncForPC(reflect.ValueOf(a).Pointer())
  17. return ts[f]
  18. }