hll1213181368 commented on PR #335:
URL: 
https://github.com/apache/kvrocks-controller/pull/335#issuecomment-3160023679

   func TestSlotRange_HasOverlap(t *testing.T) {
        type args struct {
                that SlotRange
        }
        tests := []struct {
                name       string
                slotRanges SlotRanges
                args       args
                want       bool
        }{
                {
                        name: "0-5 does not overlap 6-7",
                        slotRanges: SlotRanges{
                                {Start: 0, Stop: 5},
                        },
                        args: args{SlotRange{Start: 6, Stop: 7}},
                        want: false,
                },
                {
                        name: "0-5 does overlap 3-4",
                        slotRanges: SlotRanges{
                                {Start: 0, Stop: 5},
                        },
                        args: args{SlotRange{Start: 3, Stop: 4}},
                        want: true,
                },
                {
                        name: "0-5 does overlap 5-8",
                        slotRanges: SlotRanges{
                                {Start: 0, Stop: 5},
                        },
                        args: args{SlotRange{Start: 5, Stop: 8}},
                        want: true,
                },
                {
                        name: "0-5 does overlap 4-8",
                        slotRanges: SlotRanges{
                                {Start: 0, Stop: 5},
                        },
                        args: args{SlotRange{Start: 4, Stop: 8}},
                        want: true,
                },
                {
                        name: "0-100 does not overlap 101-150",
                        slotRanges: SlotRanges{
                                {Start: 0, Stop: 100},
                        },
                        args: args{SlotRange{Start: 101, Stop: 150}},
                        want: false,
                },
                {
                        name: "50-100 does overlap 30-50",
                        slotRanges: SlotRanges{
                                {Start: 50, Stop: 100},
                        },
                        args: args{SlotRange{Start: 30, Stop: 50}},
                        want: true,
                },
                {
                        name: "50-100 does overlap 50-51",
                        slotRanges: SlotRanges{
                                {Start: 50, Stop: 100},
                        },
                        args: args{SlotRange{Start: 50, Stop: 51}},
                        want: true,
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
                        if got := tt.slotRanges.HasOverlap(tt.args.that); got 
!= tt.want {
                                t.Errorf("SlotRange.HasOverlap() = %v, want 
%v", got, tt.want)
                        }
                })
        }
   }
   
   ---------------------------------------------------old function result------
   --- FAIL: TestSlotRange_HasOverlap (0.00s)
       --- FAIL: TestSlotRange_HasOverlap/0-5_does_not_overlap_6-7 (0.00s)
   
       --- PASS: TestSlotRange_HasOverlap/0-5_does_overlap_3-4 (0.00s)
       --- PASS: TestSlotRange_HasOverlap/0-5_does_overlap_5-8 (0.00s)
       --- PASS: TestSlotRange_HasOverlap/0-5_does_overlap_4-8 (0.00s)
       --- FAIL: TestSlotRange_HasOverlap/0-100_does_not_overlap_101-150 (0.00s)
   
       --- PASS: TestSlotRange_HasOverlap/50-100_does_overlap_30-50 (0.00s)
       --- PASS: TestSlotRange_HasOverlap/50-100_does_overlap_50-51 (0.00s)
   
   
   ---------------------------------------------------new function result------
   --- PASS: TestSlotRange_HasOverlap (0.00s)
       --- PASS: TestSlotRange_HasOverlap/0-5_does_not_overlap_6-7 (0.00s)
       --- PASS: TestSlotRange_HasOverlap/0-5_does_overlap_3-4 (0.00s)
       --- PASS: TestSlotRange_HasOverlap/0-5_does_overlap_5-8 (0.00s)
       --- PASS: TestSlotRange_HasOverlap/0-5_does_overlap_4-8 (0.00s)
       --- PASS: TestSlotRange_HasOverlap/0-100_does_not_overlap_101-150 (0.00s)
       --- PASS: TestSlotRange_HasOverlap/50-100_does_overlap_30-50 (0.00s)
       --- PASS: TestSlotRange_HasOverlap/50-100_does_overlap_50-51 (0.00s)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to