Skip to content

Instantly share code, notes, and snippets.

@pacuna
Created June 15, 2020 00:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pacuna/bce019f93e845990a2757c6aeef050b1 to your computer and use it in GitHub Desktop.
Save pacuna/bce019f93e845990a2757c6aeef050b1 to your computer and use it in GitHub Desktop.
package simplelist
import "testing"
func Test_List(t *testing.T) {
l := New()
l.Add([]byte("item1"))
l.Add([]byte("item2"))
if l.Size() != 2 {
t.Errorf("Size()=%d, want 2", l.Size())
}
if !l.Contains([]byte("item1")) {
t.Error("item1 should be present")
}
if l.Contains([]byte("nonPresentItem")) {
t.Error("item doesn't exist in the set")
}
l.Remove([]byte("item2"))
if l.Contains([]byte("item2")) {
t.Error("item2 doesn't exist in the set")
}
if l.Size() != 1 {
t.Errorf("Size()=%d, want 1", l.Size())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment