From e5af060488a94b44fca5ec174557d5c6f000c8eb Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Thu, 12 Sep 2019 09:29:38 -0700 Subject: [PATCH] Add basic test in main_test and check it passes with 'go test' --- examples/testing/main_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 examples/testing/main_test.go diff --git a/examples/testing/main_test.go b/examples/testing/main_test.go new file mode 100644 index 0000000..e119fa0 --- /dev/null +++ b/examples/testing/main_test.go @@ -0,0 +1,20 @@ +package main + +import ( + "testing" +) + +func IntMin(a, b int) int { + if a < b { + return a + } else { + return b + } +} + +func TestIntMinBasic(t *testing.T) { + result := IntMin(2, -2) + if result != -2 { + t.Errorf("IntMin(2, -2) = %d; want -2", result) + } +}