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


Golang testutils.Cleanup函数代码示例

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


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

示例1: Test_prefixWithArticleUrlBase

func Test_prefixWithArticleUrlBase(t *testing.T) {
	slateUrl, _ := url.Parse("http://www.slate.com/articles/technology/bitwise/2015/08/windows_10_privacy_problems_here_s_how_bad_they_are_and_how_to_plug_them.html")
	type inputs struct {
		link       string
		articleUrl url.URL
	}
	tests := []struct {
		in   inputs
		want string
	}{
		{
			in: inputs{
				link:       "/content/dam/slate/articles/technology/bitwise/2015/08/150803_BIT_Windows10-10.png.CROP.original-original.png",
				articleUrl: *slateUrl,
			},
			want: "http://www.slate.com/content/dam/slate/articles/technology/bitwise/2015/08/150803_BIT_Windows10-10.png.CROP.original-original.png",
		},
	}

	for _, test := range tests {
		got := prefixWithArticleUrlBase(test.in.link, test.in.articleUrl)
		if !reflect.DeepEqual(test.want, got) {
			_, file, line, _ := runtime.Caller(0)
			fmt.Printf("%s:%d:\n\ncall prefixWithArticleUrlBase(%#v)\n\texp: %#v\n\n\tgot: %#v\n\n",
				filepath.Base(file), line, test.in, test.want, got)
			t.FailNow()
		}
	}
	testutils.Cleanup()

}
开发者ID:frankMilde,项目名称:rol,代码行数:31,代码来源:image_integration_test.go

示例2: Test_SpaceBeforeClosingBrackets_hasNoSpaceBeforeAndAfterBrackets_NoNewSpaceShouldBeAdded

func Test_SpaceBeforeClosingBrackets_hasNoSpaceBeforeAndAfterBrackets_NoNewSpaceShouldBeAdded(t *testing.T) {
	tests := testutils.ConversionTests{
		{
			In: `Test.
			Test. \emph{Test}Test
			
			Test`,
			Want: `Test.
			Test. \emph{Test}Test
			
			Test`,
		},
	}

	for _, test := range tests {
		got := SpaceBeforeClosingBrackets(test.In)
		if !reflect.DeepEqual(test.Want, got) {
			_, file, line, _ := runtime.Caller(0)
			fmt.Printf("%s:%d:\n\ncall SpaceBeforeClosingBrackets(%#v)\n\texp: %#v\n\n\tgot: %#v\n\n",
				filepath.Base(file), line, test.In, test.Want, got)
			t.FailNow()
		}
	}
	testutils.Cleanup()

}
开发者ID:frankMilde,项目名称:rol,代码行数:26,代码来源:strdel_test.go

示例3: Test_isMultiLined

func Test_isMultiLined(t *testing.T) {
	tests := []struct {
		in   string
		want bool
	}{
		{
			in:   `1234567890`,
			want: false,
		},
		{
			// test regular ASCII
			in:   "it is\nmulti-lined",
			want: true,
		},
		{
			// test regular ASCII
			in: `it is 
			multi-lined, too`,
			want: true,
		},
	}

	for _, test := range tests {
		got := IsMultiLined(test.in)
		if !reflect.DeepEqual(test.want, got) {
			_, file, line, _ := runtime.Caller(0)
			fmt.Printf("%s:%d:\n\ncall isMultiLined(%#v)\n\texp: %#v\n\n\tgot: %#v\n\n",
				filepath.Base(file), line, test.in, test.want, got)
			t.FailNow()
		}
	}
	testutils.Cleanup()
}
开发者ID:frankMilde,项目名称:rol,代码行数:33,代码来源:strmult_test.go

示例4: Test_BrHtmlTag

func Test_BrHtmlTag(t *testing.T) {
	tests := testutils.ConversionTests{
		{
			In: `a<br/>
			b<br/>
			c`,
			Want: `a \\ 
			b \\ 
			c`,
		},
		{
			In: `a<br>
			b<br>
			c`,
			Want: `a \\ 
			b \\ 
			c`,
		},
	}

	for _, test := range tests {
		got := BrHtmlTagToLatexLinebreak(test.In)
		if !reflect.DeepEqual(test.Want, got) {
			_, file, line, _ := runtime.Caller(0)
			fmt.Printf("%s:%d:\n\ncall BrHtmlTag(%#v)\n\texp: %#v\n\n\tgot: %#v\n\n",
				filepath.Base(file), line, test.In, test.Want, got)
			t.FailNow()
		}
	}
	testutils.Cleanup()

}
开发者ID:frankMilde,项目名称:rol,代码行数:32,代码来源:strtrans_test.go

