add type constraint test
This commit is contained in:
parent
3e26736767
commit
e76cf0638a
1 changed files with 19 additions and 0 deletions
|
@ -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: "Batman"}))
|
||||||
assert.False(t, newSet.Contains(MyString{Value: "Robin"}))
|
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"))
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue