diff options
author | Chris Martin <chris@cmartinit.co.uk> | 2023-03-01 20:08:29 +0000 |
---|---|---|
committer | Chris Martin <chris@cmartinit.co.uk> | 2023-03-01 20:08:29 +0000 |
commit | b95d2c9b7a98ac9efd694fc82dc9e3f7160410b4 (patch) | |
tree | 3a1dce6e15bf5f2f25b9efd14263a2d937a098d5 /sets_test.go | |
parent | Merge pull request #43 from infogulch/patch-1 (diff) | |
download | pds-b95d2c9b7a98ac9efd694fc82dc9e3f7160410b4.tar.gz pds-b95d2c9b7a98ac9efd694fc82dc9e3f7160410b4.tar.xz |
expose sorted sets builder
Diffstat (limited to 'sets_test.go')
-rw-r--r-- | sets_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/sets_test.go b/sets_test.go index ca3aa3d..6612cba 100644 --- a/sets_test.go +++ b/sets_test.go @@ -101,3 +101,26 @@ func TestSortedSetsDelete(t *testing.T) { t.Fatalf("Unexpected set element after delete") } } + +func TestSortedSetBuilder(t *testing.T) { + b := NewSortedSetBuilder[string](nil) + b.Set("test3") + b.Set("test1") + b.Set("test2") + + s := b.SortedSet() + items := s.Items() + + if len(items) != 3 { + t.Fatalf("Set has wrong number of items") + } + if items[0] != "test1" { + t.Fatalf("First item incorrectly sorted") + } + if items[1] != "test2" { + t.Fatalf("Second item incorrectly sorted") + } + if items[2] != "test3" { + t.Fatalf("Third item incorrectly sorted") + } +} |