C#: Add some more test cases.

This commit is contained in:
Michael Nebel
2025-05-15 13:44:12 +02:00
parent 2c5d85e186
commit 4b2d323cb6
2 changed files with 32 additions and 1 deletions

View File

@@ -7,9 +7,26 @@ public class Test
{
var h = new Hashtable();
h.Add(this, null); // $ Alert
h.Contains(this); // $ Alert
h.ContainsKey(this); // $ Alert
h[this] = null; // $ Alert
h.Remove(this); // $ Alert
var l = new List<Test>();
l.Add(this); // Good
var d = new Dictionary<Test, bool>();
d.Add(this, false); // $ Alert
d.ContainsKey(this); // $ Alert
d[this] = false; // $ Alert
d.Remove(this); // $ Alert
d.TryAdd(this, false); // $ Alert
d.TryGetValue(this, out bool _); // $ Alert
var hs = new HashSet<Test>();
hs.Add(this); // $ Alert
hs.Contains(this); // $ Alert
hs.Remove(this); // $ Alert
}
public override bool Equals(object other)

View File

@@ -1,2 +1,16 @@
#select
| HashedButNoHash.cs:9:15:9:18 | this access | This expression is hashed, but type 'Test' only defines Equals(...) not GetHashCode(). |
| HashedButNoHash.cs:12:15:12:18 | this access | This expression is hashed, but type 'Test' only defines Equals(...) not GetHashCode(). |
| HashedButNoHash.cs:11:23:11:26 | this access | This expression is hashed, but type 'Test' only defines Equals(...) not GetHashCode(). |
| HashedButNoHash.cs:19:15:19:18 | this access | This expression is hashed, but type 'Test' only defines Equals(...) not GetHashCode(). |
| HashedButNoHash.cs:20:23:20:26 | this access | This expression is hashed, but type 'Test' only defines Equals(...) not GetHashCode(). |
testFailures
| HashedButNoHash.cs:10:27:10:36 | // ... | Missing result: Alert |
| HashedButNoHash.cs:12:25:12:34 | // ... | Missing result: Alert |
| HashedButNoHash.cs:13:25:13:34 | // ... | Missing result: Alert |
| HashedButNoHash.cs:21:26:21:35 | // ... | Missing result: Alert |
| HashedButNoHash.cs:22:25:22:34 | // ... | Missing result: Alert |
| HashedButNoHash.cs:23:32:23:41 | // ... | Missing result: Alert |
| HashedButNoHash.cs:24:42:24:51 | // ... | Missing result: Alert |
| HashedButNoHash.cs:27:23:27:32 | // ... | Missing result: Alert |
| HashedButNoHash.cs:28:28:28:37 | // ... | Missing result: Alert |
| HashedButNoHash.cs:29:26:29:35 | // ... | Missing result: Alert |