45 строки
788 Б
Go
45 строки
788 Б
Go
package godog_and_gomega
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"strconv"
|
|
|
|
. "github.com/onsi/gomega"
|
|
)
|
|
|
|
var Be = Equal
|
|
|
|
func NoErr(err error) {
|
|
ExpectWithOffset(1, err).NotTo(HaveOccurred())
|
|
}
|
|
|
|
var Ok = NoErr
|
|
|
|
func Err(err error) {
|
|
ExpectWithOffset(1, err).To(HaveOccurred())
|
|
}
|
|
func ErrIs(err, target error) {
|
|
ExpectWithOffset(1, err).To(HaveOccurred())
|
|
v := errors.Is(err, target)
|
|
s := fmt.Sprintf("ErrIs: '%v' != '%v'", err, target)
|
|
ExpectWithOffset(1, v).To(BeTrue(), s)
|
|
}
|
|
|
|
func Yes(b bool) {
|
|
ExpectWithOffset(1, b).To(BeTrue())
|
|
}
|
|
func YesText(b bool, text string) {
|
|
ExpectWithOffset(1, b).To(BeTrue(), text)
|
|
}
|
|
|
|
func Atoi(in string) int {
|
|
res, err := strconv.Atoi(in)
|
|
Ok(err)
|
|
return res
|
|
}
|
|
func Atof(in string) float64 {
|
|
res, err := strconv.ParseFloat(in, 64)
|
|
Ok(err)
|
|
return res
|
|
}
|