From 43622091fed0a47c6b3ce0b4be9358d6c48033a3 Mon Sep 17 00:00:00 2001 From: Woody Wu Date: Wed, 10 Oct 2018 11:21:51 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E6=B7=BB=E5=8A=A0=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main_test.go | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 main_test.go diff --git a/main_test.go b/main_test.go new file mode 100644 index 0000000..4f1bae7 --- /dev/null +++ b/main_test.go @@ -0,0 +1,59 @@ +package main + +import ( + "testing" +) + +func Test_get_weekday(t *testing.T) { + type args struct { + name string + } + tests := []struct { + name string + args args + want string + }{ + {"1", args{"Monday"}, "周一"}, + {"2", args{"Tuesday"}, "周二"}, + {"3", args{"Wednesday"}, "周三"}, + {"4", args{"Thursday"}, "周四"}, + {"5", args{"Friday"}, "周五"}, + {"6", args{"Saturday"}, "周六"}, + {"7", args{"Sunday"}, "周日"}, + {"8", args{""}, ""}, + {"9", args{"abc"}, ""}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := get_weekday(tt.args.name); got != tt.want { + t.Errorf("get_weekday() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_get_message(t *testing.T) { + type args struct { + name string + } + tests := []struct { + name string + args args + want string + want1 string + }{ + {"1", args{"周一"}, "周一", "么么叽,订外卖啦~~"}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, got1 := get_message(tt.args.name) + if got != tt.want { + t.Errorf("get_message() got = %v, want %v", got, tt.want) + } + if got1 != tt.want1 { + t.Errorf("get_message() got1 = %v, want %v", got1, tt.want1) + } + }) + } +} +