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

Golang testutils.Cleanup函数代码示例

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

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



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


示例16: Test_removeInvalidURLs

func Test_removeInvalidURLs(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")

	type inputs struct {
		links      []string
		articleUrl *url.URL
	}
	tests := []struct {
		in   inputs
		want []string
	}{
		{
			in: inputs{
				links:      []string{"images/sec1_conference04.jpg"},
				articleUrl: bbgUrl,
			},
			want: []string{"http://www.bloomberg.com/graphics/2015-paul-ford-what-is-code/images/sec1_conference04.jpg"},
		},
		{
			in: inputs{
				links:      []string{"/content/dam/slate/articles/technology/bitwise/2015/08/150803_BIT_Windows10-10.png.CROP.original-original.png"},
				articleUrl: slateUrl,
			},
			want: []string{"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 := removeInvalidURLs(test.in.links, test.in.articleUrl)
		if !reflect.DeepEqual(test.want, got) {
			_, file, line, _ := runtime.Caller(0)
			fmt.Printf("%s:%d:\n\ncall removeInvalidURLs(%#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,代码行数:40,代码来源:image_integration_test.go


示例17: Test_getHeight

func Test_getHeight(t *testing.T) {
	tests := []struct {
		in   string
		want string
	}{
		{
			in: `<html><head></head><body>
<p align="center"><img border="0" alt="" src="/pictures/unicode/rose.jpg" width="300" height="225" /></p>
</body></html>`,
			want: "225",
		},
		{
			in: `<html><head></head><body>
<p align="center"><img border="0" alt="" src="/pictures/unicode/rose.jpg" width="300" height="9" /></p>
</body></html>`,
			want: "9",
		},
		{
			in: `<html><head></head><body>
<p align="center"><img border="0" alt="" src="/pictures/unicode/rose.jpg" width="300"  /></p>
</body></html>`,
			want: "",
		},
	}

	for _, test := range tests {
		doc := newDocFromString(test.in)

		s := doc.Find("img")
		got := getHeight(s)
		if !reflect.DeepEqual(test.want, got) {
			_, file, line, _ := runtime.Caller(0)
			fmt.Printf("%s:%d:\n\ncall getHeigth(%#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,代码行数:40,代码来源:image_test.go


示例18: Test_heightIsBelowLimit

func Test_heightIsBelowLimit(t *testing.T) {
	tests := []struct {
		in   string
		want bool
	}{
		{
			in:   "225",
			want: false,
		},
		{
			in:   "9",
			want: true,
		},
		{
			in:   "-1",
			want: true,
		},
		{
			in:   "",
			want: false,
		},
		{
			in:   "a",
			want: false,
		},
	}

	for _, test := range tests {
		got := heightIsBelowLimit(test.in)
		if !reflect.DeepEqual(test.want, got) {
			_, file, line, _ := runtime.Caller(0)
			fmt.Printf("%s:%d:\n\ncall heigthIsBelowLimit(%#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,代码行数:39,代码来源:image_test.go


示例19: Test_imageFile_testReturnedError

func Test_imageFile_testReturnedError(t *testing.T) {
	tisj := testutils.TestImgServer("jpg")
	defer tisj.Close()
	tisg := testutils.TestImgServer("gif")
	defer tisg.Close()

	type inputs struct {
		url string
		nr  string
	}

	tests := []struct {
		in   inputs
		want error
	}{
		//{in: inputs{tisg.URL, "1"}, want: fmt.Errorf("unsupported format: gif")}, // test gif -> fail
		{in: inputs{tisg.URL, "1"}, want: nil}, // test gif -> true (gif is supported now)
		{ // wrong MIME type  --> fail
			// cannot test against testServer as its port in the url is random
			in:   inputs{"https://www.cs.cmu.edu/~chuck/jokepg/joke_19970213_01.txt#", "1"},
			want: fmt.Errorf("has NOT mime content-type image")}, // test txt -> fail
		{ // invalid url, get error from fetch(url)
			// cannot test against testServer as its port in the url is random
			in:   inputs{"invalidURL", "1"},
			want: fmt.Errorf("fetch: Get invalidURL: unsupported protocol scheme \"\""),
		},
		{in: inputs{tisj.URL, "1"}, want: nil}, // test jpeg -> ok
	}

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


示例20: Test_EmptyBrackets_haveMultilinedEmptyBrackets_spaceAndNewlinesAreRemoved

func Test_EmptyBrackets_haveMultilinedEmptyBrackets_spaceAndNewlinesAreRemoved(t *testing.T) {
	tests := testutils.ConversionTests{
		{
			In: `\emph{ 


			}`,
			Want: `\emph{}`,
		},
	}

	for _, test := range tests {
		got := EmptyBrackets(test.In)
		if !reflect.DeepEqual(test.Want, got) {
			_, file, line, _ := runtime.Caller(0)
			fmt.Printf("%s:%d:\n\ncall EmptyBrackets(%#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,代码行数:23,代码来源:strdel_test.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang webapp.Context类代码示例发布时间:2022-05-23
下一篇:
Golang goreq.Request类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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