Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcomplex_test.go
More file actions
Latest commit
80 lines (69 loc) · 2.26 KB
/
Copy pathcomplex_test.go
File metadata and controls
80 lines (69 loc) · 2.26 KB
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"
funcTestThatComplexIsZeroHasNoErrors(t*testing.T) {
assert, mockT:=setupWithMockT(t)
assert.ThatComplex(0i).IsZero().IsZero()
mockT.HasNoErrors()
}
funcTestThatComplexIsZeroHasErrorMessages(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)>.",
)
}
funcTestThatComplexIsNonZeroHasNoErrors(t*testing.T) {
assert, mockT:=setupWithMockT(t)
assert.ThatComplex(-1).IsNonZero()
assert.ThatComplex(1i).IsNonZero()
mockT.HasNoErrors()
}
funcTestThatComplexIsNonZeroHasErrorMessages(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.",
)
}
funcTestThatComplexIsEqualToHasNoErrors(t*testing.T) {
assert, mockT:=setupWithMockT(t)
assert.ThatComplex(1i).IsEqualTo(complex(0, 1)).IsEqualTo(0+1i)
mockT.HasNoErrors()
}
funcTestThatComplexIsEqualToHasErrorMessages(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)>.",
)
}
funcTestThatComplexIsNotEqualToHasNoErrors(t*testing.T) {
assert, mockT:=setupWithMockT(t)
assert.ThatComplex(1i).IsNotEqualTo(1).IsNotEqualTo(2i)
mockT.HasNoErrors()
}
funcTestThatComplexIsNotEqualToHasErrorMessages(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.",
)
}
funcTestThatComplexRealHasNoErrors(t*testing.T) {
assert, mockT:=setupWithMockT(t)
assert.ThatComplex(complex(0, -1)).Real().IsZero()
assert.ThatComplex(complex(3.3, 0)).Real().IsNonZero()
mockT.HasNoErrors()
}
funcTestThatComplexImagHasNoErrors(t*testing.T) {
assert, mockT:=setupWithMockT(t)
assert.ThatComplex(complex(3.3, 0)).Imag().IsZero()
assert.ThatComplex(complex(0, -1)).Imag().IsNonZero()
mockT.HasNoErrors()
}