Skip to content

Commit

Permalink
Rename public API unit tests to Test_PDF_<method>_()
Browse files Browse the repository at this point in the history
  • Loading branch information
balacode committed Apr 26, 2018
1 parent e2f2657 commit 1ed572e
Show file tree
Hide file tree
Showing 36 changed files with 241 additions and 235 deletions.
106 changes: 56 additions & 50 deletions public_test.go
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------------
// (c) balarabe@protonmail.com License: MIT
// :v: 2018-04-23 12:33:29 899915 [public_test.go]
// :v: 2018-04-26 22:42:44 E1046E [public_test.go]
// -----------------------------------------------------------------------------

package pdf_test
Expand Down Expand Up @@ -35,197 +35,203 @@ import "github.com/balacode/one-file-pdf/utest"
// # Constructor

// NewPDF(paperSize string) PDF
func Test_NewPDF_(t *testing.T) { utest.NewPDF(t) }
func Test_NewPDF_(t *testing.T) { utest.Test_NewPDF_(t) }

// -----------------------------------------------------------------------------
// # Read-Only Properties (ob *PDF)

// PageCount() int
//TODO: func Test_PDF_PageCount_(t *testing.T) { utest.PageCount(t) }
//TODO: func Test_PDF_PageCount_(t *testing.T) { utest.Test_PDF_PageCount_(t) }

// PageHeight() float64
func Test_PDF_PageHeight_(t *testing.T) { utest.PageHeight(t) }
func Test_PDF_PageHeight_(t *testing.T) { utest.Test_PDF_PageHeight_(t) }

// PageWidth() float64
func Test_PDF_PageWidth_(t *testing.T) { utest.PageWidth(t) }
func Test_PDF_PageWidth_(t *testing.T) { utest.Test_PDF_PageWidth_(t) }

// -----------------------------------------------------------------------------
// # Properties

// Color() color.RGBA
// SetColor(nameOrHTMLColor string) *PDF
// SetColorRGB(r, g, b byte) *PDF
func Test_PDF_Color_(t *testing.T) { utest.Color(t) }
func Test_PDF_Color_(t *testing.T) { utest.Test_PDF_Color_(t) }

// Compression() bool
// SetCompression(val bool) *PDF
func Test_PDF_Compression_(t *testing.T) { utest.Compression(t) }
func Test_PDF_Compression_(t *testing.T) { utest.Test_PDF_Compression_(t) }

// CurrentPage() int
// SetCurrentPage(pageNo int) *PDF
func Test_PDF_CurrentPage_(t *testing.T) { utest.CurrentPage(t) }
func Test_PDF_CurrentPage_(t *testing.T) { utest.Test_PDF_CurrentPage_(t) }

// DocAuthor() string
// SetDocAuthor(s string) *PDF
func Test_PDF_DocAuthor_(t *testing.T) { utest.DocAuthor(t) }
func Test_PDF_DocAuthor_(t *testing.T) { utest.Test_PDF_DocAuthor_(t) }

// DocCreator() string
// SetDocCreator(s string) *PDF
func Test_PDF_DocCreator_(t *testing.T) { utest.DocCreator(t) }
func Test_PDF_DocCreator_(t *testing.T) { utest.Test_PDF_DocCreator_(t) }

// DocKeywords() string
// SetDocKeywords(s string) *PDF
func Test_PDF_DocKeywords_(t *testing.T) { utest.DocKeywords(t) }
func Test_PDF_DocKeywords_(t *testing.T) { utest.Test_PDF_DocKeywords_(t) }

// DocSubject() string
// SetDocSubject(s string) *PDF
func Test_PDF_DocSubject_(t *testing.T) { utest.DocSubject(t) }
func Test_PDF_DocSubject_(t *testing.T) { utest.Test_PDF_DocSubject_(t) }

// DocTitle() string
// SetDocTitle(s string) *PDF
func Test_PDF_DocTitle_(t *testing.T) { utest.DocTitle(t) }
func Test_PDF_DocTitle_(t *testing.T) { utest.Test_PDF_DocTitle_(t) }

// FontName() string
// SetFontName(name string) *PDF
func Test_PDF_FontName_(t *testing.T) { utest.FontName(t) }
func Test_PDF_FontName_(t *testing.T) { utest.Test_PDF_FontName_(t) }

// TODO: func Test_PDF_FontSize_(t *testing.T) { utest.FontSize(t) }
// TODO: func Test_PDF_FontSize_(t *testing.T) { utest.Test_PDF_FontSize_(t) }
// FontSize() float64
// SetFontSize(points float64) *PDF

// SetFont(name string, points float64) *PDF
func Test_PDF_SetFont_(t *testing.T) { utest.SetFont(t) }
func Test_PDF_SetFont_(t *testing.T) { utest.Test_PDF_SetFont_(t) }

