Skip to content

Commit

Permalink
Create /utest/util module within /utest
Browse files Browse the repository at this point in the history
- rename functions and constants to public names
- create module.go in /utest to create aliases
  • Loading branch information
balacode committed May 4, 2018
1 parent ca547b6 commit d6361b1
Show file tree
Hide file tree
Showing 29 changed files with 109 additions and 89 deletions.
4 changes: 2 additions & 2 deletions utest/color.go
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------------
// (c) balarabe@protonmail.com License: MIT
// :v: 2018-04-30 23:18:23 78E469 [utest/color.go]
// :v: 2018-05-04 23:53:15 569DA8 [utest/color.go]
// -----------------------------------------------------------------------------

package utest
Expand Down Expand Up @@ -228,7 +228,7 @@ func Test_PDF_Color_(t *testing.T) {
}
}
// test color names with trimming and case insensitivity
for _, name := range permuteStrings(
for _, name := range PermuteStrings(
[]string{"", " ", " "},
[]string{"red", "Red", "RED"},
[]string{"", " ", " "},
Expand Down
14 changes: 7 additions & 7 deletions utest/compression.go
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------------
// (c) balarabe@protonmail.com License: MIT
// :v: 2018-04-29 23:42:24 B76F58 [utest/compression.go]
// :v: 2018-05-04 23:54:06 A4F136 [utest/compression.go]
// -----------------------------------------------------------------------------

package utest
Expand All @@ -26,13 +26,13 @@ func Test_PDF_Compression_(t *testing.T) {
func() {
var doc pdf.PDF // uninitialized PDF
TEqual(t, doc.Compression(), true)
pdfFailIfErrors(t, &doc)
FailIfHasErrors(t, &doc)
}()

func() {
var doc = pdf.NewPDF("A4") // initialized PDF
TEqual(t, doc.Compression(), true)
pdfFailIfErrors(t, &doc)
FailIfHasErrors(t, &doc)
}()

// generate a simple PDF with compression turned on
Expand Down Expand Up @@ -78,8 +78,8 @@ func Test_PDF_Compression_(t *testing.T) {
var doc = pdf.NewPDF("A4") // initialized PDF
doc.SetCompression(true)
draw(&doc)
pdfFailIfErrors(t, &doc)
pdfCompare(t, doc.Bytes(), expect, pdfStreamsInHex)
FailIfHasErrors(t, &doc)
ComparePDF(t, doc.Bytes(), expect, StreamsInHex)
}()

// generate a simple PDF with compression turned off
Expand Down Expand Up @@ -122,8 +122,8 @@ func Test_PDF_Compression_(t *testing.T) {
var doc = pdf.NewPDF("A4") // initialized PDF
doc.SetCompression(false)
draw(&doc)
pdfFailIfErrors(t, &doc)
pdfCompare(t, doc.Bytes(), expect, pdfStreamsInText)
FailIfHasErrors(t, &doc)
ComparePDF(t, doc.Bytes(), expect, StreamsInText)
}()

} // Test_PDF_Compression_
Expand Down
4 changes: 2 additions & 2 deletions utest/doc_author.go
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------------
// (c) balarabe@protonmail.com License: MIT
// :v: 2018-04-29 23:42:24 62EF36 [utest/doc_author.go]
// :v: 2018-05-04 23:51:59 2770D3 [utest/doc_author.go]
// -----------------------------------------------------------------------------

package utest
Expand Down Expand Up @@ -80,7 +80,7 @@ func Test_PDF_DocAuthor_(t *testing.T) {
%%EOF
`

pdfCompare(t, doc.Bytes(), expect, pdfStreamsInText)
ComparePDF(t, doc.Bytes(), expect, StreamsInText)
}()

} // Test_PDF_DocAuthor_
Expand Down
4 changes: 2 additions & 2 deletions utest/doc_creator.go
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------------
// (c) balarabe@protonmail.com License: MIT
// :v: 2018-04-29 23:42:24 32D4FB [utest/doc_creator.go]
// :v: 2018-05-04 23:51:59 BE5AEA [utest/doc_creator.go]
// -----------------------------------------------------------------------------

package utest
Expand Down Expand Up @@ -80,7 +80,7 @@ func Test_PDF_DocCreator_(t *testing.T) {
%%EOF
`

pdfCompare(t, doc.Bytes(), expect, pdfStreamsInText)
ComparePDF(t, doc.Bytes(), expect, StreamsInText)
}()

} // Test_PDF_DocCreator_
Expand Down
4 changes: 2 additions & 2 deletions utest/doc_keywords.go
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------------
// (c) balarabe@protonmail.com License: MIT
// :v: 2018-04-29 23:42:24 2873AE [utest/doc_keywords.go]
// :v: 2018-05-04 23:51:59 D8B452 [utest/doc_keywords.go]
// -----------------------------------------------------------------------------

package utest
Expand Down Expand Up @@ -80,7 +80,7 @@ func Test_PDF_DocKeywords_(t *testing.T) {
%%EOF
`

pdfCompare(t, doc.Bytes(), expect, pdfStreamsInText)
ComparePDF(t, doc.Bytes(), expect, StreamsInText)
}()

} // Test_PDF_DocKeywords_
Expand Down
4 changes: 2 additions & 2 deletions utest/doc_subject.go
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------------
// (c) balarabe@protonmail.com License: MIT
// :v: 2018-04-29 23:42:24 A91EC6 [utest/doc_subject.go]
// :v: 2018-05-04 23:51:59 E90F51 [utest/doc_subject.go]
// -----------------------------------------------------------------------------

package utest
Expand Down Expand Up @@ -79,7 +79,7 @@ func Test_PDF_DocSubject_(t *testing.T) {
%%EOF
`

pdfCompare(t, doc.Bytes(), expect, pdfStreamsInText)
ComparePDF(t, doc.Bytes(), expect, StreamsInText)
}()

} // Test_PDF_DocSubject_
Expand Down
4 changes: 2 additions & 2 deletions utest/doc_title.go
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------------
// (c) balarabe@protonmail.com License: MIT
// :v: 2018-04-29 23:42:24 9F24C2 [utest/doc_title.go]
// :v: 2018-05-04 23:51:59 56F565 [utest/doc_title.go]
// -----------------------------------------------------------------------------

