From e76cf0638a0d873d4a7d7dca3f4c3348552bb9d8 Mon Sep 17 00:00:00 2001 From: Denis Nutiu Date: Sun, 15 Sep 2024 16:05:47 +0300 Subject: [PATCH] add type constraint test --- hash_set/hash_set/hash_set_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/hash_set/hash_set/hash_set_test.go b/hash_set/hash_set/hash_set_test.go index 8f5e9cd..8972130 100644 --- a/hash_set/hash_set/hash_set_test.go +++ b/hash_set/hash_set/hash_set_test.go @@ -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")) +}