Esempio n. 1
0
func (s *LayoutSuite) TestNewPageLayoutDefaults() {
	l, err := layouts.NewPageLayout("", "", 1, 1)

	assert.Equal(s.T(), "L", l.Orientation())
	assert.Equal(s.T(), "mm", l.Unit())
	assert.Nil(s.T(), err)
}
Esempio n. 2
0
func (t *JsonTemplate) loadLayout(data interface{}) error {
	var layout_data map[string]interface{}
	mapstructure.Decode(data, &layout_data)

	var err error
	t.layout, err = layouts.NewPageLayout(
		layout_data["orientation"].(string),
		layout_data["unit"].(string),
		layout_data["width"].(float64),
		layout_data["height"].(float64),
	)
	t.layout.SetFonts(loadFonts(layout_data))

	if err != nil {
		return err
	}

	return nil
}
Esempio n. 3
0
func (s *LayoutSuite) TestHeight() {
	l, _ := layouts.NewPageLayout("", "", 15, 20)

	assert.EqualValues(s.T(), 20, l.Height())
}
Esempio n. 4
0
func (s *LayoutSuite) TestWidth() {
	l, _ := layouts.NewPageLayout("", "", 15, 20)

	assert.EqualValues(s.T(), 15, l.Width())
}
Esempio n. 5
0
func (s *LayoutSuite) TestHeightError() {
	_, err := layouts.NewPageLayout("", "", 1, 0)

	assert.NotNil(s.T(), err)
}
Esempio n. 6
0
func (s *LayoutSuite) TestWidthError() {
	_, err := layouts.NewPageLayout("", "", 0, 1)

	assert.NotNil(s.T(), err)
}