package utest
Expand Down Expand Up @@ -80,7 +80,7 @@ func Test_PDF_DocTitle_(t *testing.T) {
%%EOF
`

pdfCompare(t, doc.Bytes(), expect, pdfStreamsInText)
ComparePDF(t, doc.Bytes(), expect, StreamsInText)
}()

} // Test_PDF_DocTitle_
Expand Down
4 changes: 2 additions & 2 deletions utest/draw_box.go
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------------
// (c) balarabe@protonmail.com License: MIT
// :v: 2018-04-29 23:42:24 91C391 [utest/draw_box.go]
// :v: 2018-05-04 23:51:59 FA531F [utest/draw_box.go]
// -----------------------------------------------------------------------------

package utest
Expand Down Expand Up @@ -66,7 +66,7 @@ func Test_PDF_DrawBox_(t *testing.T) {
%%EOF
`

pdfCompare(t, doc.Bytes(), expect, pdfStreamsInText)
ComparePDF(t, doc.Bytes(), expect, StreamsInText)
} // Test_PDF_DrawBox_

//end
4 changes: 2 additions & 2 deletions utest/draw_circle.go
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------------
// (c) balarabe@protonmail.com License: MIT
// :v: 2018-04-29 23:42:24 1C1A18 [utest/draw_circle.go]
// :v: 2018-05-04 23:51:59 B7CE36 [utest/draw_circle.go]
// -----------------------------------------------------------------------------

