Skip to content

Commit a45d47d

Browse files
xxf0512xuri
authored andcommitted
Fix: int overflow of function
1 parent b936343 commit a45d47d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

stream_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,29 @@ func TestStreamSetCellValFunc(t *testing.T) {
380380
}
381381
}
382382

383+
func TestSetCellIntFunc(t *testing.T) {
384+
cases := []struct{
385+
val interface{}
386+
target string
387+
}{
388+
{val: 128, target: "128"},
389+
{val: int8(-128), target: "-128"},
390+
{val: int16(-32768), target: "-32768"},
391+
{val: int32(-2147483648), target: "-2147483648"},
392+
{val: int64(-9223372036854775808), target: "-9223372036854775808"},
393+
{val: uint(128), target: "128"},
394+
{val: uint8(255), target: "255"},
395+
{val: uint16(65535), target: "65535"},
396+
{val: uint32(4294967295), target: "4294967295"},
397+
{val: uint64(18446744073709551615), target: "18446744073709551615"},
398+
}
399+
for _, c := range cases {
400+
cell := &xlsxC{}
401+
setCellIntFunc(cell, c.val)
402+
assert.Equal(t, c.target, cell.V)
403+
}
404+
}
405+
383406
func TestStreamWriterOutlineLevel(t *testing.T) {
384407
file := NewFile()
385408
streamWriter, err := file.NewStreamWriter("Sheet1")

0 commit comments

Comments
 (0)