github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/talks/2012/simple/test.go (about) 1 // +build OMIT 2 3 package main 4 5 import "strings" 6 7 import "testing" 8 9 func TestToUpper(t *testing.T) { 10 in := "loud noises" 11 want := "LOUD NOISES" 12 got := strings.ToUpper(in) 13 if got != want { 14 t.Errorf("ToUpper(%v) = %v, want %v", in, got, want) 15 } 16 } 17 18 func TestContains(t *testing.T) { 19 var tests = []struct { 20 str, substr string 21 expected bool 22 }{ 23 {"abc", "bc", true}, 24 {"abc", "bcd", false}, 25 {"abc", "", true}, 26 {"", "a", false}, 27 } 28 for _, ct := range tests { 29 if strings.Contains(ct.str, ct.substr) != ct.expected { 30 t.Errorf("Contains(%s, %s) = %v, want %v", 31 ct.str, ct.substr, !ct.expected, ct.expected) 32 } 33 } 34 }