github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/pkg/structs/transporttrie/diff_test.go (about)

     1  package transporttrie
     2  
     3  import (
     4  	. "github.com/onsi/ginkgo/v2"
     5  	. "github.com/onsi/gomega"
     6  )
     7  
     8  var _ = Describe("trie package", func() {
     9  	Context("trie.Diff()", func() {
    10  		It("diffs 2 tries", func() {
    11  			t1 := New()
    12  			t1.Insert([]byte("foo"), uint64(1))
    13  			t1.Insert([]byte("bar"), uint64(2))
    14  			t1.Insert([]byte("baz"), uint64(3))
    15  
    16  			t2 := New()
    17  			t2.Insert([]byte("foo"), uint64(3))
    18  			t2.Insert([]byte("bar"), uint64(2))
    19  			t2.Insert([]byte("baz"), uint64(1))
    20  
    21  			t4 := New()
    22  			t4.Insert([]byte("foo"), uint64(0))
    23  			t4.Insert([]byte("bar"), uint64(0))
    24  			t4.Insert([]byte("baz"), uint64(2))
    25  
    26  			t3 := t1.Diff(t2)
    27  
    28  			Expect(t3.String()).To(Equal(t4.String()))
    29  		})
    30  	})
    31  })