示例5: Test_codeShouldHaveFullPageWidth

func Test_codeShouldHaveFullPageWidth(t *testing.T) {
	tests := []struct {
		in   string
		want bool
	}{
		{
			in:   `test`,
			want: false,
		},
		{ // has only 2 line but all are overlength so show as full width
			in: `
test adfas asj sadf jsadf jasdfj asdf jsad f
test asdf sdf sadf sdf sdf sadffdf ksadf sdsss`,
			want: false,
		},
		{ // has more 25% over line but only two lines
			in: `test
                         test  sd dddddddddddd`,
			want: false,
		},
		{
			in: `test1
test2 test3
test4`,
			want: false,
		},
		{
			in:   "",
			want: false,
		},
		{ // more than 25% overline, but only 4 lines and not 100% are overline
			in: `Set<Box> hasBlueShape = shapes.stream()
                              .filter(s  ->  s.getColor() == BLUE)
                              .map(s  ->  s.getContainingBox())
                              .collect(Collectors.toSet());`,
			want: false,
		},
		{ // long single line is broken only once
			in:   `1 test adfas asj sadf jsadf jasdfj asdf jsad 3 test adfas asj sadf jsadf jasdfj asdf jsad`,
			want: false,
		},
		{ // long single line counts as multiple overline as it is broken mult times
			in:   `1 test adfas asj sadf jsadf jasdfj asdf jsad 2 test adfas asj sadf jsadf jasdfj asdf jsad 3 test asdf sdf sadf sdf sdf sadffdf ksadf sdsss 4`,
			want: true,
		},
	}

	for _, test := range tests {
		got := codeShouldHaveFullPageWidth(test.in)
		if !reflect.DeepEqual(test.want, got) {
			_, file, line, _ := runtime.Caller(0)
			fmt.Printf("%s:%d:\n\ncall codeShouldHaveFullPageWidth(%#v)\n\texp: %#v\n\n\tgot: %#v\n\n",
				filepath.Base(file), line, test.in, test.want, got)
			t.FailNow()
		}
	}
	testutils.Cleanup()
}
开发者ID:frankMilde,项目名称:rol,代码行数:58,代码来源:code_test.go

示例6: Test_LeadingSpaces_haveSpacesBeforeFireChar_spaceAreRemoved

func Test_LeadingSpaces_haveSpacesBeforeFireChar_spaceAreRemoved(t *testing.T) {
	tests := testutils.ConversionTests{
		{ // simple spaces
			In:   `   a `,
			Want: `a `,
		},
		{ // tabs
			In: `		a	`,
			Want: `a	`,
		},
		{ // newline spaces
			In: `
    <li>Services\EntityService.cs</li>
    <li>Services\GameService.cs</li>
    <li>Services\IEntityService.cs</li>
    <li>Services\PlayerService.cs</li>

`,
			Want: `
<li>Services\EntityService.cs</li>
<li>Services\GameService.cs</li>
<li>Services\IEntityService.cs</li>
<li>Services\PlayerService.cs</li>

`,
		},
		{ // newline tabs
			In: `
	<li>Services\EntityService.cs</li>
 			<li>Services\GameService.cs</li>
 <li>Services\IEntityService.cs</li>
						<li>Services\PlayerService.cs</li>

`,
			Want: `
<li>Services\EntityService.cs</li>
<li>Services\GameService.cs</li>
<li>Services\IEntityService.cs</li>
<li>Services\PlayerService.cs</li>

`,
		},
	}

	for _, test := range tests {
		got := LeadingSpaces(test.In)
		if !reflect.DeepEqual(test.Want, got) {
			_, file, line, _ := runtime.Caller(0)
			fmt.Printf("%s:%d:\n\ncall LeadingSpaces(%#v)\n\texp: %#v\n\n\tgot: %#v\n\n",
				filepath.Base(file), line, test.In, test.Want, got)
			t.FailNow()
		}
	}
	testutils.Cleanup()

}
开发者ID:frankMilde,项目名称:rol,代码行数:56,代码来源:strdel_test.go

