• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang assert.New函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/assertgo/assert.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了New函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestReaderShouldReadFloatSliceWithTowValues

func TestReaderShouldReadFloatSliceWithTowValues(t *testing.T) {
	assert := assert.New(t)
	reader := strings.NewReader("4 5")
	read, _ := Read(reader)
	assert.That(read[0]).IsEqualTo(float64(4))
	assert.That(read[1]).IsEqualTo(float64(5))
}
开发者ID:OrdonTeam,项目名称:PTTW,代码行数:7,代码来源:reader_test.go


示例2: TestNormalizerShouldNormalizeDifferentElements

func TestNormalizerShouldNormalizeDifferentElements(t *testing.T) {
	assert := assert.New(t)
	slice := []float64{3, 6}
	normalized := Normalize(slice)
	assert.That(normalized[0]).IsEqualTo(float64(0.5))
	assert.That(normalized[1]).IsEqualTo(float64(1))
}
开发者ID:OrdonTeam,项目名称:PTTW,代码行数:7,代码来源:normalizer_test.go


示例3: TestListTemplatesSortedByName

func TestListTemplatesSortedByName(t *testing.T) {
	assert := assert.New(t)
	output := new(bytes.Buffer)
	httpmock.Activate()
	defer httpmock.DeactivateAndReset()
	httpmock.RegisterResponder("GET", "https://api.github.com/repos/github/gitignore/contents/",
		httpmock.NewStringResponder(200, `[
  {
    "name": "C.gitignore"
  },
  {
    "name": "A.gitignore"
  }
]
`))
	httpmock.RegisterResponder("GET", "https://api.github.com/repos/github/gitignore/contents/Global",
		httpmock.NewStringResponder(200, `[
  {
    "name": "B.gitignore"
  }
]
`))

	app([]string{"chtignore", "list"}, output)

	assert.ThatString(output.String()).IsEqualTo(fmt.Sprintln("A, B, C, JetBrains-build"))
}
开发者ID:jcgay,项目名称:chtignore,代码行数:27,代码来源:chtignore_test.go


示例4: TestDisplayVersion

func TestDisplayVersion(t *testing.T) {
	assert := assert.New(t)
	output := new(bytes.Buffer)

	app([]string{"chtignore", "--version"}, output)

	assert.ThatString(output.String()).IsEqualTo(fmt.Sprintln("chtignore version unknown-snapshot"))
}
开发者ID:jcgay,项目名称:chtignore,代码行数:8,代码来源:chtignore_test.go


示例5: TestAlgorithmShouldRun

func TestAlgorithmShouldRun(t *testing.T) {
	assert := assert.New(t)
	reader := strings.NewReader("1 1 1 1")
	noise := arrayBasedRandomProvider([]float64{1, 1, 1, 1})
	writer := bytes.Buffer{}
	Algorithm(reader, &writer, 0, noise)
	assert.That(writer.String()).IsEqualTo("2 2 2 2\n")
}
开发者ID:OrdonTeam,项目名称:PTTW,代码行数:8,代码来源:algorithm_test.go


示例6: TestSumShouldSumWithSNRAndMaxAmplitudeOfSignal

func TestSumShouldSumWithSNRAndMaxAmplitudeOfSignal(t *testing.T) {
	assert := assert.New(t)
	first := []float64{2}
	second := []float64{-6}
	sum := AddSignalToNoise(first, second, 20)
	assert.That((sum[0]-2)*(sum[0]-2) < 0.4000001).IsEqualTo(true)
	assert.That((sum[0]-2)*(sum[0]-2) > 0.3999999).IsEqualTo(true)
}
开发者ID:OrdonTeam,项目名称:PTTW,代码行数:8,代码来源:signal_to_noise_test.go


示例7: TestSumShouldSumWithSNR

func TestSumShouldSumWithSNR(t *testing.T) {
	assert := assert.New(t)
	first := []float64{1}
	second := []float64{1}
	sum := AddSignalToNoise(first, second, 20)
	assert.That((sum[0]-1)*(sum[0]-1) < 0.1000001).IsEqualTo(true)
	assert.That((sum[0]-1)*(sum[0]-1) > 0.0999999).IsEqualTo(true)
}
开发者ID:OrdonTeam,项目名称:PTTW,代码行数:8,代码来源:signal_to_noise_test.go


示例8: TestNormalizerShouldNormalizeWithNegativeElements

func TestNormalizerShouldNormalizeWithNegativeElements(t *testing.T) {
	assert := assert.New(t)
	slice := []float64{3, 6, -12}
	normalized := Normalize(slice)
	assert.That(normalized[0]).IsEqualTo(float64(0.25))
	assert.That(normalized[1]).IsEqualTo(float64(0.5))
	assert.That(normalized[2]).IsEqualTo(float64(-1))
}
开发者ID:OrdonTeam,项目名称:PTTW,代码行数:8,代码来源:normalizer_test.go