package utest
Expand Down Expand Up @@ -86,7 +86,7 @@ func Test_PDF_DrawCircle_(t *testing.T) {
%%EOF
`

pdfCompare(t, doc.Bytes(), expect, pdfStreamsInText)
ComparePDF(t, doc.Bytes(), expect, StreamsInText)
} // Test_PDF_DrawCircle_

//end
16 changes: 8 additions & 8 deletions utest/draw_image.go
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------------
// (c) balarabe@protonmail.com License: MIT
// :v: 2018-04-29 23:42:24 FF0D2A [utest/draw_image.go]
// :v: 2018-05-04 23:54:06 7AF666 [utest/draw_image.go]
// -----------------------------------------------------------------------------

package utest
Expand Down Expand Up @@ -110,8 +110,8 @@ func Test_PDF_DrawImage_(t *testing.T) {
doc.SetCompression(true).
SetUnits("cm").
DrawImage(x, y, height, pngData)
pdfFailIfErrors(t, &doc)
pdfCompare(t, doc.Bytes(), expectOpaque, pdfStreamsInHex)
FailIfHasErrors(t, &doc)
ComparePDF(t, doc.Bytes(), expectOpaque, StreamsInHex)
}()

// the same test, but reading direcly from PNG file
Expand All @@ -120,8 +120,8 @@ func Test_PDF_DrawImage_(t *testing.T) {
doc.SetCompression(true).
SetUnits("cm").
DrawImage(x, y, height, "./image/rgbw64.png")
pdfFailIfErrors(t, &doc)
pdfCompare(t, doc.Bytes(), expectOpaque, pdfStreamsInHex)
FailIfHasErrors(t, &doc)
ComparePDF(t, doc.Bytes(), expectOpaque, StreamsInHex)
}()

// PNG transparency test
Expand Down Expand Up @@ -289,8 +289,8 @@ func Test_PDF_DrawImage_(t *testing.T) {
SetUnits("cm").
DrawImage(x, y, height, "./image/rgbt64.png", "Yellow").
DrawImage(x, y+height+1, height, "./image/rgbt64.png", "Cyan")
pdfFailIfErrors(t, &doc)
pdfCompare(t, doc.Bytes(), expectTransparent, pdfStreamsInHex)
FailIfHasErrors(t, &doc)
ComparePDF(t, doc.Bytes(), expectTransparent, StreamsInHex)
}()

// wrong argument in fileNameOrBytes
Expand Down Expand Up @@ -327,7 +327,7 @@ func Test_PDF_DrawImage_(t *testing.T) {
doc.SetCompression(true).
SetUnits("cm").
DrawImage(x, y, height, fileNameOrBytes)
pdfCompare(t, doc.Bytes(), expect, pdfStreamsInHex)
ComparePDF(t, doc.Bytes(), expect, StreamsInHex)
//
TEqual(t, len(doc.Errors()), 1)
if len(doc.Errors()) > 0 {
Expand Down
6 changes: 3 additions & 3 deletions utest/draw_text.go
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------------
// (c) balarabe@protonmail.com License: MIT
// :v: 2018-04-29 23:42:24 BFB667 [utest/draw_text.go]
// :v: 2018-05-04 23:51:59 23D951 [utest/draw_text.go]
// -----------------------------------------------------------------------------

package utest
Expand Down Expand Up @@ -67,7 +67,7 @@ func Test_PDF_DrawText_(t *testing.T) {
%%EOF
`

pdfCompare(t, doc.Bytes(), expect, pdfStreamsInText)
ComparePDF(t, doc.Bytes(), expect, StreamsInText)
}()

func() {
Expand Down Expand Up @@ -115,7 +115,7 @@ func Test_PDF_DrawText_(t *testing.T) {
%%EOF
`

pdfCompare(t, doc.Bytes(), expect, pdfStreamsInText)
ComparePDF(t, doc.Bytes(), expect, StreamsInText)
TEqual(t, len(doc.Errors()), 1)
TEqual(t, doc.PullError(),
fmt.Errorf(`Invalid font "Ye-Olde-Scriptte" @DrawText`))
Expand Down
4 changes: 2 additions & 2 deletions utest/draw_text_at.go
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------------
// (c) balarabe@protonmail.com License: MIT
// :v: 2018-04-29 23:42:24 898C88 [utest/draw_text_at.go]
// :v: 2018-05-04 23:51:59 E9F635 [utest/draw_text_at.go]
// -----------------------------------------------------------------------------

package utest
Expand Down Expand Up @@ -75,7 +75,7 @@ func Test_PDF_DrawTextAt_(t *testing.T) {
%%EOF
`

pdfCompare(t, doc.Bytes(), expect, pdfStreamsInText)
ComparePDF(t, doc.Bytes(), expect, StreamsInText)
} // Test_PDF_DrawTextAt_

//end
6 changes: 3 additions & 3 deletions utest/draw_text_in_box.go
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------------
// (c) balarabe@protonmail.com License: MIT
// :v: 2018-05-02 23:01:56 F612B3 [utest/draw_text_in_box.go]
// :v: 2018-05-04 23:51:59 F87BFC [utest/draw_text_in_box.go]
// -----------------------------------------------------------------------------

package utest
Expand Down Expand Up @@ -108,7 +108,7 @@ func Test_PDF_DrawTextInBox_(t *testing.T) {
%%EOF
`

pdfCompare(t, doc.Bytes(), expect, pdfStreamsInText)
ComparePDF(t, doc.Bytes(), expect, StreamsInText)
}()

func() {
Expand Down Expand Up @@ -199,7 +199,7 @@ func Test_PDF_DrawTextInBox_(t *testing.T) {
%%EOF
`

pdfCompare(t, doc.Bytes(), expect, pdfStreamsInText)
ComparePDF(t, doc.Bytes(), expect, StreamsInText)
}()

} // Test_PDF_DrawTextInBox_
Expand Down
4 changes: 2 additions & 2 deletions utest/draw_unit_grid.go
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------------
// (c) balarabe@protonmail.com License: MIT
// :v: 2018-04-29 23:42:24 85D483 [utest/draw_unit_grid.go]
// :v: 2018-05-04 23:51:59 A985B5 [utest/draw_unit_grid.go]
// -----------------------------------------------------------------------------

