Added HasAll utility method for string set.

Added HasAll method which detects if one set contains all
of the memebers of another set.

A.HasAll(B) returns true if A is a superset of B.
This commit is contained in:
Danny Jones
2014-07-18 13:08:11 -07:00
parent fda69bcca2
commit 2d9bad95f8
3 changed files with 22 additions and 1 deletions

View File

@@ -23,6 +23,7 @@ import (
func TestStringSet(t *testing.T) {
s := StringSet{}
s2 := StringSet{}
if len(s) != 0 {
t.Errorf("Expected len=0: %d", len(s))
}
@@ -41,6 +42,15 @@ func TestStringSet(t *testing.T) {
if s.Has("a") {
t.Errorf("Unexpected contents: %#v", s)
}
s.Insert("a")
s2.Insert("a","b","d")
if s.HasAll(s2) {
t.Errorf("Unexpected contents: %#v", s)
}
s2.Delete("d")
if !s.HasAll(s2) {
t.Errorf("Missing contents: %#v", s)
}
}
func TestNewStringSet(t *testing.T) {