From 509c5063d66e8bbef4ec1def1c99c318be51aceb Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Thu, 25 Aug 2016 03:13:39 +0200 Subject: Initial import --- go/hello-world/hello_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 go/hello-world/hello_test.go (limited to 'go/hello-world/hello_test.go') diff --git a/go/hello-world/hello_test.go b/go/hello-world/hello_test.go new file mode 100644 index 0000000..3099d41 --- /dev/null +++ b/go/hello-world/hello_test.go @@ -0,0 +1,29 @@ +package hello + +import "testing" + +// Define a function HelloWorld(string) string. +// +// Also define a testVersion with a value that matches +// the targetTestVersion here. + +const targetTestVersion = 2 + +func TestHelloWorld(t *testing.T) { + tests := []struct { + name, expected string + }{ + {"", "Hello, World!"}, + {"Gopher", "Hello, Gopher!"}, + } + for _, test := range tests { + observed := HelloWorld(test.name) + if observed != test.expected { + t.Fatalf("HelloWorld(%s) = %v, want %v", test.name, observed, test.expected) + } + } + + if testVersion != targetTestVersion { + t.Fatalf("Found testVersion = %v, want %v", testVersion, targetTestVersion) + } +} -- cgit v1.2.3