Skip to content

Conversation

@hll1213181368
Copy link
Contributor

Fix HasOverlap function

@git-hulk
Copy link
Member

git-hulk commented Aug 5, 2025

@hll1213181368 Could you please add a test case for this issue?

@hll1213181368
Copy link
Contributor Author

@git-hulk I have add a test case for this issue

@git-hulk
Copy link
Member

git-hulk commented Aug 5, 2025

@hll1213181368 Thanks for your fix.

@codecov-commenter
Copy link

codecov-commenter commented Aug 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 47.16%. Comparing base (6c56470) to head (c805d3f).
⚠️ Report is 79 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable     #335      +/-   ##
============================================
+ Coverage     43.38%   47.16%   +3.77%     
============================================
  Files            37       45       +8     
  Lines          2971     4425    +1454     
============================================
+ Hits           1289     2087     +798     
- Misses         1544     2129     +585     
- Partials        138      209      +71     
Flag Coverage Δ
unittests 47.16% <100.00%> (+3.77%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@git-hulk
Copy link
Member

git-hulk commented Aug 5, 2025

@hll1213181368 I didn't find any new cases in this PR. Did I miss anything?

@hll1213181368
Copy link
Contributor Author

@git-hulk I directly modified the slot_test.go of TestSlotRange_HasOverlap function. The previous function in testcase 1 not pass failed.

@git-hulk
Copy link
Member

git-hulk commented Aug 6, 2025

@git-hulk I directly modified the slot_test.go of TestSlotRange_HasOverlap function. The previous function in testcase 1 not pass failed.

Sorry, I didn't get your point entirely. Do you mean the first test case should be failed but now is passed?

@hll1213181368
Copy link
Contributor Author

hll1213181368 commented Aug 6, 2025

@git-hulk this is my modify test case.

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------
=== RUN TestSlotRange_HasOverlap
=== RUN TestSlotRange_HasOverlap/0-5_does_not_overlap_6-7
slot_test.go:365: SlotRange.HasOverlap() = true, want false
=== RUN TestSlotRange_HasOverlap/0-5_does_overlap_3-4
=== RUN TestSlotRange_HasOverlap/0-5_does_overlap_5-8
=== RUN TestSlotRange_HasOverlap/0-5_does_overlap_4-8
=== RUN TestSlotRange_HasOverlap/0-100_does_not_overlap_101-150
slot_test.go:365: SlotRange.HasOverlap() = true, want false
=== RUN TestSlotRange_HasOverlap/50-100_does_overlap_30-50
=== RUN TestSlotRange_HasOverlap/50-100_does_overlap_50-51
--- 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)

FAIL

---------------------------------------------------new function result------
=== RUN TestSlotRange_HasOverlap
=== RUN TestSlotRange_HasOverlap/0-5_does_not_overlap_6-7
=== RUN TestSlotRange_HasOverlap/0-5_does_overlap_3-4
=== RUN TestSlotRange_HasOverlap/0-5_does_overlap_5-8
=== RUN TestSlotRange_HasOverlap/0-5_does_overlap_4-8
=== RUN TestSlotRange_HasOverlap/0-100_does_not_overlap_101-150
=== RUN TestSlotRange_HasOverlap/50-100_does_overlap_30-50
=== RUN TestSlotRange_HasOverlap/50-100_does_overlap_50-51
--- 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)
PASS

@git-hulk git-hulk changed the title Fix SlotRanges class HasOverlap function Fix HasOverlap might return the wrong result Aug 6, 2025
@git-hulk git-hulk merged commit 431c824 into apache:unstable Aug 6, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants