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

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

表驅(qū)動的文件創(chuàng)建測試

表驅(qū)動的文件創(chuàng)建測試

Go
開心每一天1111 2021-04-06 13:14:50
我從@volker得到了一個有關(guān)表驅(qū)動測試的示例,如下所示,但是目前我錯過了我應(yīng)該在真實測試中放入的內(nèi)容,該測試使用的是字節(jié),目前我不確定要在args和中放入什么expected []byte,例如,我想檢查一下在文件中存在2 new line然后application輸入,我該如何做而無需創(chuàng)建真實文件并對其進(jìn)行解析?type Models struct {    name        string    vtype       string    contentType string}func setFile(file io.Writer, appStr Models) {    fmt.Fprint(file, "1.0")    fmt.Fprint(file, "Created-By: application generation process")    for _, mod := range appStr.Modules {        fmt.Fprint(file, "\n")        fmt.Fprint(file, "\n")        fmt.Fprint(file,  appStr.vtype) //"userApp"        fmt.Fprint(file, "\n")        fmt.Fprint(file, appStr.name) //"applicationValue"        fmt.Fprint(file, "\n")        fmt.Fprint(file, appStr.contentType)//"ContentType"    }}func Test_setFile(t *testing.T) {    type args struct {        appStr models.App    }    var tests []struct {        name string        args args        expected []byte   }    for _, tt := range tests {        t.Run(tt.name, func(t *testing.T) {            b := &bytes.Buffer{}            setFile(b, tt.args.AppStr)            if !bytes.Equal(b.Bytes(), tt.expected) {                t.Error("somewhat bad happen")            }        })    }}我閱讀并理解了以下示例,但不了解字節(jié)和文件 https://medium.com/@virup/how-to-write-concise-tests-table-driven-tests-ed672c502ae4
查看完整描述

1 回答

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

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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