mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-22 23:26:40 -08:00
Protect against index out of range exceptions
This commit is contained in:
@@ -37,5 +37,16 @@ namespace Reverse.Tests
|
||||
|
||||
Assert.True(input.SequenceEqual(output));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Reverse_WithIndexGreaterThanArrayLength_DoesNothing()
|
||||
{
|
||||
var input = new int[] { 1, 2 };
|
||||
var output = new int[] { 1, 2 };
|
||||
|
||||
Reverser.Reverse(input, input.Length + 1);
|
||||
|
||||
Assert.True(input.SequenceEqual(output));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user