add type constraint test

This commit is contained in:
Denis-Cosmin Nutiu 2024-09-15 16:05:47 +03:00
parent 3e26736767
commit e76cf0638a

View file

@ -83,3 +83,22 @@ func TestMyHashSet_Sub(t *testing.T) {
assert.False(t, newSet.Contains(MyString{Value: "Batman"}))
assert.False(t, newSet.Contains(MyString{Value: "Robin"}))
}
type String string
func (a String) Hash() string {
return string(a)
}
func TestMyHashSet_Constraint(t *testing.T) {
// Setup
newSet := NewSet[String, string]()
// Test
newSet.AddAll("type", "constraints", "rock")
// Then
assert.True(t, newSet.Contains("type"))
assert.True(t, newSet.Contains("constraints"))
assert.True(t, newSet.Contains("rock"))
}