Add unit test for SetPageLayout
This commit is contained in:
parent
e14d2febc8
commit
14d490c83d
|
@ -23,6 +23,8 @@ func ExampleFile_SetPageLayout() {
|
||||||
if err := f.SetPageLayout(
|
if err := f.SetPageLayout(
|
||||||
"Sheet1",
|
"Sheet1",
|
||||||
excelize.PageLayoutPaperSize(10),
|
excelize.PageLayoutPaperSize(10),
|
||||||
|
excelize.FitToHeight(2),
|
||||||
|
excelize.FitToWidth(2),
|
||||||
); err != nil {
|
); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -34,6 +36,8 @@ func ExampleFile_GetPageLayout() {
|
||||||
var (
|
var (
|
||||||
orientation excelize.PageLayoutOrientation
|
orientation excelize.PageLayoutOrientation
|
||||||
paperSize excelize.PageLayoutPaperSize
|
paperSize excelize.PageLayoutPaperSize
|
||||||
|
fitToHeight excelize.FitToHeight
|
||||||
|
fitToWidth excelize.FitToWidth
|
||||||
)
|
)
|
||||||
if err := f.GetPageLayout("Sheet1", &orientation); err != nil {
|
if err := f.GetPageLayout("Sheet1", &orientation); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
@ -41,13 +45,24 @@ func ExampleFile_GetPageLayout() {
|
||||||
if err := f.GetPageLayout("Sheet1", &paperSize); err != nil {
|
if err := f.GetPageLayout("Sheet1", &paperSize); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
if err := f.GetPageLayout("Sheet1", &fitToHeight); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := f.GetPageLayout("Sheet1", &fitToWidth); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
fmt.Println("Defaults:")
|
fmt.Println("Defaults:")
|
||||||
fmt.Printf("- orientation: %q\n", orientation)
|
fmt.Printf("- orientation: %q\n", orientation)
|
||||||
fmt.Printf("- paper size: %d\n", paperSize)
|
fmt.Printf("- paper size: %d\n", paperSize)
|
||||||
|
fmt.Printf("- fit to height: %d\n", fitToHeight)
|
||||||
|
fmt.Printf("- fit to width: %d\n", fitToWidth)
|
||||||
// Output:
|
// Output:
|
||||||
// Defaults:
|
// Defaults:
|
||||||
// - orientation: "portrait"
|
// - orientation: "portrait"
|
||||||
// - paper size: 1
|
// - paper size: 1
|
||||||
|
// - fit to height: 1
|
||||||
|
// - fit to width: 1
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPageLayoutOption(t *testing.T) {
|
func TestPageLayoutOption(t *testing.T) {
|
||||||
|
@ -59,6 +74,8 @@ func TestPageLayoutOption(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
{new(excelize.PageLayoutOrientation), excelize.PageLayoutOrientation(excelize.OrientationLandscape)},
|
{new(excelize.PageLayoutOrientation), excelize.PageLayoutOrientation(excelize.OrientationLandscape)},
|
||||||
{new(excelize.PageLayoutPaperSize), excelize.PageLayoutPaperSize(10)},
|
{new(excelize.PageLayoutPaperSize), excelize.PageLayoutPaperSize(10)},
|
||||||
|
{new(excelize.FitToHeight), excelize.FitToHeight(2)},
|
||||||
|
{new(excelize.FitToWidth), excelize.FitToWidth(2)},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, test := range testData {
|
for i, test := range testData {
|
||||||
|
|
Loading…
Reference in New Issue