广告点击添加

This commit is contained in:
谢宇宁
2026-10-29 16:39:28 +07:00
parent 3879f5a71c
commit bfc26aa5ab
12 changed files with 209 additions and 3 deletions
+24
View File
@@ -80,3 +80,27 @@ func TestBuildAppConfigVMIncludesValidAdvertisements(t *testing.T) {
t.Fatalf("DialogList[0] = %#v", got)
}
}
func TestAdvertisementClickTrackable(t *testing.T) {
cases := []struct {
ad Advertisement
wantID int64
trackable bool
}{
{Advertisement{ID: "1138200002", Location: 2}, 1138200002, true},
{Advertisement{ID: " 1138200012 ", Location: 12}, 1138200012, true},
{Advertisement{ID: "1138200003", Location: 0}, 1138200003, false},
{Advertisement{ID: "", Location: 3}, 0, false},
{Advertisement{ID: "0", Location: 3}, 0, false},
{Advertisement{ID: "-5", Location: 3}, 0, false},
{Advertisement{ID: "abc", Location: 3}, 0, false},
}
for _, tc := range cases {
if got := tc.ad.ClickID(); got != tc.wantID {
t.Fatalf("ClickID(%q) = %d, want %d", tc.ad.ID, got, tc.wantID)
}
if got := tc.ad.ClickTrackable(); got != tc.trackable {
t.Fatalf("ClickTrackable(%q, %d) = %v, want %v", tc.ad.ID, tc.ad.Location, got, tc.trackable)
}
}
}