Add a NewStringSet() function
Also beef up tests to cover len(ss).
This commit is contained in:
@@ -22,7 +22,13 @@ import (
|
||||
|
||||
func TestStringSet(t *testing.T) {
|
||||
s := StringSet{}
|
||||
if len(s) != 0 {
|
||||
t.Errorf("Expected len=0: %d", len(s))
|
||||
}
|
||||
s.Insert("a", "b")
|
||||
if len(s) != 2 {
|
||||
t.Errorf("Expected len=2: %d", len(s))
|
||||
}
|
||||
s.Insert("c")
|
||||
if s.Has("d") {
|
||||
t.Errorf("Unexpected contents: %#v", s)
|
||||
@@ -35,3 +41,13 @@ func TestStringSet(t *testing.T) {
|
||||
t.Errorf("Unexpected contents: %#v", s)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewStringSet(t *testing.T) {
|
||||
s := NewStringSet("a", "b", "c")
|
||||
if len(s) != 3 {
|
||||
t.Errorf("Expected len=3: %d", len(s))
|
||||
}
|
||||
if !s.Has("a") || !s.Has("b") || !s.Has("c") {
|
||||
t.Errorf("Unexpected contents: %#v", s)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user