From 6ff767265861e38485326f8f7fc1976744b8d3a7 Mon Sep 17 00:00:00 2001 From: Jean-Marc MEESSEN Date: Mon, 8 Jun 2020 07:40:19 +0200 Subject: [PATCH] testing unit tests --- cmd/callsign_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 cmd/callsign_test.go diff --git a/cmd/callsign_test.go b/cmd/callsign_test.go new file mode 100644 index 0000000..ab2a1df --- /dev/null +++ b/cmd/callsign_test.go @@ -0,0 +1,30 @@ +package cmd + +import "testing" + +func TestValidateCall(t *testing.T) { + type args struct { + sign string + } + tests := []struct { + name string + args args + //args string + wantCall string + wantErrorMsg string + }{ + {"Good call (simple)", args.String("on4kjm"), "ON4KJM", ""}, + {"Good call (suffix)", "on4kjm/p", "ON4KJM/P", ""}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + gotCall, gotErrorMsg := ValidateCall(tt.args.sign) + if gotCall != tt.wantCall { + t.Errorf("ValidateCall() gotCall = %v, want %v", gotCall, tt.wantCall) + } + if gotErrorMsg != tt.wantErrorMsg { + t.Errorf("ValidateCall() gotErrorMsg = %v, want %v", gotErrorMsg, tt.wantErrorMsg) + } + }) + } +}