-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcomplex.go
39 lines (31 loc) · 949 Bytes
/
complex.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package assert
type Complex struct {
logFacade *logFacade
actual complex128
}
func (a *Complex) IsZero() *Complex {
return a.isTrue(a.actual == 0,
"Expected zero, but was <%v>.", a.actual)
}
func (a *Complex) IsNonZero() *Complex {
return a.isTrue(a.actual != 0,
"Expected nonzero, but was zero.")
}
func (a *Complex) IsEqualTo(expected complex128) *Complex {
return a.isTrue(a.actual == expected,
"Expected <%v>, but was <%v>.", expected, a.actual)
}
func (a *Complex) IsNotEqualTo(unexpected complex128) *Complex {
return a.isTrue(a.actual != unexpected,
"Expected not equal to <%v>, but was.", unexpected)
}
func (a *Complex) Real() *Float {
return &Float{a.logFacade, real(a.actual)}
}
func (a *Complex) Imag() *Float {
return &Float{a.logFacade, imag(a.actual)}
}
func (a *Complex) isTrue(condition bool, format string, args ...interface{}) *Complex {
logIfFalse(a.logFacade, condition, format, args...)
return a
}