diff options
| author | mo khan <mo.khan@gmail.com> | 2019-10-19 16:01:23 -0600 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2019-10-19 16:01:23 -0600 |
| commit | 9b791a5cd600701c99d804557d9e2395f6d07595 (patch) | |
| tree | 59b6ab3cc340881e05fbf25d53c61fd990d30389 | |
| parent | 57d4f8ae76b7ff7c1bd71df678d39b7670b260f5 (diff) | |
Add a unit test
| -rw-r--r-- | hello.go | 6 | ||||
| -rw-r--r-- | hello_test.go | 12 |
2 files changed, 17 insertions, 1 deletions
@@ -2,6 +2,10 @@ package main import "fmt" +func Hello() string { + return "Hello, world" +} + func main() { - fmt.Println("Hello, world") + fmt.Println(Hello()) } diff --git a/hello_test.go b/hello_test.go new file mode 100644 index 0000000..283ada8 --- /dev/null +++ b/hello_test.go @@ -0,0 +1,12 @@ +package main + +import "testing" + +func TestHello(t *testing.T) { + got := Hello() + want := "Hello, world" + + if got != want { + t.Errorf("got %q want %q", got, want) + } +} |
