本文整理匯總了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()
}
示例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()
}
示例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()
}
示例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()
}
示例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()
}
示例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()
}
示例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
}
示例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()
}
示例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()
}
示例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()
}
示例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()
}
示例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()
}
示例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()
}
示例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()
}
示例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()
}