示例7: runIntegrationTestsAndCleanup

func runIntegrationTestsAndCleanup(tests IntegrationTests, shouldCleanup bool) error {
	err := runIntegrationTests(tests)
	if err != nil {
		return err
	}
	if shouldCleanup && err == nil {
		testutils.Cleanup()
	}
	return nil
}
开发者ID:frankMilde,项目名称:rol,代码行数:10,代码来源:integration_test.go

示例8: Test_LinesAboveTextWidthLimit

func Test_LinesAboveTextWidthLimit(t *testing.T) {
	tests := []struct {
		in   string
		want int
	}{
		{
			in:   `test`,
			want: 0,
		},
		{
			in: `
test adfas asj sadf jsadf jasdfj asdf jsad f
test asdf sdf sadf sdf sdf sadffdf ksadf sdsss`,
			want: 1,
		},
		{
			in: `test
                         test  sd dddddddddddd`,
			want: 1,
		},
		{
			in: `test1
test2 test3
test4`,
			want: 0,
		},
		{
			in:   "",
			want: 0,
		},
		{
			in: `Set<Box> hasBlueShape = shapes.stream()
                              .filter(s  ->  s.getColor() == BLUE)
                              .map(s  ->  s.getContainingBox())
                              .collect(Collectors.toSet());`,
			want: 3,
		},
		{ // long line counts as multiple overline as it is broken mult times
			in: `1
2 test adfas asj sadf jsadf jasdfj asdf jsad 3 test adfas asj sadf jsadf jasdfj asdf jsad 4 test asdf sdf sadf sdf sdf sadffdf ksadf sdsss 5 test asdf sdf sadf sdf sdf sadffdf ksadf sdsss 6 test asdf sdf sadf sdf sdf sadffdf ksadf sdsss`,
			want: 5,
		},
	}

	for _, test := range tests {
		got := LinesAboveTextWidthLimit(test.in)
		if !reflect.DeepEqual(test.want, got) {
			_, file, line, _ := runtime.Caller(0)
			fmt.Printf("%s:%d:\n\ncall LinesAboveTextWidthLimit(%#v)\n\texp: %#v\n\n\tgot: %#v\n\n",
				filepath.Base(file), line, test.in, test.want, got)
			t.FailNow()
		}
	}
	testutils.Cleanup()
}
开发者ID:frankMilde,项目名称:rol,代码行数:55,代码来源:code_test.go

示例9: Test_createValidImgUrl

func Test_createValidImgUrl(t *testing.T) {
	bbgUrl, _ := url.Parse("http://www.bloomberg.com/graphics/2015-paul-ford-what-is-code/")
	slateUrl, _ := url.Parse("http://www.slate.com/articles/technology/bitwise/2015/08/windows_10_privacy_problems_here_s_how_bad_they_are_and_how_to_plug_them.html")
	fowlerUrl, _ := url.Parse("http://martinfowler.com/eaaDev/uiArchs.html")

	type inputs struct {
		link       string
		articleUrl *url.URL
	}
	tests := []struct {
		in   inputs
		want string
	}{
		{
			in: inputs{
				link:       "images/sec1_conference04.jpg",
				articleUrl: bbgUrl,
			},
			want: "http://www.bloomberg.com/graphics/2015-paul-ford-what-is-code/images/sec1_conference04.jpg",
		},
		{
			in: inputs{
				link:       "uiArchs/formsAndControls-cd.gif",
				articleUrl: fowlerUrl,
			},
			want: "http://martinfowler.com/eaaDev/uiArchs/formsAndControls-cd.gif",
		},
		{
			in: inputs{
				link:       "uiArchs/assessmentUI.gif",
				articleUrl: fowlerUrl,
			},
			want: "http://martinfowler.com/eaaDev/uiArchs/assessmentUI.gif",
		},
		{
			in: inputs{
				link:       "/content/dam/slate/articles/technology/bitwise/2015/08/150803_BIT_Windows10-10.png.CROP.original-original.png",
				articleUrl: slateUrl,
			},
			want: "http://www.slate.com/content/dam/slate/articles/technology/bitwise/2015/08/150803_BIT_Windows10-10.png.CROP.original-original.png",
		},
	}

	for _, test := range tests {
		got := createValidImgUrl(test.in.link, test.in.articleUrl)
		if !reflect.DeepEqual(test.want, got) {
			_, file, line, _ := runtime.Caller(0)
			fmt.Printf("%s:%d:\n\ncall createValidImgUrl(%#v)\n\texp: %#v\n\n\tgot: %#v\n\n",
				filepath.Base(file), line, test.in, test.want, got)
			t.FailNow()
		}
	}
	testutils.Cleanup()

}
开发者ID:frankMilde,项目名称:rol,代码行数:55,代码来源:image_integration_test.go

