当前位置: 首页>>代码示例>>Golang>>正文


Golang assert.New函数代码示例

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


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


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