-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
720ab06
commit ddb6921
Showing
4 changed files
with
48 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ run: build | |
@./bin/bisturi | ||
|
||
test: | ||
@$$GO_EXECUTABLE_PATH test -v ./... | ||
@$$GO_EXECUTABLE_PATH test -v -race ./... |
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
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,41 @@ | ||
package sockets | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestHostToNetworkShort(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
host uint16 | ||
expected uint16 | ||
}{ | ||
{ | ||
name: "Little Endian to Big Endian 1", | ||
host: 0xff00, | ||
expected: 0x00ff, | ||
}, | ||
{ | ||
name: "Little Endian to Big Endian 2", | ||
host: 0xf00f, | ||
expected: 0x0ff0, | ||
}, | ||
{ | ||
name: "Little Endian to Big Endian 3", | ||
host: 0x0ff0, | ||
expected: 0xf00f, | ||
}, | ||
{ | ||
name: "Little Endian to Big Endian 4", | ||
host: 0xfff0, | ||
expected: 0xf0ff, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := hostToNetworkShort(tt.host); got != tt.expected { | ||
t.Errorf("expected %016b to become %016b: got %016b", tt.host, tt.expected, got) | ||
} | ||
}) | ||
} | ||
} |