示例9: TestSumShouldSum

func TestSumShouldSum(t *testing.T) {
	assert := assert.New(t)
	first := []float64{0.5, 1, -1}
	second := []float64{-0.5, -1, 1}
	sum := AddSignalToNoise(first, second, 0)
	assert.That(sum[0]).IsEqualTo(float64(0))
	assert.That(sum[1]).IsEqualTo(float64(0))
	assert.That(sum[2]).IsEqualTo(float64(0))
}
开发者ID:OrdonTeam,项目名称:PTTW,代码行数:9,代码来源:signal_to_noise_test.go


示例10: TestCountCorrectColorAndPosition

func TestCountCorrectColorAndPosition(t *testing.T) {
	assert := assert.New(t)

	noPegIsCorrectPositionOrColor := CountCorrectColorAndPosition([...]string{"B", "B", "B", "B"}, [...]string{"N", "N", "N", "N"})
	assert.That(noPegIsCorrectPositionOrColor).IsEqualTo(0)

	onePegIsCorrectPositionAndColor := CountCorrectColorAndPosition([...]string{"B", "B", "B", "B"}, [...]string{"B", "N", "N", "N"})
	assert.That(onePegIsCorrectPositionAndColor).IsEqualTo(1)

	allPegsAreCorrectPositionAndColor := CountCorrectColorAndPosition([...]string{"B", "B", "B", "B"}, [...]string{"B", "B", "B", "B"})
	assert.That(allPegsAreCorrectPositionAndColor).IsEqualTo(4)
}
开发者ID:dgageot,项目名称:sandbox,代码行数:12,代码来源:mastermind_test.go


示例11: TestFooBarQix

func TestFooBarQix(t *testing.T) {
	assert := assert.New(t)

	assert.That(foobarqix(1)).IsEqualTo("1")
	assert.That(foobarqix(2)).IsEqualTo("2")
	assert.That(foobarqix(3)).IsEqualTo("FooFoo")
	assert.That(foobarqix(5)).IsEqualTo("BarBar")
	assert.That(foobarqix(7)).IsEqualTo("QixQix")
	assert.That(foobarqix(9)).IsEqualTo("Foo")
	assert.That(foobarqix(10)).IsEqualTo("Bar")
	assert.That(foobarqix(14)).IsEqualTo("Qix")
	assert.That(foobarqix(15)).IsEqualTo("FooBarBar")
}
开发者ID:dgageot,项目名称:sandbox,代码行数:13,代码来源:foobarqix_test.go


示例12: TestGetJetBrainsBuildTemplate

func TestGetJetBrainsBuildTemplate(t *testing.T) {
	assert := assert.New(t)
	output := new(bytes.Buffer)
	httpmock.Activate()
	defer httpmock.DeactivateAndReset()
	httpmock.RegisterResponder("GET", "https://raw.githubusercontent.com/github/gitignore/38d6cac990a82a1f7814571634e08295086763b5/Global/JetBrains.gitignore",
		httpmock.NewStringResponder(200, ".idea"))

	app([]string{"chtignore", "JetBrains-build"}, output)

	assert.ThatString(output.String()).IsEqualTo(
		`# JetBrains-build
.idea
`)
}
开发者ID:jcgay,项目名称:chtignore,代码行数:15,代码来源:chtignore_test.go


示例13: TestTemplateStartWithUpperCase

func TestTemplateStartWithUpperCase(t *testing.T) {
	assert := assert.New(t)
	output := new(bytes.Buffer)
	httpmock.Activate()
	defer httpmock.DeactivateAndReset()
	httpmock.RegisterResponder("GET", templateUrl("Java.gitignore"),
		httpmock.NewStringResponder(200, "*.class"))

	app([]string{"chtignore", "java"}, output)

	assert.ThatString(output.String()).IsEqualTo(
		`# Java
*.class
`)
}
开发者ID:jcgay,项目名称:chtignore,代码行数:15,代码来源:chtignore_test.go


示例14: TestGetMultipleTemplates

func TestGetMultipleTemplates(t *testing.T) {
	assert := assert.New(t)
	output := new(bytes.Buffer)
	httpmock.Activate()
	defer httpmock.DeactivateAndReset()
	httpmock.RegisterResponder("GET", templateUrl("Java.gitignore"),
		httpmock.NewStringResponder(200, "*.class"))
	httpmock.RegisterResponder("GET", templateUrl("Go.gitignore"),
		httpmock.NewStringResponder(200, "*.o"))

	app([]string{"chtignore", "Java", "Go"}, output)

	assert.ThatString(output.String()).
		Contains(fmt.Sprintln("# Java\n*.class")).
		Contains(fmt.Sprintln("# Go\n*.o"))
}
开发者ID:jcgay,项目名称:chtignore,代码行数:16,代码来源:chtignore_test.go


