Skip to content

Commit df4d60c

Browse files
committed
Added testing and licensing sections.
1 parent 85605f6 commit df4d60c

File tree

1 file changed

+57
-12
lines changed

1 file changed

+57
-12
lines changed

README.md

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
- [Usage](#usage)
1515
- [Classes](#classes)
1616

17-
# About project
17+
## About project
1818
This is a library for importing and exporting data. Created as a result of the division of Volbx project code and moving parts of it to an independent library. The library contains classes:
1919
+ ExportData (base class for exporting)
2020
+ ExportXlsx
@@ -73,13 +73,13 @@ Check my other project `Volbx` for real world CMake integration.
7373
| Zlib | 1.3.1 | 1.3.1 |
7474
| QuaZip | 1.4 | 1.4 |
7575

76-
# Usage
76+
## Usage
7777
The easiest way is to check the examples' subproject, where you can find how to create and interact with each class included in this library.
7878
Alternatively, tests in a subproject can be checked. Usage can also be found in my other project called Volbx where classes from this library are used for exporting and importing data.
7979

80-
# Classes
81-
## Classes used for importing data
82-
### ImportSpreadsheet
80+
## Classes
81+
### Classes used for importing data
82+
#### ImportSpreadsheet
8383
Base class for spreadsheet-related import classes. The following pure virtual methods need to be implemented when creating a new derived class:
8484
+ `getSheetNames()`
8585
+ `getColumnNames()`
@@ -92,7 +92,7 @@ Base class for spreadsheet-related import classes. The following pure virtual me
9292
Emits signal `progressPercentChanged` during loading data.
9393

9494
Importing can be done from objects with the interface QIODevice: files on disk, files from resources, QBuffer and more.
95-
### ImportXlsx
95+
#### ImportXlsx
9696
Class used to import data from .xlsx files. Basic usage:
9797
```cpp
9898
QFile xlsxFile("example.xlsx");
@@ -101,16 +101,16 @@ auto [success, xlsxData] = importXlsx.getData("SheetName", {});
101101
```
102102
Check `example` and `test` subprojects for more advanced use cases.
103103
Take note that .xlsx files store strings separately. ImportXlsx follows that convention and provides `getSharedStrings()` to retrieve those.
104-
### ImportOds
104+
#### ImportOds
105105
Class used to import data from .ods files. Basic usage:
106106
```cpp
107107
QFile odsFile("example.ods");
108108
ImportOds importOds(odsFile);
109109
auto [success, odsData] = importOds.getData("SheetName", {});
110110
```
111111
Check `example` and `test` subprojects for more advanced use cases.
112-
## Classes used for exporting data
113-
### ExportData
112+
### Classes used for exporting data
113+
#### ExportData
114114
Base class for export-related classes. The following pure virtual methods need to be implemented when creating a new derived class:
115115
+ `writeContent()`
116116
+ `getEmptyContent()`
@@ -128,7 +128,7 @@ QTableWidget tableWidget;
128128
ExportXlsx exportXlsx;
129129
exportXlsx.exportView(tableWidget, exportedZip);
130130
```
131-
### ExportDsv
131+
#### ExportDsv
132132
Class for exporting data to DSV (Delimiter Separated Values) files. The delimiter is set in the constructor and can be any character (comma, tab, semicolon, ...). CSV or TSV files can be created using this class.
133133
Three additional methods can be used to customize the output:
134134
+ `setDateFormat(Qt::DateFormat)` - for setting the output date format to a given one,
@@ -143,7 +143,7 @@ QTableWidget tableWidget;
143143
ExportDsv exportDsv(',');
144144
exportDsv.exportView(tableWidget, outFile);
145145
```
146-
### ExportXlsx
146+
#### ExportXlsx
147147
Class for exporting data to .xlsx files.
148148
Basic usage:
149149
```cpp
@@ -153,4 +153,49 @@ QTableWidget tableWidget;
153153
ExportXlsx exportXlsx;
154154
exportXlsx.exportView(tableWidget, outFile);
155155
```
156-
XLSX files are created using the template file `template.xlsx` included in the project via the resource collection file `resources.qrc`.
156+
XLSX files are created using the template file `template.xlsx` included in the project via the resource collection file `resources.qrc`.
157+
158+
## Testing
159+
For testing purposes, the Qt Test framework is used. Build the project first. Make sure that the `eible-tests` target is built. Modern IDEs supporting CMake also support running tests with monitoring of failures. But in case you would like to run it manually, go to the `build/tests` directory, where the⁣ binary `eible-tests` should be available. Launching it should produce the following output on Linux:
160+
Example run:
161+
```
162+
$ ./eible-tests
163+
********* Start testing of ExportXlsxTest *********
164+
Config: Using QtTest library 6.5.2, Qt 6.5.2 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 10.3.1 20210422 (Red Hat 10.3.1-1)), ubuntu 24.04
165+
PASS : ExportXlsxTest::initTestCase()
166+
PASS : ExportXlsxTest::testExportingEmptyTable()
167+
PASS : ExportXlsxTest::testExportingHeadersOnly()
168+
169+
(...)
170+
171+
PASS : ImportOdsTest::testInvalidSheetName()
172+
PASS : ImportOdsTest::testDamagedFile()
173+
PASS : ImportOdsTest::cleanupTestCase()
174+
Totals: 71 passed, 0 failed, 1 skipped, 0 blacklisted, 142ms
175+
********* Finished testing of ImportOdsTest *********
176+
177+
```
178+
As an alternative, CTest can be used to run tests from the `build/tests` directory:
179+
```
180+
$ ctest
181+
Test project <path>/eible/build/tests
182+
Start 1: eible-tests
183+
1/1 Test #1: eible-tests ...................... Passed 0.29 sec
184+
185+
100% tests passed, 0 tests failed out of 1
186+
187+
Total Test time (real) = 0.29 sec
188+
189+
```
190+
191+
Performance tests for importing and exporting are disabled by default. Search for `QSKIP` and comment lines with that macro to activate it.
192+
193+
## Licensing
194+
Eible library is published under a LGPL license.
195+
196+
The project uses the following software:
197+
| Name | License | Home | Description |
198+
| --- | --- | --- | --- |
199+
| Qt | LGPLv3 | https://www.qt.io/| cross-platform application development framework |
200+
| Zlib | Zlib license | https://www.zlib.net/ | compression library |
201+
| QuaZip | LGPLv2.1 with static linking exception | https://github.com/stachenov/quazip | C++ wrapper for Minizip using Qt library |

0 commit comments

Comments
 (0)