示例10: Test_TrailingSpaces_haveSpacesBeforeLinebreaks_spaceAreRemoved

func Test_TrailingSpaces_haveSpacesBeforeLinebreaks_spaceAreRemoved(t *testing.T) {
	tests := testutils.ConversionTests{
		{
			In: `a 
b			
c     


d




e   	 			 	 	





`,
			Want: `a
b
c


d




e





`,
		},
	}

	for _, test := range tests {
		got := TrailingSpaces(test.In)
		if !reflect.DeepEqual(test.Want, got) {
			_, file, line, _ := runtime.Caller(0)
			fmt.Printf("%s:%d:\n\ncall TrailingSpaces(%#v)\n\texp: %#v\n\n\tgot: %#v\n\n",
				filepath.Base(file), line, test.In, test.Want, got)
			t.FailNow()
		}
	}
	testutils.Cleanup()

}
开发者ID:frankMilde,项目名称:rol,代码行数:52,代码来源:strdel_test.go

示例11: Test_PercentOfLinesOverLimit

func Test_PercentOfLinesOverLimit(t *testing.T) {
	tests := []struct {
		in   string
		want float64
	}{
		{
			in:   `test`,
			want: 0,
		},
		{
			in: `1
2 test adfas asj sadf jsadf jasdfj asdf jsad
3 test adfas asj sadf jsadf jasdfj asdf jsad
4 test asdf sdf sadf sdf sdf sadffdf ksadf sdsss
5 test asdf sdf sadf sdf sdf sadffdf ksadf sdsss
6 test asdf sdf sadf sdf sdf sadffdf ksadf sdsss`,
			want: 0.5,
		},
		{
			in: `test
                         test  sd dddddddddddd`,
			want: 0.5,
		},
		{
			in: `test1
test2 test3
test4`,
			want: 0.,
		},
		{
			in:   "",
			want: 0.,
		},
	}

	for _, test := range tests {
		got := PercentOfLinesOverLimit(test.in)
		if !reflect.DeepEqual(test.want, got) {
			_, file, line, _ := runtime.Caller(0)
			fmt.Printf("%s:%d:\n\ncall PercenttOfLinesAreOverLimit(%#v)\n\texp: %#v\n\n\tgot: %#v\n\n",
				filepath.Base(file), line, test.in, test.want, got)
			t.FailNow()
		}
	}
	testutils.Cleanup()

}
开发者ID:frankMilde,项目名称:rol,代码行数:47,代码来源:code_test.go

示例12: Test_prefixWithFullArticleUrl

func Test_prefixWithFullArticleUrl(t *testing.T) {
	bbgUrl, _ := url.Parse("http://www.bloomberg.com/graphics/2015-paul-ford-what-is-code/")
	type inputs struct {
		link       string
		articleUrl url.URL
	}
	tests := []struct {
		in   inputs
		want string
	}{
		{
			in: inputs{
				link:       "images/sec1_conference04.jpg",
				articleUrl: *bbgUrl,
			},
			want: "http://www.bloomberg.com/graphics/2015-paul-ford-what-is-code/images/sec1_conference04.jpg",
		},
		//{
		//	in: inputs{
		//		link:       "images/sec1_conference04.jpg",
		//		articleUrl: nil,
		//	},
		//	want: "",
		//},
		//{
		//	in: inputs{
		//		link:       "",
		//		articleUrl: bbgUrl2,
		//	},
		//	want: "",
		//},
	}

	for _, test := range tests {
		got := prefixWithFullArticleUrl(test.in.link, test.in.articleUrl)
		if !reflect.DeepEqual(test.want, got) {
			_, file, line, _ := runtime.Caller(0)
			fmt.Printf("%s:%d:\n\ncall prefixWithfullArticleUrl(%#v)\n\texp: %#v\n\n\tgot: %#v\n\n",
				filepath.Base(file), line, test.in, test.want, got)
			t.FailNow()
		}
	}
	testutils.Cleanup()

}
开发者ID:frankMilde,项目名称:rol,代码行数:45,代码来源:image_integration_test.go

