github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/pkg/storage/segment/relationship_test.go (about) 1 package segment 2 3 import ( 4 . "github.com/onsi/ginkgo/v2" 5 . "github.com/onsi/gomega" 6 "github.com/pyroscope-io/pyroscope/pkg/testing" 7 ) 8 9 // relationship overlap read overlap write 10 // inside rel = iota // | S E | <1 1/1 11 // match // matching ranges 1/1 1/1 12 // outside // | | S E 0/1 0/1 13 // overlap // | S | E <1 <1 14 // contain // S | | E 1/1 <1 15 16 var _ = Describe("stree", func() { 17 Context("relationship", func() { 18 Context("match", func() { 19 It("returns correct values", func() { 20 Expect(relationship( 21 testing.SimpleTime(0), testing.SimpleTime(100), // t1 t2 22 testing.SimpleTime(0), testing.SimpleTime(100), // st et 23 ).String()).To(Equal("match")) 24 }) 25 }) 26 Context("inside", func() { 27 It("returns correct values", func() { 28 Expect(relationship( 29 testing.SimpleTime(0), testing.SimpleTime(100), // t1 t2 30 testing.SimpleTime(10), testing.SimpleTime(90), // st et 31 ).String()).To(Equal("inside")) 32 Expect(relationship( 33 testing.SimpleTime(0), testing.SimpleTime(100), // t1 t2 34 testing.SimpleTime(0), testing.SimpleTime(90), // st et 35 ).String()).To(Equal("inside")) 36 Expect(relationship( 37 testing.SimpleTime(0), testing.SimpleTime(100), // t1 t2 38 testing.SimpleTime(10), testing.SimpleTime(100), // st et 39 ).String()).To(Equal("inside")) 40 }) 41 }) 42 Context("contain", func() { 43 It("returns correct values", func() { 44 Expect(relationship( 45 testing.SimpleTime(100), testing.SimpleTime(200), // t1 t2 46 testing.SimpleTime(90), testing.SimpleTime(210), // st et 47 ).String()).To(Equal("contain")) 48 Expect(relationship( 49 testing.SimpleTime(100), testing.SimpleTime(200), // t1 t2 50 testing.SimpleTime(100), testing.SimpleTime(210), // st et 51 ).String()).To(Equal("contain")) 52 Expect(relationship( 53 testing.SimpleTime(100), testing.SimpleTime(200), // t1 t2 54 testing.SimpleTime(90), testing.SimpleTime(200), // st et 55 ).String()).To(Equal("contain")) 56 }) 57 }) 58 Context("overlap", func() { 59 It("returns correct values", func() { 60 Expect(relationship( 61 testing.SimpleTime(100), testing.SimpleTime(200), // t1 t2 62 testing.SimpleTime(90), testing.SimpleTime(110), // st et 63 ).String()).To(Equal("overlap")) 64 Expect(relationship( 65 testing.SimpleTime(100), testing.SimpleTime(200), // t1 t2 66 testing.SimpleTime(190), testing.SimpleTime(210), // st et 67 ).String()).To(Equal("overlap")) 68 }) 69 }) 70 Context("outside", func() { 71 It("returns correct values", func() { 72 Expect(relationship( 73 testing.SimpleTime(100), testing.SimpleTime(200), // t1 t2 74 testing.SimpleTime(90), testing.SimpleTime(100), // st et 75 ).String()).To(Equal("outside")) 76 Expect(relationship( 77 testing.SimpleTime(100), testing.SimpleTime(200), // t1 t2 78 testing.SimpleTime(80), testing.SimpleTime(90), // st et 79 ).String()).To(Equal("outside")) 80 Expect(relationship( 81 testing.SimpleTime(100), testing.SimpleTime(200), // t1 t2 82 testing.SimpleTime(200), testing.SimpleTime(210), // st et 83 ).String()).To(Equal("outside")) 84 Expect(relationship( 85 testing.SimpleTime(100), testing.SimpleTime(200), // t1 t2 86 testing.SimpleTime(210), testing.SimpleTime(220), // st et 87 ).String()).To(Equal("outside")) 88 }) 89 }) 90 }) 91 })