package main import "testing" func TestNoSpaceCompare(t *testing.T) { testCases := []struct { a, b string ok bool }{ {"", "", true}, {"x", "", false}, {"", "x", false}, {"x ", "x", true}, {" x", "x", true}, {"x x", "xx", true}, {"x x x", "x", false}, } for _, tc := range testCases { t.Run(tc.a+"?"+tc.b, func(t *testing.T) { ok := noSpaceCompare(tc.a, tc.b) if ok != tc.ok { t.Errorf("got %v; want %v", ok, tc.ok) } }) } }