-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcomplex_test.go
80 lines (69 loc) · 2.26 KB
/
complex_test.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package assert
import "testing"
func TestThatComplexIsZeroHasNoErrors(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatComplex(0i).IsZero().IsZero()
mockT.HasNoErrors()
}
func TestThatComplexIsZeroHasErrorMessages(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatComplex(-1).IsZero()
assert.ThatComplex(1i).IsZero()
mockT.HasErrorMessages(
"Expected zero, but was <(-1+0i)>.",
"Expected zero, but was <(0+1i)>.",
)
}
func TestThatComplexIsNonZeroHasNoErrors(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatComplex(-1).IsNonZero()
assert.ThatComplex(1i).IsNonZero()
mockT.HasNoErrors()
}
func TestThatComplexIsNonZeroHasErrorMessages(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatComplex(complex(0, 0)).IsNonZero().IsNonZero()
mockT.HasErrorMessages(
"Expected nonzero, but was zero.",
"Expected nonzero, but was zero.",
)
}
func TestThatComplexIsEqualToHasNoErrors(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatComplex(1i).IsEqualTo(complex(0, 1)).IsEqualTo(0 + 1i)
mockT.HasNoErrors()
}
func TestThatComplexIsEqualToHasErrorMessages(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatComplex(1i).IsEqualTo(1).IsEqualTo(2i)
mockT.HasErrorMessages(
"Expected <(1+0i)>, but was <(0+1i)>.",
"Expected <(0+2i)>, but was <(0+1i)>.",
)
}
func TestThatComplexIsNotEqualToHasNoErrors(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatComplex(1i).IsNotEqualTo(1).IsNotEqualTo(2i)
mockT.HasNoErrors()
}
func TestThatComplexIsNotEqualToHasErrorMessages(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatComplex(1i).IsNotEqualTo(complex(0, 1))
assert.ThatComplex(0.3 - 0.3i).IsNotEqualTo(complex(0.3, -0.3))
mockT.HasErrorMessages(
"Expected not equal to <(0+1i)>, but was.",
"Expected not equal to <(0.3-0.3i)>, but was.",
)
}
func TestThatComplexRealHasNoErrors(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatComplex(complex(0, -1)).Real().IsZero()
assert.ThatComplex(complex(3.3, 0)).Real().IsNonZero()
mockT.HasNoErrors()
}
func TestThatComplexImagHasNoErrors(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatComplex(complex(3.3, 0)).Imag().IsZero()
assert.ThatComplex(complex(0, -1)).Imag().IsNonZero()
mockT.HasNoErrors()
}