草庐IT

loop_test

全部标签

loops - 指针 slice 和循环

这个问题在这里已经有了答案:UsingPointersinaforloop(2个答案)关闭4年前。我想这个问题问了好几次,但我还是很困惑:我有以下代码:typeobjstruct{s*string}varcmdsP=[]*string{stringPointer("create"),stringPointer("delete"),stringPointer("update"),}varcmds=[]string{"create","delete","update",}//[]*stringfuncloop1(){slice:=make([]obj,0,0)for_,cmd:=range

loops - 指针 slice 和循环

这个问题在这里已经有了答案:UsingPointersinaforloop(2个答案)关闭4年前。我想这个问题问了好几次,但我还是很困惑:我有以下代码:typeobjstruct{s*string}varcmdsP=[]*string{stringPointer("create"),stringPointer("delete"),stringPointer("update"),}varcmds=[]string{"create","delete","update",}//[]*stringfuncloop1(){slice:=make([]obj,0,0)for_,cmd:=range

eclipse - 如何在eclipse IDE中执行go test文件

如何在goeclipseIDE中创建eclipse启动文件来执行测试文件或运行配置 最佳答案 这是待定的增强功能:issue5Iwasthinkingmorealongthelineofaddingamenuitem("Testgoapplication")inthe"runas"contextmenu.RightnowifIselectagotestfileandclick"Rungoapplication"fromthe"runas"contextmenunothingisexecuted(nomain).A"Testgoapp

eclipse - 如何在eclipse IDE中执行go test文件

如何在goeclipseIDE中创建eclipse启动文件来执行测试文件或运行配置 最佳答案 这是待定的增强功能:issue5Iwasthinkingmorealongthelineofaddingamenuitem("Testgoapplication")inthe"runas"contextmenu.RightnowifIselectagotestfileandclick"Rungoapplication"fromthe"runas"contextmenunothingisexecuted(nomain).A"Testgoapp

c - SIGTRAP : trace trap error in Golang wrapping C library, 但仅在运行 go test 时

我已经设置了一个最小的代码库repo来复制错误并尽可能清楚地解释这个错误:https://github.com/soroushjp/go_wrapper_c_err我目前正在做一个使用Go包进行ECDSA签名的项目go-secp256k1包装Csecp256k1library.如果我通过导入直接使用go-secp256k1中的函数(如在main.go中所见),它工作正常。所以在repo中,运行main.go效果很好,并打印出一个公钥。所以这是一个奇怪的错误:如果我尝试使用go-secp256k1为一个包编写一个测试,我会收到一个奇怪的错误。要复制,请运行:gotestgithub.co

c - SIGTRAP : trace trap error in Golang wrapping C library, 但仅在运行 go test 时

我已经设置了一个最小的代码库repo来复制错误并尽可能清楚地解释这个错误:https://github.com/soroushjp/go_wrapper_c_err我目前正在做一个使用Go包进行ECDSA签名的项目go-secp256k1包装Csecp256k1library.如果我通过导入直接使用go-secp256k1中的函数(如在main.go中所见),它工作正常。所以在repo中,运行main.go效果很好,并打印出一个公钥。所以这是一个奇怪的错误:如果我尝试使用go-secp256k1为一个包编写一个测试,我会收到一个奇怪的错误。要复制,请运行:gotestgithub.co

testing - 如何用 Go 测试这个简单的方法?

我正在编写一些单元测试,但我一直在为以下方法编写测试:func(database*Database)FindUnusedKey()string{count:=0possibleKey:=helpers.RandomString(helpers.Config.KeySize)fordatabase.DoesKeyExist(possibleKey){possibleKey=helpers.RandomString(helpers.Config.KeySize+uint8(count/10))count++}returnpossibleKey}我想要一个测试,其中helpers.Rando

testing - 如何用 Go 测试这个简单的方法?

我正在编写一些单元测试,但我一直在为以下方法编写测试:func(database*Database)FindUnusedKey()string{count:=0possibleKey:=helpers.RandomString(helpers.Config.KeySize)fordatabase.DoesKeyExist(possibleKey){possibleKey=helpers.RandomString(helpers.Config.KeySize+uint8(count/10))count++}returnpossibleKey}我想要一个测试,其中helpers.Rando

unit-testing - 我可以期望(要求)go 测试失败吗?

在我使用的其他测试框架中,当编写测试助手时,能够自动测试它们是很好的,即测试它们是否通过以及是否失败。让我使用以下帮助程序(实际上要复杂得多):funcIsRedirect(t*testing.T,codeint){assert.True(t,code>=300)assert.True(t,code当然,我可以写:funcTestIsRedirect(t*testing.T){IsRedirect(t,http.StatusSeeOther)}但我也想写这样的东西:funcTestNotRedirect(t*testing.T){t.RequireFailure()IsRedirect

unit-testing - 我可以期望(要求)go 测试失败吗?

在我使用的其他测试框架中,当编写测试助手时,能够自动测试它们是很好的,即测试它们是否通过以及是否失败。让我使用以下帮助程序(实际上要复杂得多):funcIsRedirect(t*testing.T,codeint){assert.True(t,code>=300)assert.True(t,code当然,我可以写:funcTestIsRedirect(t*testing.T){IsRedirect(t,http.StatusSeeOther)}但我也想写这样的东西:funcTestNotRedirect(t*testing.T){t.RequireFailure()IsRedirect