package utest
Expand Down Expand Up @@ -361,7 +361,7 @@ func Test_PDF_DrawUnitGrid_(t *testing.T) {
%%EOF
`

pdfCompare(t, result, expect, pdfStreamsInText)
ComparePDF(t, result, expect, StreamsInText)
} // Test_PDF_DrawUnitGrid_

//end
4 changes: 2 additions & 2 deletions utest/fill_box.go
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------------
// (c) balarabe@protonmail.com License: MIT
// :v: 2018-04-29 23:42:24 558C89 [utest/fill_box.go]
// :v: 2018-05-04 23:51:59 7AB65F [utest/fill_box.go]
// -----------------------------------------------------------------------------

package utest
Expand Down Expand Up @@ -58,7 +58,7 @@ func Test_PDF_FillBox_(t *testing.T) {
%%EOF
`

pdfCompare(t, doc.Bytes(), expect, pdfStreamsInText)
ComparePDF(t, doc.Bytes(), expect, StreamsInText)
} // Test_PDF_FillBox_

//end
4 changes: 2 additions & 2 deletions utest/fill_circle.go
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------------
// (c) balarabe@protonmail.com License: MIT
// :v: 2018-04-29 23:42:24 6703F4 [utest/fill_circle.go]
// :v: 2018-05-04 23:51:59 9BD639 [utest/fill_circle.go]
// -----------------------------------------------------------------------------

package utest
Expand Down Expand Up @@ -61,7 +61,7 @@ func Test_PDF_FillCircle_(t *testing.T) {
%%EOF
`

pdfCompare(t, doc.Bytes(), expect, pdfStreamsInText)
ComparePDF(t, doc.Bytes(), expect, StreamsInText)
} // Test_PDF_FillCircle_

//end
4 changes: 2 additions & 2 deletions utest/font_name.go
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------------
// (c) balarabe@protonmail.com License: MIT
// :v: 2018-04-29 23:42:24 00150E [utest/font_name.go]
// :v: 2018-05-04 23:51:59 29D149 [utest/font_name.go]
// -----------------------------------------------------------------------------

package utest
Expand Down Expand Up @@ -92,7 +92,7 @@ func Test_PDF_FontName_(t *testing.T) {
%%EOF
`

pdfCompare(t, doc.Bytes(), expect, pdfStreamsInText)
ComparePDF(t, doc.Bytes(), expect, StreamsInText)
}()

} // Test_PDF_FontName_
Expand Down
4 changes: 2 additions & 2 deletions utest/horizontal_scaling.go
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------------
// (c) balarabe@protonmail.com License: MIT
// :v: 2018-04-29 23:42:24 260610 [utest/horizontal_scaling.go]
// :v: 2018-05-04 23:51:59 FCAFDC [utest/horizontal_scaling.go]
// -----------------------------------------------------------------------------

package utest
Expand Down Expand Up @@ -130,7 +130,7 @@ func Test_PDF_HorizontalScaling_(t *testing.T) {
%%EOF
`

pdfCompare(t, doc.Bytes(), expect, pdfStreamsInText)
ComparePDF(t, doc.Bytes(), expect, StreamsInText)
doc.SaveFile("~~test_horizontal_scaling.pdf")
}()

Expand Down

0 comments on commit d6361b1

Please sign in to comment.