forked from credondocr/dota2api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsteamId_test.go
148 lines (141 loc) · 4.25 KB
/
steamId_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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
package dota2api
import (
"fmt"
. "github.com/franela/goblin"
"testing"
)
func TestNewSteamIdFrom32(t *testing.T) {
g := Goblin(t)
g.Describe("NewSteamIdFrom32", func() {
steamId := NewSteamIdFrom32(4039455774)
g.It("Should set the Id", func() {
g.Assert(steamId.id == 4039455774).IsTrue()
})
g.It("Should set the Id type", func() {
g.Assert(steamId.isId64).IsFalse()
})
})
}
func TestNewSteamIdFrom64(t *testing.T) {
g := Goblin(t)
g.Describe("NewSteamIdFrom64", func() {
steamId := NewSteamIdFrom64(8674665223082153551)
g.It("Should set the Id", func() {
g.Assert(steamId.id == 8674665223082153551).IsTrue()
})
g.It("Should set the Id type", func() {
g.Assert(steamId.isId64).IsTrue()
})
})
}
func TestSteamId_SetSteamId32(t *testing.T) {
g := Goblin(t)
g.Describe("SteamId.SetSteamId32", func() {
g.Describe("With a previously empty SteamId", func() {
steamId := SteamId{}
steamId.SetSteamId32(2854263694)
g.It("Should set the Id", func() {
g.Assert(steamId.id == 2854263694).IsTrue(fmt.Sprintf("expected %d, got %d", 2854263694, steamId.id))
})
g.It("Should set the Id type", func() {
g.Assert(steamId.isId64).IsFalse()
})
})
g.Describe("With a previously SteamId32 SteamId", func() {
steamId := NewSteamIdFrom32(4039455774)
steamId.SetSteamId32(2854263694)
g.It("Should set the Id", func() {
g.Assert(steamId.id == 2854263694).IsTrue(fmt.Sprintf("expected %d, got %d", 2854263694, steamId.id))
})
g.It("Should set the Id type", func() {
g.Assert(steamId.isId64).IsFalse()
})
})
g.Describe("With a previously SteamId64 SteamId", func() {
steamId := NewSteamIdFrom64(8674665223082153551)
steamId.SetSteamId32(2854263694)
g.It("Should set the Id", func() {
g.Assert(steamId.id == 2854263694).IsTrue(fmt.Sprintf("expected %d, got %d", 2854263694, steamId.id))
})
g.It("Should set the Id type", func() {
g.Assert(steamId.isId64).IsFalse()
})
})
})
}
func TestSteamId_SetSteamId64(t *testing.T) {
g := Goblin(t)
g.Describe("SteamId.SetSteamId64", func() {
g.Describe("With a previously empty SteamId", func() {
steamId := SteamId{}
steamId.SetSteamId64(15352856648520921629)
g.It("Should set the Id", func() {
g.Assert(steamId.id == 15352856648520921629).IsTrue()
})
g.It("Should set the Id type", func() {
g.Assert(steamId.isId64).IsTrue()
})
})
g.Describe("With a previously SteamId32 SteamId", func() {
steamId := NewSteamIdFrom32(4039455774)
steamId.SetSteamId64(15352856648520921629)
g.It("Should set the Id", func() {
g.Assert(steamId.id == 15352856648520921629).IsTrue()
})
g.It("Should set the Id type", func() {
g.Assert(steamId.isId64).IsTrue()
})
})
g.Describe("With a previously SteamId64 SteamId", func() {
steamId := NewSteamIdFrom64(8674665223082153551)
steamId.SetSteamId64(15352856648520921629)
g.It("Should set the Id", func() {
g.Assert(steamId.id == 15352856648520921629).IsTrue()
})
g.It("Should set the Id type", func() {
g.Assert(steamId.isId64).IsTrue()
})
})
})
}
func TestSteamId_SteamId32(t *testing.T) {
g := Goblin(t)
g.Describe("SteamId.SteamId32", func() {
g.Describe("With a previously SteamId32 SteamId", func() {
steamId := NewSteamIdFrom32(4039455774)
id := steamId.SteamId32()
g.It("Should set the correct Id", func() {
g.Assert(id == 4039455774).IsTrue()
})
})
g.Describe("With a previously SteamId64 SteamId", func() {
steamId := NewSteamIdFrom64(8674665223082153551)
id := steamId.SteamId32()
g.It("Should set the correct Id", func() {
g.Assert(id == 1597969999).IsTrue()
})
})
})
}
func TestSteamId_SteamId64(t *testing.T) {
g := Goblin(t)
g.Describe("SteamId.SteamId64", func() {
g.Describe("With a previously SteamId32 SteamId", func() {
steamId := NewSteamIdFrom32(4039455774)
_, err := steamId.SteamId64()
g.It("Should return error", func() {
g.Assert(err).IsNotNil()
})
})
g.Describe("With a previously SteamId64 SteamId", func() {
steamId := NewSteamIdFrom64(8674665223082153551)
id, err := steamId.SteamId64()
g.It("Should return no error", func() {
g.Assert(err).IsNil()
})
g.It("Should return the correct Id", func() {
g.Assert(id == 8674665223082153551).IsTrue()
})
})
})
}