MCPcopy Create free account
hub / github.com/dgraph-io/dgraph / TestRemoveDuplicates

Function TestRemoveDuplicates

worker/sort_test.go:774–805  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

772}
773
774func TestRemoveDuplicates(t *testing.T) {
775 toSet := func(uids []uint64) map[uint64]struct{} {
776 m := make(map[uint64]struct{})
777 for _, uid := range uids {
778 m[uid] = struct{}{}
779 }
780 return m
781 }
782
783 for _, test := range []struct {
784 setIn []uint64
785 setOut []uint64
786 uidsIn []uint64
787 uidsOut []uint64
788 }{
789 {setIn: nil, setOut: nil, uidsIn: nil, uidsOut: nil},
790 {setIn: nil, setOut: []uint64{2}, uidsIn: []uint64{2}, uidsOut: []uint64{2}},
791 {setIn: []uint64{2}, setOut: []uint64{2}, uidsIn: []uint64{2}, uidsOut: []uint64{}},
792 {setIn: []uint64{2}, setOut: []uint64{2}, uidsIn: []uint64{2, 2}, uidsOut: []uint64{}},
793 {
794 setIn: []uint64{2, 3},
795 setOut: []uint64{2, 3, 4, 5},
796 uidsIn: []uint64{3, 4, 5},
797 uidsOut: []uint64{4, 5},
798 },
799 } {
800 set := toSet(test.setIn)
801 uidsOut := removeDuplicates(test.uidsIn, set)
802 require.Equal(t, uidsOut, test.uidsOut)
803 require.Equal(t, set, toSet(test.setOut))
804 }
805}

Callers

nothing calls this directly

Calls 1

removeDuplicatesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…