// HorizontalScaling() uint16
// SetHorizontalScaling(percent uint16) *PDF
func Test_PDF_HorizontalScaling_(t *testing.T) { utest.HorizontalScaling(t) }
func Test_PDF_HorizontalScaling_(t *testing.T) {
utest.Test_PDF_HorizontalScaling_(t)
}

// LineWidth() float64
// SetLineWidth(points float64) *PDF
func Test_PDF_LineWidth_(t *testing.T) { utest.LineWidth(t) }
func Test_PDF_LineWidth_(t *testing.T) { utest.Test_PDF_LineWidth_(t) }

// Units() string
// SetUnits(unitName string) *PDF
func Test_PDF_Units_(t *testing.T) { utest.Units(t) }
func Test_PDF_Units_(t *testing.T) { utest.Test_PDF_Units_(t) }

// X() float64
// SetX(x float64) *PDF
func Test_PDF_X_(t *testing.T) { utest.X(t) }
func Test_PDF_X_(t *testing.T) { utest.Test_PDF_X_(t) }

// Y() float64
// SetY(y float64) *PDF
func Test_PDF_Y_(t *testing.T) { utest.Y(t) }
func Test_PDF_Y_(t *testing.T) { utest.Test_PDF_Y_(t) }

//TODO: func Test_PDF_SetXY_(t *testing.T) { utest.SetXY(t) }
//TODO: func Test_PDF_SetXY_(t *testing.T) { utest.Test_PDF_SetXY_(t) }
// SetXY(x, y float64) *PDF

// -----------------------------------------------------------------------------
// # Methods (ob *PDF)

// AddPage() *PDF
//TODO: func Test_PDF_AddPage_(t *testing.T) { utest.AddPage(t) }
//TODO: func Test_PDF_AddPage_(t *testing.T) { utest.Test_PDF_AddPage_(t) }

// Bytes() []byte
//TODO: func Test_PDF_Bytes_(t *testing.T) { utest.Bytes(t) }
//TODO: func Test_PDF_Bytes_(t *testing.T) { utest.Test_PDF_Bytes_(t) }

// DrawBox(x, y, width, height float64, optFill ...bool) *PDF
func Test_PDF_DrawBox_(t *testing.T) { utest.DrawBox(t) }
func Test_PDF_DrawBox_(t *testing.T) { utest.Test_PDF_DrawBox_(t) }

// DrawCircle(x, y, radius float64, optFill ...bool) *PDF
func Test_PDF_DrawCircle_(t *testing.T) { utest.DrawCircle(t) }
func Test_PDF_DrawCircle_(t *testing.T) { utest.Test_PDF_DrawCircle_(t) }

// DrawEllipse(x, y, xRadius, yRadius float64,
// optFill ...bool) *PDF
//TODO: func Test_PDF_DrawEllipse_(t *testing.T) { utest.DrawEllipse(t) }
//TODO: func Test_PDF_DrawEllipse_(t *testing.T) {
// utest.Test_PDF_DrawEllipse_(t)
// }

// DrawImage(x, y, height float64, fileNameOrBytes interface{},
// backColor ...string) *PDF
func Test_PDF_DrawImage_(t *testing.T) { utest.DrawImage(t) }
func Test_PDF_DrawImage_(t *testing.T) { utest.Test_PDF_DrawImage_(t) }

// DrawLine(x1, y1, x2, y2 float64) *PDF
//TODO: func Test_PDF_DrawLine_(t *testing.T) { utest.DrawLine(t) }
//TODO: func Test_PDF_DrawLine_(t *testing.T) { utest.Test_PDF_DrawLine_(t) }

// DrawText(s string) *PDF
func Test_PDF_DrawText_(t *testing.T) { utest.DrawText(t) }
func Test_PDF_DrawText_(t *testing.T) { utest.Test_PDF_DrawText_(t) }

// DrawTextAlignedToBox(
// x, y, width, height float64, align, text string) *PDF
//TODO: func Test_PDF_DrawTextAlignedToBox_(t *testing.T) {
// utest.DrawTextAlignedToBox(t)
// utest.Test_PDF_DrawTextAlignedToBox(t)
// }

// DrawTextAt(x, y float64, text string) *PDF
func Test_PDF_DrawTextAt_(t *testing.T) { utest.DrawTextAt(t) }
func Test_PDF_DrawTextAt_(t *testing.T) { utest.Test_PDF_DrawTextAt_(t) }

// DrawTextInBox(
// x, y, width, height float64, align, text string) *PDF
func Test_PDF_DrawTextInBox_(t *testing.T) { utest.DrawTextInBox(t) }
func Test_PDF_DrawTextInBox_(t *testing.T) { utest.Test_PDF_DrawTextInBox_(t) }

