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

Function runKeyChecks

keys_test.go:134–155  ·  view source on GitHub ↗

Checks the state of keys in the configuration against the expected state.

(msg string, t *testing.T, mgr *KeyManager, expect [12]keyState)

Source from the content-addressed store, hash-verified

132
133// Checks the state of keys in the configuration against the expected state.
134func runKeyChecks(msg string, t *testing.T, mgr *KeyManager, expect [12]keyState) {
135 for i, cd := range keySimpleCfg {
136 exp := expect[i]
137 sto := mgr.Get(cd)
138
139 if exp.state != sto.State() {
140 t.Error(msg, " Invalid on: ", cd, " - State")
141 }
142 if (KeyStateUp == exp.state) != sto.Up() {
143 t.Error(msg, " Invalid on: ", cd, " - Up")
144 }
145 if (KeyStateDown == exp.state) != sto.Down() {
146 t.Error(msg, " Invalid on: ", cd, " - Down")
147 }
148 if (KeyStateJustUp == exp.state) != sto.JustReleased() {
149 t.Error(msg, " Invalid on: ", cd, " - Just Up")
150 }
151 if (KeyStateJustDown == exp.state) != sto.JustPressed() {
152 t.Error(msg, " Invalid on: ", cd, " - Just Down")
153 }
154 }
155}
156
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.

Callers 1

TestKeyManagerFunction · 0.85

Calls 7

GetMethod · 0.80
StateMethod · 0.45
ErrorMethod · 0.45
UpMethod · 0.45
DownMethod · 0.45
JustReleasedMethod · 0.45
JustPressedMethod · 0.45

Tested by

no test coverage detected