-
Notifications
You must be signed in to change notification settings - Fork 0
All assertion methods
actually.Got(v).True(t)
If v
would be a true
of boolean type, then it will pass. Otherwise, it will be failed.
actually.Got(v).False(t)
If v
would be a false
of boolean type, then it will pass. Otherwise, it will be failed.
actually.Got(v).Nil(t)
If v
would be a nil
, then it will pass.
actually.Got(v).NotNil(t)
If v
would be other than nil
, then it will pass.
actually.Got(err).NoError(t)
If err
would be nil
, then it will pass.
There is a special setter for error
value for NoError
method: GotError
.
actually.GotError(err).NoError(t)
GotError
accepts only error
type. You can specify more strict on compile.
actually.Got(func(){ panic("OMG") }).Panic(t)
If a func of Got
panics, then it will pass. Otherwise, it will be failed.
actually.Got(func(){ panic("OMG") }).Expect("OMG").PanicMessage(t)
If a func of Got
panics, and a value of Expect
matches with a message from panic, then it will pass. Otherwise, it will be failed.
actually.Got(func(){}).NoPanic(t)
If a func of Got
doesn't panic, then it will pass. Otherwise, it will be failed.
actually.Got("target string").Expect(`.ing$`).Match(t)
If a value of Got
would match a value of Expect
as regexp, then it will pass. Otherwise, it will be failed.
Values of Got
and Expect
should be string type, anyway, it's going to be stringified by fmt.Sprint
.
actually.Got("target string").Expect(`^[a-z]+$`).NotMatch(t)
If a value of Got
would NOT match a value of Expect
as regexp, then it will pass. Otherwise, it will be failed. No matter why didn't match these.
Values of Got
and Expect
should be string type, anyway, it's going to be stringified by fmt.Sprint
.
actually.Got([]int{1, 2}).Expect(2).Len(t)
Len asserts that the specified object has specific length.
Len also fails if the object has a type that len() not accept.
All assertions for 2 objects of Actually have prefix 'Same'.
actually.Got(v).Expect(vv).Same(t)
If v
and vv
are same, then pass. The 2 objects should be same type. If these are same value, then it passes even if pointer addresses are different.
actually.Got(v).Expect(vv).SameNumber(t)
If v
and vv
are able to convert and able to assume objects are same value, then it's pass. For example, int32 and int64, or int and float, for kind of numbers.
actually.Got(ptr1).Expect(ptr2).SamePointer(t)
If ptr1
and ptr2
are pointing same address, then pass.
actually.Got(v).Expect(vv).SameType(t)
If a type of v
and a type of vv
are same, then pass. No matter values. Just verify only types.
actually.Got(v).Expect(vv).Cmp(t)
Cmp method gets the differences between two objects by go-cmp.Diff.
If you need to set cmp.Option, then you shoud use CmpOpt(cmp.Option)
method before calling Cmp.
Cmp method is just a wrapper of go-cmp.Diff. So, it's same that unexported fields are not compared by default;
they result in panics unless suppressed by using an Ignore option. It may panic if it cannot compare the values.
actually.Got(v).Expect(vv).CmpAllowUnexported(t)
CmpAllowUnexported method gets the differences between two objects by go-cmp.Diff with cmp.AllowUnexported option. It accepts unexported methods to compare instead panic. If you would like to ignore unexported methods, then you can use cmpopts.IgnoreUnexported or some cmpopt's options to ignore.
actually.Got(v).Expect(vv).CmpOpt(cmpopts.IgnoreFields(Foo{}, "Field")).Cmp(t)
CmpOpt method sets/adds options for Cmp* methods. There is no method to reset cmpOpts. Just set all opts at one time, or add opts.
actually.Got(v).Expect(vv).NotSame(t)
If v
and vv
are NOT same, then pass. If these are same value, then it should be FAIL even if pointer addresses are different.
actually.Got(v).Expect(vv).NotSameNumber(t)
If v
and vv
should be int, uint, or float for kind of numbers. And these should NOT be same values.
actually.Got(ptr1).Expect(ptr2).NotSamePointer(t)
If ptr1
and ptr2
should be pointers. But these should NOT be pointing same address.
actually.Got(v).Expect(vv).NotSameType(t)
If a type of v
and a type of vv
should NOT same, then pass. No matter values. Just verify only types.