MCPcopy
hub / github.com/EngoEngine/engo / TestKeyManager

Function TestKeyManager

keys_test.go:159–234  ·  view source on GitHub ↗

This test sets up a key manager and changes the states a few times, every time the state changes the results are checked against the expected outcome.

(t *testing.T)

Source from the content-addressed store, hash-verified

157// This test sets up a key manager and changes the states a few times, every
158// time the state changes the results are checked against the expected outcome.
159func TestKeyManager(t *testing.T) {
160 mgr := NewKeyManager()
161 runKeyChecks("Init (0.0)", t, mgr, initPass0)
162
163 // Empty update pass0
164 mgr.update()
165 runKeyChecks("Pass (0.1)", t, mgr, initPass0)
166 mgr.update()
167 runKeyChecks("Pass (0.2)", t, mgr, initPass0)
168 mgr.update()
169 runKeyChecks("Pass (0.3)", t, mgr, initPass0)
170
171 // Set uneven true pass1
172 mgr.update()
173
174 mgr.Set(keySimpleCfg[1], true)
175 mgr.Set(keySimpleCfg[3], true)
176 mgr.Set(keySimpleCfg[5], true)
177 mgr.Set(keySimpleCfg[7], true)
178 mgr.Set(keySimpleCfg[9], true)
179 mgr.Set(keySimpleCfg[11], true)
180
181 runKeyChecks("Pass (1.0)", t, mgr, initPass1)
182
183 // Set even true pass2
184 mgr.update()
185
186 mgr.Set(keySimpleCfg[0], true)
187 mgr.Set(keySimpleCfg[2], true)
188 mgr.Set(keySimpleCfg[4], true)
189 mgr.Set(keySimpleCfg[6], true)
190 mgr.Set(keySimpleCfg[8], true)
191 mgr.Set(keySimpleCfg[10], true)
192
193 runKeyChecks("Pass (2.0)", t, mgr, initPass2)
194
195 // Keeps state
196 mgr.update()
197 runKeyChecks("Pass (3.0)", t, mgr, initPass3)
198 mgr.update()
199 runKeyChecks("Pass (3.1)", t, mgr, initPass3)
200 mgr.update()
201 runKeyChecks("Pass (3.2)", t, mgr, initPass3)
202
203 // Set uneven to false
204 mgr.update()
205
206 mgr.Set(keySimpleCfg[1], false)
207 mgr.Set(keySimpleCfg[3], false)
208 mgr.Set(keySimpleCfg[5], false)
209 mgr.Set(keySimpleCfg[7], false)
210 mgr.Set(keySimpleCfg[9], false)
211 mgr.Set(keySimpleCfg[11], false)
212
213 runKeyChecks("Pass (4.0)", t, mgr, initPass4)
214
215 // Set uneven to false
216 mgr.update()

Callers

nothing calls this directly

Calls 4

updateMethod · 0.95
SetMethod · 0.95
NewKeyManagerFunction · 0.85
runKeyChecksFunction · 0.85

Tested by

no test coverage detected