MCPcopy Create free account
hub / github.com/ByteStorage/FlyDB / TestFZSetMinMax

Function TestFZSetMinMax

structure/zset_test.go:884–916  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

882}
883
884func TestFZSetMinMax(t *testing.T) {
885 fzs := &FZSet{
886 skipList: newSkipList(),
887 }
888 _ = fzs.InsertNode(1, "mem1", "")
889 _ = fzs.InsertNode(100, "mem2", "")
890
891 minScore, maxScore := fzs.getMinMaxScore()
892
893 if minScore != 1 || maxScore != 100 {
894 t.Errorf("getMinMaxScore() = %d, %d, want: 1, 100", minScore, maxScore)
895 }
896
897 if min := fzs.min(5, 10); min != 5 {
898 t.Errorf("min(5, 10) = %d, want: 5", min)
899 }
900
901 if max := fzs.max(5, 10); max != 10 {
902 t.Errorf("max(5, 10) = %d, want: 10", max)
903 }
904
905 // if case part of skip list is missing, we should return 0,0
906 fzs.skipList.tail.value = nil
907 minScore, maxScore = fzs.getMinMaxScore()
908 assert.Equal(t, minScore, 0)
909 assert.Equal(t, maxScore, 0)
910 // again, an error case
911 fzs.skipList = nil
912 minScore, maxScore = fzs.getMinMaxScore()
913 assert.Equal(t, minScore, 0)
914 assert.Equal(t, maxScore, 0)
915
916}
917func TestZSetStructure_adjustMinMax(t *testing.T) {
918 zss, _ := NewZSetStructure(config.DefaultOptions)
919 fz := newZSetNodes()

Callers

nothing calls this directly

Calls 5

InsertNodeMethod · 0.95
getMinMaxScoreMethod · 0.95
minMethod · 0.95
maxMethod · 0.95
newSkipListFunction · 0.85

Tested by

no test coverage detected