2023-08-03 21:07:58 +02:00
|
|
|
package utils
|
|
|
|
|
2023-08-05 16:15:54 +02:00
|
|
|
import (
|
|
|
|
"log"
|
2023-08-07 18:18:25 +02:00
|
|
|
"testing"
|
2023-08-05 16:15:54 +02:00
|
|
|
|
|
|
|
"golang.org/x/exp/constraints"
|
|
|
|
)
|
2023-08-03 21:07:58 +02:00
|
|
|
|
|
|
|
func Check(err error, msg string, args ...any) {
|
|
|
|
if err != nil {
|
|
|
|
log.Printf(msg, args...)
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
2023-08-05 16:15:54 +02:00
|
|
|
|
|
|
|
func Min[T constraints.Ordered](a, b T) T {
|
|
|
|
if a < b {
|
|
|
|
return a
|
|
|
|
}
|
|
|
|
return b
|
|
|
|
}
|
2023-08-07 18:18:25 +02:00
|
|
|
|
|
|
|
func AssertEqual[T comparable](t *testing.T, got T, want T, msg string, args ...any) {
|
|
|
|
args = append(args, got, want)
|
|
|
|
if got != want {
|
|
|
|
t.Fatalf(msg+"\nGot: %v, Want: %v", args...)
|
|
|
|
}
|
|
|
|
}
|