Skip to content

Commit 79465a0

Browse files
committed
Adding missing functional test
1 parent 77da16b commit 79465a0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Assets/Tests/InputSystem/CoreTests_Devices_Keyboard.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,24 @@ public void Devices_Keyboard_SubscriptOperatorCanLookupKeyControlOfCorresponding
199199
}
200200
}
201201

202+
[Test(Description = "Verifies documented requirement 'This is equivalent to <c>allKeys[(int)key - 1]'")]
203+
[Category("Devices")]
204+
public void Devices_Keyboard_SubscriptOperatorShouldBeEquivalentToShiftedAllKeysLookup()
205+
{
206+
var keyboard = InputSystem.AddDevice<Keyboard>();
207+
var allKeys = keyboard.allKeys;
208+
foreach (var key in sKeys)
209+
{
210+
// Key.None is documented as an invalid key so skip it in this test.
211+
// Sub-script operator is documented to through for invalid key.
212+
if (key == Key.None)
213+
continue;
214+
215+
var keyControl = keyboard[key];
216+
Assert.That(keyControl, Is.EqualTo(allKeys[(int)key - 1]));
217+
}
218+
}
219+
202220
[Test]
203221
[Category("Devices")]
204222
public void Devices_Keyboard_SubscriptOperatorThrowsForInvalidOrOutOfRangeKey()

0 commit comments

Comments
 (0)