1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334
|
From 2e3e954874443d6f9e307fd31f566e279f4b46db Mon Sep 17 00:00:00 2001
From: Nobuhiro Iwamatsu <iwamatsu@debian.org>
Date: Mon, 31 Dec 2018 21:02:37 +0900
Subject: [PATCH] Change path of test files
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@debian.org>
---
compatibility_test.go | 18 +++++++++----
file_test.go | 61 +++++++++++++++++++++++++++++--------------
lib_test.go | 24 ++++++++++-------
3 files changed, 69 insertions(+), 34 deletions(-)
diff --git a/compatibility_test.go b/compatibility_test.go
index 69a1241..b675af3 100644
--- a/compatibility_test.go
+++ b/compatibility_test.go
@@ -1,6 +1,10 @@
package xlsx
-import . "gopkg.in/check.v1"
+import (
+ "os"
+
+ . "gopkg.in/check.v1"
+)
type GoogleDocsExcelSuite struct{}
@@ -9,7 +13,8 @@ var _ = Suite(&GoogleDocsExcelSuite{})
// Test that we can successfully read an XLSX file generated by
// Google Docs.
func (g *GoogleDocsExcelSuite) TestGoogleDocsExcel(c *C) {
- xlsxFile, err := OpenFile("./testdocs/googleDocsTest.xlsx")
+ wd_path, _ := os.Getwd()
+ xlsxFile, err := OpenFile(wd_path + "/../../../../../testdocs/googleDocsTest.xlsx")
c.Assert(err, IsNil)
c.Assert(xlsxFile, NotNil)
}
@@ -23,7 +28,8 @@ var _ = Suite(&MacExcelSuite{})
// respect the contents of workbook.xml.rels, which maps the sheet IDs
// to their internal file names.
func (m *MacExcelSuite) TestMacExcel(c *C) {
- xlsxFile, err := OpenFile("./testdocs/macExcelTest.xlsx")
+ wd_path, _ := os.Getwd()
+ xlsxFile, err := OpenFile(wd_path + "/../../../../../testdocs/macExcelTest.xlsx")
c.Assert(err, IsNil)
c.Assert(xlsxFile, NotNil)
if val, err := xlsxFile.Sheet["普通技能"].Cell(0, 0).FormattedValue(); err != nil {
@@ -40,7 +46,8 @@ var _ = Suite(&MacNumbersSuite{})
// Test that we can successfully read an XLSX file generated by
// Numbers for Mac.
func (m *MacNumbersSuite) TestMacNumbers(c *C) {
- xlsxFile, err := OpenFile("./testdocs/macNumbersTest.xlsx")
+ wd_path, _ := os.Getwd()
+ xlsxFile, err := OpenFile(wd_path + "/../../../../../testdocs/macNumbersTest.xlsx")
c.Assert(err, IsNil)
c.Assert(xlsxFile, NotNil)
sheet, ok := xlsxFile.Sheet["主动技能"]
@@ -59,7 +66,8 @@ var _ = Suite(&WorksheetSuite{})
// Test that we can successfully read an XLSX file generated by
// Wps on windows. you can download it freely from http://www.wps.cn/
func (w *WpsBlankLineSuite) TestWpsBlankLine(c *C) {
- xlsxFile, err := OpenFile("./testdocs/wpsBlankLineTest.xlsx")
+ wd_path, _ := os.Getwd()
+ xlsxFile, err := OpenFile(wd_path + "/../../../../../testdocs/wpsBlankLineTest.xlsx")
c.Assert(err, IsNil)
c.Assert(xlsxFile, NotNil)
sheet := xlsxFile.Sheet["Sheet1"]
diff --git a/file_test.go b/file_test.go
index 0b7377c..ef50b39 100644
--- a/file_test.go
+++ b/file_test.go
@@ -55,7 +55,8 @@ func (l *FileSuite) TestOpenFile(c *C) {
var xlsxFile *File
var err error
- xlsxFile, err = OpenFile("./testdocs/testfile.xlsx")
+ wd_path, _ := os.Getwd()
+ xlsxFile, err = OpenFile(wd_path + "/../../../../../testdocs/testfile.xlsx")
c.Assert(err, IsNil)
c.Assert(xlsxFile, NotNil)
}
@@ -69,7 +70,8 @@ func (l *FileSuite) TestPartialReadsWithFewSharedStringsOnlyPartiallyReads(c *C)
// to anywhere near a significant amount of 11 million. We're testing that this number is low, to ensure that partial
// reads are fast.
readLimit := 20 * 1000
- reader, size, err := NewReaderAtCounter("testdocs/large_sheet_no_shared_strings_no_dimension_tag.xlsx")
+ wd_path, _ := os.Getwd()
+ reader, size, err := NewReaderAtCounter(wd_path + "/../../../../../testdocs/large_sheet_no_shared_strings_no_dimension_tag.xlsx")
if err != nil {
c.Fatal(err)
}
@@ -95,7 +97,8 @@ func (l *FileSuite) TestPartialReadsWithLargeSharedStringsOnlyPartiallyReads(c *
// to anywhere near a significant amount of 7 million. We're testing that this number is low, to ensure that partial
// reads are fast.
readLimit := int(1.2 * 1000 * 1000)
- reader, size, err := NewReaderAtCounter("testdocs/large_sheet_large_sharedstrings_dimension_tag.xlsx")
+ wd_path, _ := os.Getwd()
+ reader, size, err := NewReaderAtCounter(wd_path + "/../../../../../testdocs/large_sheet_large_sharedstrings_dimension_tag.xlsx")
if err != nil {
c.Fatal(err)
}
@@ -114,7 +117,9 @@ func (l *FileSuite) TestPartialReadsWithLargeSharedStringsOnlyPartiallyReads(c *
func (l *FileSuite) TestPartialReadsWithFewerRowsThanRequested(c *C) {
rowLimit := 10
- file, err := OpenFileWithRowLimit("testdocs/testfile.xlsx", rowLimit)
+
+ wd_path, _ := os.Getwd()
+ file, err := OpenFileWithRowLimit(wd_path + "/../../../../../testdocs/testfile.xlsx", rowLimit)
if err != nil {
c.Fatal(err)
}
@@ -127,13 +132,15 @@ func (l *FileSuite) TestOpenFileWithoutStyleAndSharedStrings(c *C) {
var xlsxFile *File
var error error
- xlsxFile, error = OpenFile("./testdocs/noStylesAndSharedStringsTest.xlsx")
+ wd_path, _ := os.Getwd()
+ xlsxFile, error = OpenFile(wd_path + "/../../../../../testdocs/noStylesAndSharedStringsTest.xlsx")
c.Assert(error, IsNil)
c.Assert(xlsxFile, NotNil)
}
func (l *FileSuite) TestOpenFileWithChartsheet(c *C) {
- xlsxFile, error := OpenFile("./testdocs/testchartsheet.xlsx")
+ wd_path, _ := os.Getwd()
+ xlsxFile, error := OpenFile(wd_path + "/../../../../../testdocs/testchartsheet.xlsx")
c.Assert(error, IsNil)
c.Assert(xlsxFile, NotNil)
}
@@ -144,7 +151,9 @@ func (l *FileSuite) TestOpenFileWithChartsheet(c *C) {
func (l *FileSuite) TestReadSharedStringsFromZipFile(c *C) {
var xlsxFile *File
var err error
- xlsxFile, err = OpenFile("./testdocs/testfile.xlsx")
+
+ wd_path, _ := os.Getwd()
+ xlsxFile, err = OpenFile(wd_path + "/../../../../../testdocs/testfile.xlsx")
c.Assert(err, IsNil)
c.Assert(xlsxFile.referenceTable, NotNil)
}
@@ -174,7 +183,8 @@ func (l *FileSuite) TestReadStylesFromZipFile(c *C) {
var border xlsxBorder
var xf xlsxXf
- xlsxFile, err = OpenFile("./testdocs/testfile.xlsx")
+ wd_path, _ := os.Getwd()
+ xlsxFile, err = OpenFile(wd_path + "/../../../../../testdocs/testfile.xlsx")
c.Assert(err, IsNil)
c.Assert(xlsxFile.styles, NotNil)
@@ -247,7 +257,8 @@ func (l *FileSuite) TestReadWorkbookRelationsFromZipFile(c *C) {
var xlsxFile *File
var err error
- xlsxFile, err = OpenFile("./testdocs/testfile.xlsx")
+ wd_path, _ := os.Getwd()
+ xlsxFile, err = OpenFile(wd_path + "/../../../../../testdocs/testfile.xlsx")
c.Assert(err, IsNil)
c.Assert(len(xlsxFile.Sheets), Equals, 3)
sheet, ok := xlsxFile.Sheet["Tabelle1"]
@@ -262,7 +273,8 @@ func (l *FileSuite) TestGetStyleFromZipFile(c *C) {
var style *Style
var val string
- xlsxFile, err = OpenFile("./testdocs/testfile.xlsx")
+ wd_path, _ := os.Getwd()
+ xlsxFile, err = OpenFile(wd_path + "/../../../../../testdocs/testfile.xlsx")
c.Assert(err, IsNil)
sheetCount := len(xlsxFile.Sheets)
c.Assert(sheetCount, Equals, 3)
@@ -314,7 +326,8 @@ func (l *FileSuite) TestCreateSheet(c *C) {
var err error
var sheet *Sheet
var row *Row
- xlsxFile, err = OpenFile("./testdocs/testfile.xlsx")
+ wd_path, _ := os.Getwd()
+ xlsxFile, err = OpenFile(wd_path + "/../../../../../testdocs/testfile.xlsx")
c.Assert(err, IsNil)
c.Assert(xlsxFile, NotNil)
sheetLen := len(xlsxFile.Sheets)
@@ -379,7 +392,8 @@ func (l *FileSuite) TestAppendSheetWithDuplicateName(c *C) {
// Test that we can read & create a 31 rune sheet name
func (l *FileSuite) TestMaxSheetNameLength(c *C) {
// Open a genuine xlsx created by Microsoft Excel 2007
- xlsxFile, err := OpenFile("./testdocs/max_sheet_name_length.xlsx")
+ wd_path, _ := os.Getwd()
+ xlsxFile, err := OpenFile(wd_path + "/../../../../../testdocs/max_sheet_name_length.xlsx")
c.Assert(err, IsNil)
c.Assert(xlsxFile, NotNil)
c.Assert(xlsxFile.Sheets[0].Name, Equals, "αααααβββββγγγγγδδδδδεεεεεζζζζζη")
@@ -882,19 +896,22 @@ type SliceReaderSuite struct{}
var _ = Suite(&SliceReaderSuite{})
func (s *SliceReaderSuite) TestFileToSlice(c *C) {
- output, err := FileToSlice("./testdocs/testfile.xlsx")
+ wd_path, _ := os.Getwd()
+ output, err := FileToSlice(wd_path + "/../../../../../testdocs/testfile.xlsx")
c.Assert(err, IsNil)
fileToSliceCheckOutput(c, output)
}
func (s *SliceReaderSuite) TestFileToSliceMissingCol(c *C) {
// Test xlsx file with the A column removed
- _, err := FileToSlice("./testdocs/testFileToSlice.xlsx")
+ wd_path, _ := os.Getwd()
+ _, err := FileToSlice(wd_path + "/../../../../../testdocs/testFileToSlice.xlsx")
c.Assert(err, IsNil)
}
func (s *SliceReaderSuite) TestFileObjToSlice(c *C) {
- f, err := OpenFile("./testdocs/testfile.xlsx")
+ wd_path, _ := os.Getwd()
+ f, err := OpenFile(wd_path + "/../../../../../testdocs/testfile.xlsx")
output, err := f.ToSlice()
c.Assert(err, IsNil)
fileToSliceCheckOutput(c, output)
@@ -914,12 +931,13 @@ func fileToSliceCheckOutput(c *C, output [][][]string) {
}
func (s *SliceReaderSuite) TestFileToSliceUnmerged(c *C) {
- output, err := FileToSliceUnmerged("./testdocs/testfile.xlsx")
+ wd_path, _ := os.Getwd()
+ output, err := FileToSliceUnmerged(wd_path + "/../../../../../testdocs/testfile.xlsx")
c.Assert(err, IsNil)
fileToSliceCheckOutput(c, output)
// merged cells
- output, err = FileToSliceUnmerged("./testdocs/merged_cells.xlsx")
+ output, err = FileToSliceUnmerged(wd_path + "/../../../../../testdocs/merged_cells.xlsx")
c.Assert(err, IsNil)
c.Assert(output[0][6][2], Equals, "Happy New Year!")
c.Assert(output[0][6][1], Equals, "Happy New Year!")
@@ -931,7 +949,8 @@ func (l *FileSuite) TestReadWorkbookWithTypes(c *C) {
var xlsxFile *File
var err error
- xlsxFile, err = OpenFile("./testdocs/testcelltypes.xlsx")
+ wd_path, _ := os.Getwd()
+ xlsxFile, err = OpenFile(wd_path + "/../../../../../testdocs/testcelltypes.xlsx")
c.Assert(err, IsNil)
c.Assert(len(xlsxFile.Sheets), Equals, 1)
sheet := xlsxFile.Sheet["Sheet1"]
@@ -985,7 +1004,8 @@ func (l *FileSuite) TestReadWorkbookWithTypes(c *C) {
}
func (s *SliceReaderSuite) TestFileWithEmptyRows(c *C) {
- f, err := OpenFile("./testdocs/empty_rows.xlsx")
+ wd_path, _ := os.Getwd()
+ f, err := OpenFile(wd_path + "/../../../../../testdocs/empty_rows.xlsx")
c.Assert(err, IsNil)
sheet, ok := f.Sheet["EmptyRows"]
c.Assert(ok, Equals, true)
@@ -1003,7 +1023,8 @@ func (s *SliceReaderSuite) TestFileWithEmptyRows(c *C) {
}
func (s *SliceReaderSuite) TestFileWithEmptyCols(c *C) {
- f, err := OpenFile("./testdocs/empty_rows.xlsx")
+ wd_path, _ := os.Getwd()
+ f, err := OpenFile(wd_path + "/../../../../../testdocs/empty_rows.xlsx")
c.Assert(err, IsNil)
sheet, ok := f.Sheet["EmptyCols"]
c.Assert(ok, Equals, true)
diff --git a/lib_test.go b/lib_test.go
index 9d8f5db..8357843 100644
--- a/lib_test.go
+++ b/lib_test.go
@@ -16,14 +16,16 @@ var _ = Suite(&LibSuite{})
// Attempting to open a file without workbook.xml.rels returns an error.
func (l *LibSuite) TestReadZipReaderWithFileWithNoWorkbookRels(c *C) {
- _, err := OpenFile("./testdocs/badfile_noWorkbookRels.xlsx")
+ wd_path, _ := os.Getwd()
+ _, err := OpenFile(wd_path + "/../../../../../testdocs/badfile_noWorkbookRels.xlsx")
c.Assert(err, NotNil)
c.Assert(err.Error(), Equals, "xl/_rels/workbook.xml.rels not found in input xlsx.")
}
// Attempting to open a file with no worksheets returns an error.
func (l *LibSuite) TestReadZipReaderWithFileWithNoWorksheets(c *C) {
- _, err := OpenFile("./testdocs/badfile_noWorksheets.xlsx")
+ wd_path, _ := os.Getwd()
+ _, err := OpenFile(wd_path + "/../../../../../testdocs/badfile_noWorksheets.xlsx")
c.Assert(err, NotNil)
c.Assert(err.Error(), Equals, "Input xlsx contains no worksheets.")
}
@@ -33,7 +35,8 @@ func (l *LibSuite) TestReadWithInlineStrings(c *C) {
var xlsxFile *File
var err error
- xlsxFile, err = OpenFile("./testdocs/inlineStrings.xlsx")
+ wd_path, _ := os.Getwd()
+ xlsxFile, err = OpenFile(wd_path + "/../../../../../testdocs/inlineStrings.xlsx")
c.Assert(err, IsNil)
sheet := xlsxFile.Sheets[0]
r1 := sheet.Rows[0]
@@ -57,7 +60,8 @@ func (l *LibSuite) TestReadWorkbookRelationsFromZipFileWithFunnyNames(c *C) {
var xlsxFile *File
var err error
- xlsxFile, err = OpenFile("./testdocs/testrels.xlsx")
+ wd_path, _ := os.Getwd()
+ xlsxFile, err = OpenFile(wd_path + "/../../../../../testdocs/testrels.xlsx")
c.Assert(err, IsNil)
bob := xlsxFile.Sheet["Bob"]
row1 := bob.Rows[0]
@@ -1340,16 +1344,18 @@ func (l *LibSuite) TestRowNotOverwrittenWhenFollowedByEmptyRow(c *C) {
// This was a specific issue raised by a user.
func (l *LibSuite) TestRoundTripFileWithNoSheetCols(c *C) {
- originalXlFile, err := OpenFile("testdocs/original.xlsx")
+ wd_path, _ := os.Getwd()
+ originalXlFile, err := OpenFile(wd_path + "/../../../../../testdocs/original.xlsx")
c.Assert(err, IsNil)
- originalXlFile.Save("testdocs/after_write.xlsx")
- _, err = OpenFile("testdocs/after_write.xlsx")
+ originalXlFile.Save(wd_path + "/../../../../../testdocs/after_write.xlsx")
+ _, err = OpenFile(wd_path + "/../../../../../testdocs/after_write.xlsx")
c.Assert(err, IsNil)
- os.Remove("testdocs/after_write.xlsx")
+ os.Remove(wd_path + "/../../../../../testdocs/after_write.xlsx")
}
func (l *LibSuite) TestReadRestEmptyRowsFromSheet(c *C) {
- originalXlFile, err := OpenFile("testdocs/empty_rows_in_the_rest.xlsx")
+ wd_path, _ := os.Getwd()
+ originalXlFile, err := OpenFile(wd_path + "/../../../../../testdocs/empty_rows_in_the_rest.xlsx")
c.Assert(err, IsNil)
for _, sheet := range originalXlFile.Sheets {
for _, row := range sheet.Rows {
--
2.20.1
|