From 06a4ff4897146bb7ea0b78798f594735e07f3df0 Mon Sep 17 00:00:00 2001 From: sterlingdeng Date: Sun, 24 Nov 2024 13:47:30 -0800 Subject: [PATCH] add test --- pkg/gcc/arrival_group_accumulator_test.go | 60 +++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/pkg/gcc/arrival_group_accumulator_test.go b/pkg/gcc/arrival_group_accumulator_test.go index be48962..25d87c0 100644 --- a/pkg/gcc/arrival_group_accumulator_test.go +++ b/pkg/gcc/arrival_group_accumulator_test.go @@ -156,6 +156,66 @@ func TestArrivalGroupAccumulator(t *testing.T) { }, }, }, + { + name: "newGroupBecauseOfInterDepartureTime", + log: []cc.Acknowledgment{ + { + SequenceNumber: 0, + Departure: time.Time{}, + Arrival: time.Time{}.Add(4 * time.Millisecond), + }, + { + SequenceNumber: 1, + Departure: time.Time{}.Add(3 * time.Millisecond), + Arrival: time.Time{}.Add(4 * time.Millisecond), + }, + { + SequenceNumber: 2, + Departure: time.Time{}.Add(6 * time.Millisecond), + Arrival: time.Time{}.Add(10 * time.Millisecond), + }, + { + SequenceNumber: 3, + Departure: time.Time{}.Add(9 * time.Millisecond), + Arrival: time.Time{}.Add(10 * time.Millisecond), + }, + triggerNewGroupElement, + }, + exp: []arrivalGroup{ + { + packets: []cc.Acknowledgment{ + { + SequenceNumber: 0, + Departure: time.Time{}, + Arrival: time.Time{}.Add(4 * time.Millisecond), + }, + { + SequenceNumber: 1, + Departure: time.Time{}.Add(3 * time.Millisecond), + Arrival: time.Time{}.Add(4 * time.Millisecond), + }, + }, + departure: time.Time{}, + arrival: time.Time{}.Add(4 * time.Millisecond), + }, + { + packets: []cc.Acknowledgment{ + { + SequenceNumber: 2, + Departure: time.Time{}.Add(6 * time.Millisecond), + Arrival: time.Time{}.Add(10 * time.Millisecond), + }, + { + SequenceNumber: 3, + Departure: time.Time{}.Add(9 * time.Millisecond), + Arrival: time.Time{}.Add(10 * time.Millisecond), + }, + }, + departure: time.Time{}.Add(6 * time.Millisecond), + arrival: time.Time{}.Add(10 * time.Millisecond), + }, + }, + }, } for _, tc := range cases {