// DrawUnitGrid() *PDF
func Test_PDF_DrawUnitGrid_(t *testing.T) { utest.DrawUnitGrid(t) }
func Test_PDF_DrawUnitGrid_(t *testing.T) { utest.Test_PDF_DrawUnitGrid_(t) }

// FillBox(x, y, width, height float64) *PDF
func Test_PDF_FillBox_(t *testing.T) { utest.FillBox(t) }
func Test_PDF_FillBox_(t *testing.T) { utest.Test_PDF_FillBox_(t) }

// FillCircle(x, y, radius float64) *PDF
func Test_PDF_FillCircle_(t *testing.T) { utest.FillCircle(t) }
func Test_PDF_FillCircle_(t *testing.T) { utest.Test_PDF_FillCircle_(t) }

// FillEllipse(x, y, xRadius, yRadius float64) *PDF
//TODO: func Test_PDF_FillEllipse_(t *testing.T) { utest.FillEllipse(t) }
//TODO: func Test_PDF_FillEllipse_(t *testing.T) {
// utest.Test_PDF_FillEllipse_(t)
// }

// NextLine() *PDF
//TODO: func Test_PDF_NextLine_(t *testing.T) { utest.NextLine(t) }
//TODO: func Test_PDF_NextLine_(t *testing.T) { utest.Test_PDF_NextLine_(t) }

// Reset() *PDF
func Test_PDF_Reset_(t *testing.T) { utest.Reset(t) }
func Test_PDF_Reset_(t *testing.T) { utest.Test_PDF_Reset_(t) }

// SaveFile(filename string) error
//TODO: func Test_PDF_SaveFile_(t *testing.T) { utest.SaveFile(t) }
//TODO: func Test_PDF_SaveFile_(t *testing.T) { utest.Test_PDF_SaveFile_(t) }

// SetColumnWidths(widths ...float64) *PDF
//TODO: func Test_PDF_SetColumnWidths_(t *testing.T) {
// utest.SetColumnWidths(t)
// utest.Test_PDF_SetColumnWidths(t)
// }

// -----------------------------------------------------------------------------
// # Metrics Methods (ob *PDF)

// TextWidth(s string) float64
//TODO: func Test_PDF_TextWidth_(t *testing.T) { utest.TextWidth(t) }
//TODO: func Test_PDF_TextWidth_(t *testing.T) { utest.Test_PDF_TextWidth_(t) }

// ToColor(nameOrHTMLColor string) (color.RGBA, error)
func Test_PDF_ToColorT1_(t *testing.T) { utest.ToColorT1(t) }
func Test_PDF_ToColorT2_(t *testing.T) { utest.ToColorT2(t) }
func Test_PDF_ToColor_1_(t *testing.T) { utest.Test_PDF_ToColor_1_(t) }
func Test_PDF_ToColor_2_(t *testing.T) { utest.Test_PDF_ToColor_2_(t) }

// -----------------------------------------------------------------------------
// # Metrics Methods (ob *PDF)

// ToPoints(numberAndUnit string) (float64, error)
func Test_PDF_ToPoints_(t *testing.T) { utest.ToPoints(t) }
func Test_PDF_ToPoints_(t *testing.T) { utest.Test_PDF_ToPoints_(t) }

// ToUnits(points float64) float64
func Test_PDF_ToUnits_(t *testing.T) { utest.ToUnits(t) }
func Test_PDF_ToUnits_(t *testing.T) { utest.Test_PDF_ToUnits_(t) }

// WrapTextLines(width float64, text string) (ret []string)
//TODO: func Test_PDF_WrapTextLines_(t *testing.T) {
// utest.WrapTextLines(t)
// utest.Test_PDF_WrapTextLines(t)
// }

// -----------------------------------------------------------------------------
// # Error Handling Methods (ob *PDF)

// Clean() *PDF
func Test_PDF_Clean_(t *testing.T) { utest.Clean(t) }
func Test_PDF_Clean_(t *testing.T) { utest.Test_PDF_Clean_(t) }

// ErrorInfo(err error) (ret struct {
// ID int
// Msg, Src, Val string
// })

// Errors() []error
func Test_PDF_Errors_(t *testing.T) { utest.Errors(t) }
func Test_PDF_Errors_(t *testing.T) { utest.Test_PDF_Errors_(t) }

// PullError() error
func Test_PDF_PullError_(t *testing.T) { utest.PullError(t) }
func Test_PDF_PullError_(t *testing.T) { utest.Test_PDF_PullError_(t) }

//end
10 changes: 5 additions & 5 deletions utest/clean.go
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------------
// (c) balarabe@protonmail.com License: MIT
// :v: 2018-03-24 18:56:20 438C56 [utest/clean.go]
// :v: 2018-04-26 22:42:44 2FF3CC [utest/clean.go]
// -----------------------------------------------------------------------------