示例13: Test_LinebreaksToTwoLinebreaks_haveMultipleLinebreaks_reducedToTwoLinebreaks

func Test_LinebreaksToTwoLinebreaks_haveMultipleLinebreaks_reducedToTwoLinebreaks(t *testing.T) {
	tests := testutils.ConversionTests{
		{
			In: `a
b
c


d




e





`,
			Want: `a
b
c

d

e

`,
		},
	}

	for _, test := range tests {
		got := LinebreaksToTwoLinebreaks(test.In)
		if !reflect.DeepEqual(test.Want, got) {
			_, file, line, _ := runtime.Caller(0)
			fmt.Printf("%s:%d:\n\ncall LineBreaks(%#v)\n\texp: %#v\n\n\tgot: %#v\n\n",
				filepath.Base(file), line, test.In, test.Want, got)
			t.FailNow()
		}
	}
	testutils.Cleanup()

}
开发者ID:frankMilde,项目名称:rol,代码行数:44,代码来源:strtrans_test.go

示例14: Test_imageURLisValid

func Test_imageURLisValid(t *testing.T) {
	tests := []struct {
		in   string
		want bool
	}{
		{
			in:   "https://cdn3.vox-cdn.com",
			want: false,
		},
		{
			in:   "http://www.spiegel.de",
			want: false,
		},
		{
			in:   "images/sec1_conference04.jpg",
			want: false,
		},
		{
			in:   "http://www.slate.com/articles/technology/bitwise/2015/08/windows_10_privacy_problems_here_s_how_bad_they_are_and_how_to_plug_them.html/content/dam/slate/articles/technology/bitwise/2015/08/150803_BIT_Windows10-10.png.CROP.original-original.png",
			want: false,
		},
		{
			in:   "http://www.slate.com/content/dam/slate/articles/technology/bitwise/2015/08/150803_BIT_Windows10-10.png.CROP.original-original.png",
			want: true,
		},
		{
			in:   "http://martinfowler.com/eaaDev/uiArchs/formsAndControls-cd.gif",
			want: true,
		},
	}

	for _, test := range tests {
		got := imageURLisValid(test.in)
		if !reflect.DeepEqual(test.want, got) {
			_, file, line, _ := runtime.Caller(0)
			fmt.Printf("%s:%d:\n\ncall imageURLisValid (%#v)\n\texp: %#v\n\n\tgot: %#v\n\n",
				filepath.Base(file), line, test.in, test.want, got)
			t.FailNow()
		}
	}
	testutils.Cleanup()

}
开发者ID:frankMilde,项目名称:rol,代码行数:43,代码来源:image_integration_test.go

示例15: Test_splitStringIntoLines

func Test_splitStringIntoLines(t *testing.T) {
	tests := []struct {
		in   string
		want []string
	}{
		{
			in:   `test`,
			want: []string{"test"},
		},
		{
			in:   "test\ntest",
			want: []string{"test", "test"},
		},
		{
			in: `test
test`,
			want: []string{"test", "test"},
		},
		{
			in: `test1
test2 test3
test4`,
			want: []string{"test1", "test2 test3", "test4"},
		},
		{
			in:   "",
			want: []string{},
		},
	}

	for _, test := range tests {
		got := SplitStringIntoLines(test.in)
		if !reflect.DeepEqual(test.want, got) {
			_, file, line, _ := runtime.Caller(0)
			fmt.Printf("%s:%d:\n\ncall splitStringIntoLines(%#v)\n\texp: %#v\n\n\tgot: %#v\n\n",
				filepath.Base(file), line, test.in, test.want, got)
			t.FailNow()
		}
	}
	testutils.Cleanup()

}
开发者ID:frankMilde,项目名称:rol,代码行数:42,代码来源:strmult_test.go


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