From bef0c7d77e17141db87f5ef24dc59941a13c94f5 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Tue, 24 Jul 2018 15:54:35 +0200 Subject: no space compare --- main_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 main_test.go (limited to 'main_test.go') diff --git a/main_test.go b/main_test.go new file mode 100644 index 0000000..51002d7 --- /dev/null +++ b/main_test.go @@ -0,0 +1,26 @@ +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) + } + }) + } +} -- cgit v1.2.3