From ad60b3f368daf380ed6dc2e724535c47c57d181a Mon Sep 17 00:00:00 2001 From: ChillerDragon Date: Sun, 2 Jun 2024 09:41:00 +0800 Subject: [PATCH] Add sample test --- README.md | 7 +++++++ teeworlds.go | 2 +- teeworlds_test.go | 16 ++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 teeworlds_test.go diff --git a/README.md b/README.md index 537cdc8..ccba104 100644 --- a/README.md +++ b/README.md @@ -4,3 +4,10 @@ A client side network protocol implementation of the game teeworlds. WORK IN PROGRESS + +## tests + +``` +go test +``` + diff --git a/teeworlds.go b/teeworlds.go index b6ea3ba..efe33c2 100644 --- a/teeworlds.go +++ b/teeworlds.go @@ -1,4 +1,4 @@ -package main +package teeworlds import ( "bufio" diff --git a/teeworlds_test.go b/teeworlds_test.go new file mode 100644 index 0000000..f0e9727 --- /dev/null +++ b/teeworlds_test.go @@ -0,0 +1,16 @@ +package teeworlds + +import ( + "testing" +) + +func TestIsCtrlMsg(t *testing.T) { + data := []byte{0x04, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x04} + + got := isCtrlMsg(data) + want := true + + if got != want { + t.Errorf("got %t, wanted %t", got, want) + } +}