public void CharactersComparedOneByOne_Invariant(RegexOptions options) { // Regex compares characters one by one. If that changes, it could impact the behavior of // a case like this, where these characters are not the same, but the strings compare // as equal with the invariant culture (and some other cultures as well). const string S1 = "\u00D6\u200D"; const string S2 = "\u004F\u0308"; // Validate the chosen strings to make sure they compare the way we want to test via Regex Assert.False(S1[0] == S2[0]); Assert.False(S1[1] == S2[1]); Assert.StartsWith(S1, S2, StringComparison.InvariantCulture); Assert.True(S1.Equals(S2, StringComparison.InvariantCulture)); // Test varying lengths of strings to validate codegen changes that kick in at longer lengths foreach (int multiple in new[] { 1, 10, 100 }) { string pattern = string.Concat(Enumerable.Repeat(S1, multiple)); string input = string.Concat(Enumerable.Repeat(S2, multiple)); Regex r; // Validate when the string is at the beginning of the pattern, as it impacts Boyer-Moore prefix matching. r = new Regex(pattern, options); Assert.False(r.IsMatch(input)); Assert.True(r.IsMatch(pattern)); // Validate when it's not at the beginning of the pattern, as it impacts "multi" matching. r = new Regex("[abc]" + pattern, options); Assert.False(r.IsMatch("a" + input)); Assert.True(r.IsMatch("a" + pattern)); } }
public override bool Equals(object obj) { var other = obj as JoinWithAuditNameEntity; if (other == null) { return(false); } return(Id == other.Id && S1.Equals(other.S1) && S2.Equals(other.S2)); }
private void Remove(char?literal) { if (!literal.HasValue) { return; } if (S1?.Equals(literal.Value) ?? false) { S1 = null; } if (S2?.Equals(literal.Value) ?? false) { S2 = null; } }