Skip to content

Commit

Permalink
Fix #386 regression test added (#440)
Browse files Browse the repository at this point in the history
* #386 regression test added

* closes #386 string to bigint on GOARCH=386
  • Loading branch information
Vsevolod Balashov authored and xuri committed Sep 1, 2019
1 parent 333c588 commit 1fc4bc5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions cell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package excelize

import (
"fmt"
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -94,3 +95,15 @@ func BenchmarkSetCellValue(b *testing.B) {
}
}
}

func TestOverflowNumericCell(t *testing.T) {
f, err := OpenFile(filepath.Join("test", "OverflowNumericCell.xlsx"))
if !assert.NoError(t, err) {
t.FailNow()
}
// source of xlsx file is Russia, don`t touch it, elsewhere bug not reproduced
val, err := f.GetCellValue("Лист1", "A1")
assert.NoError(t, err)
// GOARCH=amd64 - all ok; GOARCH=386 - actual : "-2147483648"
assert.Equal(t, "8595602512225", val, "A1 should be 8595602512225")
}
2 changes: 1 addition & 1 deletion styles.go
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ func formatToInt(i int, v string) string {
if err != nil {
return v
}
return fmt.Sprintf("%d", int(f))
return fmt.Sprintf("%d", int64(f))
}

// formatToFloat provides a function to convert original string to float
Expand Down
Binary file added test/OverflowNumericCell.xlsx
Binary file not shown.

0 comments on commit 1fc4bc5

Please sign in to comment.