-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ken Schneider <ken.schneider@datadoghq.com>
- Loading branch information
1 parent
0e91f97
commit ec7a40f
Showing
2 changed files
with
66 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
//go:build windows | ||
// +build windows | ||
|
||
package probing | ||
|
||
import "testing" | ||
|
||
func TestGetMessageLength(t *testing.T) { | ||
tests := []struct { | ||
description string | ||
pinger *Pinger | ||
expected int | ||
}{ | ||
{ | ||
description: "IPv4 total size < 2048", | ||
pinger: &Pinger{ | ||
Size: 24, // default size | ||
ipv4: true, | ||
}, | ||
expected: 2048, | ||
}, | ||
{ | ||
description: "IPv4 total size > 2048", | ||
pinger: &Pinger{ | ||
Size: 1993, // 2048 - 2 * (ipv4.HeaderLen + 8) + 1 | ||
ipv4: true, | ||
}, | ||
expected: 2049, | ||
}, | ||
{ | ||
description: "IPv6 total size < 2048", | ||
pinger: &Pinger{ | ||
Size: 24, | ||
ipv4: false, | ||
}, | ||
expected: 2048, | ||
}, | ||
{ | ||
description: "IPv6 total size > 2048", | ||
pinger: &Pinger{ | ||
Size: 1953, // 2048 - 2 * (ipv6.HeaderLen + 8) + 1 | ||
ipv4: false, | ||
}, | ||
expected: 2049, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.description, func(t *testing.T) { | ||
actual := tt.pinger.getMessageLength() | ||
if tt.expected != actual { | ||
t.Fatalf("unexpected message length, expected: %d, actual %d", tt.expected, actual) | ||
} | ||
}) | ||
} | ||
} |