public void EqualsAtIndex() { const string s = "01234567890123456789012345678901234567890123456789012345678901234567890123456789"; for (var index = 0; index <= s.Length; index++) { for (var length = 0; length < s.Length - index; length++) { const string format = "index={0} length={1}"; Assert.True(StringPool.EqualsAtIndex(s, index, s.Substring(index, length)), format, index, length); if (length < s.Length) { Assert.False(StringPool.EqualsAtIndex(s, index, s.Substring(index, length) + 'Z'), format, index, length); } if (index > 0 && length > 0) { Assert.False(StringPool.EqualsAtIndex(s, index - 1, s.Substring(index, length)), format, index, length); Assert.False(StringPool.EqualsAtIndex(s, index, s.Substring(index - 1, length)), format, index, length); } if (index + length < s.Length) { if (length == 0) { Assert.True(StringPool.EqualsAtIndex(s, index + 1, s.Substring(index, length)), format, index, length); Assert.True(StringPool.EqualsAtIndex(s, index, s.Substring(index + 1, length)), format, index, length); } else { Assert.False(StringPool.EqualsAtIndex(s, index + 1, s.Substring(index, length)), format, index, length); Assert.False(StringPool.EqualsAtIndex(s, index, s.Substring(index + 1, length)), format, index, length); } } } } }