package utest
Expand All @@ -10,9 +10,9 @@ import "testing" // standard

import "github.com/balacode/one-file-pdf"

// Clean is the unit test for PDF.Clean()
func Clean(t *testing.T) {
fmt.Println("utest.Clean")
// Test_PDF_Clean_ is the unit test for PDF.Clean()
func Test_PDF_Clean_(t *testing.T) {
fmt.Println("Test PDF.Clean()")

// calling Clean() multiple times on a non-initialized PDF:
// (you should not do this normally, use NewPDF() to create a PDF)
Expand Down Expand Up @@ -53,6 +53,6 @@ func Clean(t *testing.T) {
TEqual(t, doc.Errors(), []error{})
}()

} // Clean
} // Test_PDF_Clean_

//end
14 changes: 7 additions & 7 deletions utest/color.go
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------------
// (c) balarabe@protonmail.com License: MIT
// :v: 2018-03-27 22:10:13 FB0CFA [utest/color.go]
// :v: 2018-04-26 22:42:44 E26F93 [utest/color.go]
// -----------------------------------------------------------------------------

package utest
Expand All @@ -11,13 +11,13 @@ import "image/color" // standard

import "github.com/balacode/one-file-pdf"

// Color tests PDF.Color() and SetColor()
func Color(t *testing.T) {
// Test_PDF_Color_ tests PDF.Color() and SetColor()
func Test_PDF_Color_(t *testing.T) {

// -------------------------------------------------------------------------
// (ob *PDF) Color() color.RGBA
//
fmt.Println("utest.Color")
fmt.Println("Test PDF.Color()")

func() {
var doc pdf.PDF // uninitialized PDF
Expand All @@ -39,7 +39,7 @@ func Color(t *testing.T) {
// TODO: test case-insensitivity
// TODO: test ignoring '-' and '_'

fmt.Println("utest.SetColor")
fmt.Println("Test PDF.SetColor()")
for _, name := range permuteStrings(
[]string{"", " ", " "},
[]string{"red", "Red", "RED"},
Expand Down Expand Up @@ -87,7 +87,7 @@ func Color(t *testing.T) {
// -------------------------------------------------------------------------
// SetColorRGB(red, green, blue int) *PDF
//
fmt.Println("utest.SetColorRGB")
fmt.Println("Test PDF.SetColorRGB()")

func() {
// red
Expand All @@ -113,6 +113,6 @@ func Color(t *testing.T) {
TEqual(t, &a, b)
}()

} // Color
} // Test_PDF_Color_

//end
10 changes: 5 additions & 5 deletions utest/compression.go
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------------
// (c) balarabe@protonmail.com License: MIT
// :v: 2018-04-23 11:32:14 6D6A87 [utest/compression.go]
// :v: 2018-04-26 22:42:44 9DC683 [utest/compression.go]
// -----------------------------------------------------------------------------

package utest
Expand All @@ -10,9 +10,9 @@ import "testing" // standard

import "github.com/balacode/one-file-pdf"

// Compression tests PDF.Compression() and SetCompression()
func Compression(t *testing.T) {
fmt.Println("utest.Compression")
// Test_PDF_Compression_ tests PDF.Compression() and SetCompression()
func Test_PDF_Compression_(t *testing.T) {
fmt.Println("Test PDF.Compression()")

var draw = func(doc *pdf.PDF) {
doc.SetUnits("cm").
Expand Down Expand Up @@ -124,6 +124,6 @@ func Compression(t *testing.T) {
pdfCompare(t, doc.Bytes(), expect, pdfStreamsInText)
}()

} // Compression
} // Test_PDF_Compression_

//end
10 changes: 5 additions & 5 deletions utest/current_page.go
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------------
// (c) balarabe@protonmail.com License: MIT
// :v: 2018-03-26 12:23:48 4726B1 [utest/current_page.go]
// :v: 2018-04-26 22:42:44 F50185 [utest/current_page.go]
// -----------------------------------------------------------------------------

package utest
Expand All @@ -10,9 +10,9 @@ import "testing" // standard

import "github.com/balacode/one-file-pdf"

// CurrentPage tests PDF.CurrentPage()
func CurrentPage(t *testing.T) {
fmt.Println("utest.CurrentPage")
// Test_PDF_CurrentPage_ tests PDF.CurrentPage()
func Test_PDF_CurrentPage_(t *testing.T) {
fmt.Println("Test PDF.CurrentPage()")

func() {
var doc pdf.PDF // uninitialized PDF
Expand Down Expand Up @@ -58,6 +58,6 @@ func CurrentPage(t *testing.T) {
TEqual(t, doc.CurrentPage(), 4)
}()

} // CurrentPage
} // Test_PDF_CurrentPage_

//end

0 comments on commit 1ed572e

Please sign in to comment.