mirror of
https://github.com/go-ping/ping.git
synced 2025-07-20 16:59:07 +00:00
fix tests
This commit is contained in:
parent
1c7ace28c4
commit
c939a03fb2
15
ping_test.go
15
ping_test.go
@ -3,7 +3,6 @@ package ping
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"net"
|
"net"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
@ -26,7 +25,7 @@ func TestProcessPacket(t *testing.T) {
|
|||||||
currentUUID := pinger.getCurrentTrackerUUID()
|
currentUUID := pinger.getCurrentTrackerUUID()
|
||||||
uuidEncoded, err := currentUUID.MarshalBinary()
|
uuidEncoded, err := currentUUID.MarshalBinary()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(fmt.Sprintf("unable to marshal UUID binary: %s", err))
|
t.Fatalf("unable to marshal UUID binary: %s", err)
|
||||||
}
|
}
|
||||||
data := append(timeToBytes(time.Now()), uuidEncoded...)
|
data := append(timeToBytes(time.Now()), uuidEncoded...)
|
||||||
if remainSize := pinger.Size - timeSliceLength - trackerLength; remainSize > 0 {
|
if remainSize := pinger.Size - timeSliceLength - trackerLength; remainSize > 0 {
|
||||||
@ -69,7 +68,7 @@ func TestProcessPacket_IgnoreNonEchoReplies(t *testing.T) {
|
|||||||
|
|
||||||
currentUUID, err := pinger.getCurrentTrackerUUID().MarshalBinary()
|
currentUUID, err := pinger.getCurrentTrackerUUID().MarshalBinary()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(fmt.Sprintf("unable to marshal UUID binary: %s", err))
|
t.Fatalf("unable to marshal UUID binary: %s", err)
|
||||||
}
|
}
|
||||||
data := append(timeToBytes(time.Now()), currentUUID...)
|
data := append(timeToBytes(time.Now()), currentUUID...)
|
||||||
if remainSize := pinger.Size - timeSliceLength - trackerLength; remainSize > 0 {
|
if remainSize := pinger.Size - timeSliceLength - trackerLength; remainSize > 0 {
|
||||||
@ -112,7 +111,7 @@ func TestProcessPacket_IDMismatch(t *testing.T) {
|
|||||||
|
|
||||||
currentUUID, err := pinger.getCurrentTrackerUUID().MarshalBinary()
|
currentUUID, err := pinger.getCurrentTrackerUUID().MarshalBinary()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(fmt.Sprintf("unable to marshal UUID binary: %s", err))
|
t.Fatalf("unable to marshal UUID binary: %s", err)
|
||||||
}
|
}
|
||||||
data := append(timeToBytes(time.Now()), currentUUID...)
|
data := append(timeToBytes(time.Now()), currentUUID...)
|
||||||
if remainSize := pinger.Size - timeSliceLength - trackerLength; remainSize > 0 {
|
if remainSize := pinger.Size - timeSliceLength - trackerLength; remainSize > 0 {
|
||||||
@ -154,7 +153,7 @@ func TestProcessPacket_TrackerMismatch(t *testing.T) {
|
|||||||
|
|
||||||
testUUID, err := uuid.New().MarshalBinary()
|
testUUID, err := uuid.New().MarshalBinary()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(fmt.Sprintf("unable to marshal UUID binary: %s", err))
|
t.Fatalf("unable to marshal UUID binary: %s", err)
|
||||||
}
|
}
|
||||||
data := append(timeToBytes(time.Now()), testUUID...)
|
data := append(timeToBytes(time.Now()), testUUID...)
|
||||||
if remainSize := pinger.Size - timeSliceLength - trackerLength; remainSize > 0 {
|
if remainSize := pinger.Size - timeSliceLength - trackerLength; remainSize > 0 {
|
||||||
@ -192,7 +191,7 @@ func TestProcessPacket_LargePacket(t *testing.T) {
|
|||||||
|
|
||||||
currentUUID, err := pinger.getCurrentTrackerUUID().MarshalBinary()
|
currentUUID, err := pinger.getCurrentTrackerUUID().MarshalBinary()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(fmt.Sprintf("unable to marshal UUID binary: %s", err))
|
t.Fatalf("unable to marshal UUID binary: %s", err)
|
||||||
}
|
}
|
||||||
data := append(timeToBytes(time.Now()), currentUUID...)
|
data := append(timeToBytes(time.Now()), currentUUID...)
|
||||||
if remainSize := pinger.Size - timeSliceLength - trackerLength; remainSize > 0 {
|
if remainSize := pinger.Size - timeSliceLength - trackerLength; remainSize > 0 {
|
||||||
@ -545,7 +544,7 @@ func BenchmarkProcessPacket(b *testing.B) {
|
|||||||
|
|
||||||
currentUUID, err := pinger.getCurrentTrackerUUID().MarshalBinary()
|
currentUUID, err := pinger.getCurrentTrackerUUID().MarshalBinary()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatal(fmt.Sprintf("unable to marshal UUID binary: %s", err))
|
b.Fatalf("unable to marshal UUID binary: %s", err)
|
||||||
}
|
}
|
||||||
data := append(timeToBytes(time.Now()), currentUUID...)
|
data := append(timeToBytes(time.Now()), currentUUID...)
|
||||||
if remainSize := pinger.Size - timeSliceLength - trackerLength; remainSize > 0 {
|
if remainSize := pinger.Size - timeSliceLength - trackerLength; remainSize > 0 {
|
||||||
@ -595,7 +594,7 @@ func TestProcessPacket_IgnoresDuplicateSequence(t *testing.T) {
|
|||||||
currentUUID := pinger.getCurrentTrackerUUID()
|
currentUUID := pinger.getCurrentTrackerUUID()
|
||||||
uuidEncoded, err := currentUUID.MarshalBinary()
|
uuidEncoded, err := currentUUID.MarshalBinary()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(fmt.Sprintf("unable to marshal UUID binary: %s", err))
|
t.Fatalf("unable to marshal UUID binary: %s", err)
|
||||||
}
|
}
|
||||||
data := append(timeToBytes(time.Now()), uuidEncoded...)
|
data := append(timeToBytes(time.Now()), uuidEncoded...)
|
||||||
if remainSize := pinger.Size - timeSliceLength - trackerLength; remainSize > 0 {
|
if remainSize := pinger.Size - timeSliceLength - trackerLength; remainSize > 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user