示例15: TestGetUniqueGlobalTemplate

func TestGetUniqueGlobalTemplate(t *testing.T) {
	assert := assert.New(t)
	output := new(bytes.Buffer)
	httpmock.Activate()
	defer httpmock.DeactivateAndReset()
	httpmock.RegisterResponder("GET", templateUrl("Vagrant.gitignore"),
		httpmock.NewStringResponder(404, "Not Found"))
	httpmock.RegisterResponder("GET", templateUrl("Global/Vagrant.gitignore"),
		httpmock.NewStringResponder(200, ".vagrant/"))

	app([]string{"chtignore", "Vagrant"}, output)

	assert.ThatString(output.String()).IsEqualTo(
		`# Vagrant
.vagrant/
`)
}
开发者ID:jcgay,项目名称:chtignore,代码行数:17,代码来源:chtignore_test.go


示例16: TestCountCorrectColorWrongPosition

func TestCountCorrectColorWrongPosition(t *testing.T) {
	assert := assert.New(t)

	noPegIsCorrectColor := CountCorrectColorWrongPosition([...]string{"B", "B", "B", "B"}, [...]string{"N", "N", "N", "N"})
	assert.That(noPegIsCorrectColor).IsEqualTo(0)

	onePegIsCorrectColorAndWrongPosition := CountCorrectColorWrongPosition([...]string{"V", "B", "B", "B"}, [...]string{"N", "V", "N", "N"})
	assert.That(onePegIsCorrectColorAndWrongPosition).IsEqualTo(1)

	ignoreAditionalPegsOfSameColor := CountCorrectColorWrongPosition([...]string{"V", "B", "B", "B"}, [...]string{"N", "V", "V", "N"})
	assert.That(ignoreAditionalPegsOfSameColor).IsEqualTo(1)

	ignorePegsWithCorrectColorAndPosition := CountCorrectColorWrongPosition([...]string{"V", "B", "B", "V"}, [...]string{"V", "V", "N", "N"})
	assert.That(ignorePegsWithCorrectColorAndPosition).IsEqualTo(1)

	recognizePegsAreCorrectColorsForMultipleColors := CountCorrectColorWrongPosition([...]string{"V", "R", "B", "B"}, [...]string{"R", "V", "N", "N"})
	assert.That(recognizePegsAreCorrectColorsForMultipleColors).IsEqualTo(2)
}
开发者ID:dgageot,项目名称:sandbox,代码行数:18,代码来源:mastermind_test.go


示例17: TestNormalizerShouldNormalizeSingleElement

func TestNormalizerShouldNormalizeSingleElement(t *testing.T) {
	assert := assert.New(t)
	slice := []float64{3}
	normalized := Normalize(slice)
	assert.That(normalized[0]).IsEqualTo(float64(1))
}
开发者ID:OrdonTeam,项目名称:PTTW,代码行数:6,代码来源:normalizer_test.go


示例18: TestHelpShouldSearchWholeParamsList

func TestHelpShouldSearchWholeParamsList(t *testing.T) {
	assert := assert.New(t)
	result := ShouldDisplayHelp([]string{"", "", "", "-help"})
	assert.ThatBool(result).IsTrue()
}
开发者ID:OrdonTeam,项目名称:PTTW,代码行数:5,代码来源:help_test.go


示例19: TestHelpShouldReturnFalseIsNotAskedForHelp

func TestHelpShouldReturnFalseIsNotAskedForHelp(t *testing.T) {
	assert := assert.New(t)
	result := ShouldDisplayHelp([]string{})
	assert.ThatBool(result).IsFalse()
}
开发者ID:OrdonTeam,项目名称:PTTW,代码行数:5,代码来源:help_test.go


示例20: TestMaxAbsShouldFindMaxFromMultipleElements

func TestMaxAbsShouldFindMaxFromMultipleElements(t *testing.T) {
	assert := assert.New(t)
	slice := []float64{3, 7, 2}
	max := MaxAbs(slice)
	assert.That(max).IsEqualTo(float64(7))
}
开发者ID:OrdonTeam,项目名称:PTTW,代码行数:6,代码来源:max_test.go



注:本文中的github.com/assertgo/assert.New函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang beedb.New函数代码示例发布时间:2022-05-24
下一篇:
Golang x.LogErr函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap