diff options
author | xuri <xuri.me@gmail.com> | 2020-08-14 16:09:50 +0000 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2020-08-15 09:19:35 +0000 |
commit | c3e92a51d744bc8420e0626b06ee3a0efd030341 (patch) | |
tree | 3ddf72f53711ae898baf584287d6b4b7ad4276b9 /cell_test.go | |
parent | cb6f8852bb764ffc1f9b637faaf594353476e17c (diff) |
Compatible with Go 1.15, fix unit test failed on Windows and fixed #689 potential race condition
Diffstat (limited to 'cell_test.go')
-rw-r--r-- | cell_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/cell_test.go b/cell_test.go index fb30596..ba4cd83 100644 --- a/cell_test.go +++ b/cell_test.go @@ -4,12 +4,33 @@ import ( "fmt" "path/filepath" "strconv" + "sync" "testing" "time" "github.com/stretchr/testify/assert" ) +func TestConcurrency(t *testing.T) { + f := NewFile() + wg := new(sync.WaitGroup) + for i := 1; i <= 5; i++ { + wg.Add(1) + go func(val int) { + f.SetCellValue("Sheet1", fmt.Sprintf("A%d", val), val) + f.SetCellValue("Sheet1", fmt.Sprintf("B%d", val), strconv.Itoa(val)) + f.GetCellValue("Sheet1", fmt.Sprintf("A%d", val)) + wg.Done() + }(i) + } + wg.Wait() + val, err := f.GetCellValue("Sheet1", "A1") + if err != nil { + t.Error(err) + } + assert.Equal(t, "1", val) +} + func TestCheckCellInArea(t *testing.T) { f := NewFile() expectedTrueCellInAreaList := [][2]string{ |