From 324f87bcaed9ec775c0b79627956a093ad481d36 Mon Sep 17 00:00:00 2001 From: xuri Date: Fri, 18 Sep 2020 22:20:58 +0800 Subject: add checking and limits for the worksheet --- styles_test.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'styles_test.go') diff --git a/styles_test.go b/styles_test.go index 9b8ba39..b68365b 100644 --- a/styles_test.go +++ b/styles_test.go @@ -3,6 +3,7 @@ package excelize import ( "fmt" "path/filepath" + "strings" "testing" "github.com/stretchr/testify/assert" @@ -200,6 +201,10 @@ func TestNewStyle(t *testing.T) { assert.NoError(t, err) _, err = f.NewStyle(Style{}) assert.EqualError(t, err, "invalid parameter type") + _, err = f.NewStyle(&Style{Font: &Font{Family: strings.Repeat("s", MaxFontFamilyLength+1)}}) + assert.EqualError(t, err, "the length of the font family name must be smaller than or equal to 31") + _, err = f.NewStyle(&Style{Font: &Font{Size: MaxFontSize + 1}}) + assert.EqualError(t, err, "font size must be between 1 and 409 points") } func TestGetDefaultFont(t *testing.T) { -- cgit v1.2.1