ソースを参照

add test file

zou.yingbin 3 年 前
コミット
66d2db58f3
1 ファイル変更158 行追加0 行削除
  1. 158 0
      models/ermcp3_test.go

+ 158 - 0
models/ermcp3_test.go

@@ -0,0 +1,158 @@
+/**
+* @Author  : zou.yingbin
+* @Create  : 2022/1/18 11:26
+* @Modify  : 2022/1/18 11:26
+* @note    :
+ */
+
+package models
+
+import "testing"
+
+func TestXHDeliveryGoods_filterSubEmpty(t *testing.T) {
+
+	tests := []struct {
+		name   string
+		args   []XHDeliveryGoods
+		wantLen int
+	}{
+		{
+			name: "01",
+			args: []XHDeliveryGoods{
+				{
+					AREAUSERID: 100,
+					WDLST: []XHWrstandard{},
+				},
+			},
+			wantLen: 0,
+		},
+		{
+			name: "02",
+			args: []XHDeliveryGoods{
+				{
+					AREAUSERID: 100,
+					WDLST: []XHWrstandard{
+						{
+							DELIVERYGOODSID: 1,
+						},
+					},
+				},
+			},
+			wantLen: 0,
+		},
+		{
+			name: "03",
+			args: []XHDeliveryGoods{
+				{
+					AREAUSERID: 100,
+					WDLST: []XHWrstandard{
+						{
+							DELIVERYGOODSID: 1,
+							MGLST: []XHMiddleGoods{
+								{
+									MIDDLEGOODSID: 2,
+								},
+							},
+						},
+					},
+				},
+			},
+			wantLen: 0,
+		},
+		{
+			name: "04",
+			args: []XHDeliveryGoods{
+				{
+					AREAUSERID: 100,
+					WDLST: []XHWrstandard{
+						{
+							DELIVERYGOODSID: 1,
+							MGLST: []XHMiddleGoods{
+								{
+									MIDDLEGOODSID: 2,
+									GPLST: []TBGoodsGroup{
+
+									},
+								},
+							},
+						},
+					},
+				},
+			},
+			wantLen: 0,
+		},
+		{
+			name: "05",
+			args: []XHDeliveryGoods{
+				{
+					AREAUSERID: 100,
+					WDLST: []XHWrstandard{
+						{
+							DELIVERYGOODSID: 1,
+							MGLST: []XHMiddleGoods{
+								{
+									MIDDLEGOODSID: 2,
+									GPLST: []TBGoodsGroup{
+										{
+											GOODSGROUPID: 1,
+											GDLST: []TBGoods{
+												{
+													GOODSID: 1001,
+												},
+											},
+										},
+									},
+								},
+							},
+						},
+					},
+				},
+			},
+			wantLen: 1,
+		},
+		{
+			name: "06",
+			args: []XHDeliveryGoods{
+				{
+					AREAUSERID: 100,
+					WDLST: []XHWrstandard{
+						{
+							WRSTANDARDID: 1,
+							MGLST: []XHMiddleGoods{
+								{
+									MIDDLEGOODSID: 2,
+									GPLST: []TBGoodsGroup{
+										{
+											GOODSGROUPID: 1,
+											GDLST: []TBGoods{
+												{
+													GOODSID: 1001,
+												},
+											},
+										},
+									},
+								},
+							},
+						},
+						{
+							WRSTANDARDID: 2,
+						},
+					},
+				},
+				{
+					AREAUSERID: 100,
+				},
+			},
+			wantLen: 1,
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			a := XHDeliveryGoods{}
+			tt.args = a.filterSubEmpty(tt.args)
+			if len(tt.args) != tt.wantLen {
+				t.Errorf("%v result len:%v, want:%v", tt.name, len(tt.args), tt.wantLen)
+			}
+		})
+	}
+}