Debian Codegraph @

assert_test.go

raw
1 // assert_test.go - utility function for tests
2 //
3 // (c) 2024 Sudhi Herle <[email protected]>
4 //
5 // Licensing Terms: GPLv2
6 //
7 // If you need a commercial license for this work, please contact
8 // the author.
9 //
10 // This software does not come with any express or implied
11 // warranty; it is provided "as is". No claim is made to its
12 // suitability for any purpose.
13
14 package sieve_test
15
16 import (
17 "fmt"
18 "runtime"
19 "testing"
20 )
21
22 func newAsserter(t *testing.T) func(cond bool, msg string, args ...interface{}) {
23 return func(cond bool, msg string, args ...interface{}) {
24 if cond {
25 return
26 }
27
28 _, file, line, ok := runtime.Caller(1)
29 if !ok {
30 file = "???"
31 line = 0
32 }
33
34 s := fmt.Sprintf(msg, args...)
35 t.Fatalf("%s: %d: Assertion failed: %s\n", file, line, s)
36 }
37 }