第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 testing.T 作為匿名結(jié)構(gòu)字段:

使用 testing.T 作為匿名結(jié)構(gòu)字段:

Go
富國滬深 2021-11-01 16:31:44
我正在嘗試解決Go 中的Karate Chop kata 作為練習(xí),并在我的測試用例中遇到了這個編譯器錯誤:調(diào)用 this.T.common.Fail 的參數(shù)太多我testing.T用額外的方法包裝成一個結(jié)構(gòu)體,作為一個匿名結(jié)構(gòu)體字段:package mainimport (    "fmt"    "testing")type assertions struct {    *testing.T}func (this assertions) assert_equal(expected int, actual int) {    if (expected != actual) {        this.Fail(fmt.Sprintf("Failed asserting that %v is %v", actual, expected));    }}func TestChop(t *testing.T) {  test := assertions{t}  test.assert_equal(-1, Chop(3, []int{}))  test.assert_equal(-1, Chop(3, []int{1}))  ...}我希望this.Fail調(diào)用帶有字符串參數(shù)Fail()的匿名testing.T結(jié)構(gòu)字段。為什么不是這種情況,它this.T.common.Fail來自哪里?我common在testing包文檔中找不到任何參考。
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 163 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號