aboutsummaryrefslogtreecommitdiffstats
path: root/tests/testrenumber.cpp
AgeCommit message (Collapse)Author
2020-01-10code cleanup: add empty table structuresGravatar Dirk Hohndel
It seemed to make sense to combine all three types in one commit. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-06-19Cleanup: move trip-related functions into own translation unitGravatar Berthold Stoeger
These functions were spread out over dive.c and divelist.c. Move them into their own file to make all this a bit less monolithic. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive sites: prepare for dive site ref-countingGravatar Berthold Stoeger
Add a dive site table to each dive site to keep track of dives that have been added to a dive site. Add two functions to add dives to / remove dives from dive sites. Since dive sites now contain a dive table, the order of includes had to be changed: "divesite.h" now includes "dive.h" and not vice-versa. This caused some include churn. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: make undo-system dive site-awareGravatar Berthold Stoeger
As opposed to dive trips, dive sites were always directly added to the global table, even on import. Instead, parse the divesites into a distinct table and merge them on import. Currently, this does not do any merging of dive sites, i.e. dive sites are considered as either equal or different. Nevertheless, merging of data should be rather easy to implement and simply follow the code of the dive merging. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Parser: parse into custom dive site tableGravatar Berthold Stoeger
To extend the undo system to dive sites, the importers and downloaders must not parse directly into the global dive site table. Instead, pass a dive_site_table argument to parse into. For now, always pass the global dive_site_table so that this commit should not cause any functional change. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-19Import: control process_imported_dives() by flagsGravatar Berthold Stoeger
process_imported_dives() takes four boolean parameters. Replace these by flags. This makes the function calls much more descriptive. Morover, it becomes easier to add or remove flags. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-19Import: add add_to_new_trip flag to process_imported_dives()Gravatar Berthold Stoeger
If this flag is set, dives that are not assigned to a trip will be assigned to a new trip. This flag is set if the user checked "add to new trip" in the download dialog of the desktop version. Currently this is a no-op as the dives will already have been added to a new trip by the downloading code. This will be removed in a subsequent commit. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09Import: split process_imported_dives() functionGravatar Berthold Stoeger
Split the process_imported_dives() function in two: 1) process_imported_dives() processes the dives and generates a list of dives and trips to be added and removed. 2) add_imported_dives() calls process_imported_dives() and does the actual removal / addition of dives and trips. The goal is to split preparation and actual work, to make dive import undo-able. The code adds extra checks to never merge into the same dive twice, as this would lead to a double-free() bug. This should in principle never happen, as dives that compare equal according to is_same_dive() are merged in the imported-dives list, but perhaps in some pathologival corner-cases is_same_dive() turns out to be non-transitive. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09Import: add merge_all_trips parameter to process_imported_dives()Gravatar Berthold Stoeger
When importing log-files we generally want to merge trips. But when downloading and the user chose "generate new trip", that new trip should not be merged into existing trips. Therefore, add a "merge_all_trips" parameter to process_imported_dives(). If false only autogenerated trips [via autogroup] will be merged. In the future we might want to let the user choose if trips should be merged when importing log-files. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09Import: merge dives trip-wiseGravatar Berthold Stoeger
The old way of merging log-files was not well defined: Trips were recognized as the same if and only if the first dives started at the same instant. Later dives did not matter. Change this to merge dives if they are overlapping. Moreover, on parsing and download generate trips in a separate trip-table. This will be fundamental for undo of dive-import: Firstly, we don't want to mix trips of imported and not-yet imported dives. Secondly, by merging trip-wise, we can autogroup the dives in the import-data to trips and merge these at once. This will simplify the code to decide to which trip dives should be autogrouped. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09Parser: add trip_table parameter to parsing functionsGravatar Berthold Stoeger
To allow parsing into arbitrary trip_tables, add the corresponding parameter to the parsing functions and the parser state. Currently, all callers pass the global trip_table so there should be no change in functionality. These arguments will be replaced in subsequent commits. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-06Import: pass "downloaded" parameter to process_imported_dives()Gravatar Berthold Stoeger
process_imported_dives() is more efficient for downloaded than for imported (from a file) dives, because it checks only the divecomputer of the first dive. This condition is checked via the "downloaded" flag of the first dive. Instead, pass an argument to process_imported_dives(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-06Core: remove preexisting field from struct dive_tableGravatar Berthold Stoeger
Dives are now in all cases imported via distinct dive_tables. Therefore the "preexisting" marker is useless. Remove. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-06Import: pass a dive table to process_imported_dives()Gravatar Berthold Stoeger
Dives were directly imported into the global dive table and then merged in process_imported_dives(). Make this interface more flexible, by passing an independent dive table. The dive table of the to-be-imported dives will be sorted and merged. Then each dive is inserted in a one-by-one manner to into the global dive table. This actually introduces (at least) two functional changes: 1) If a new dive spans two old dives, it will only be merged to the first dive. But this seems like a pathological case, which is of dubious value anyway. 2) Dives unrelated to the import will not be merged. The old code would happily merge dives that were not even close to the newly imported dives. A surprising behavior. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-09-23Core: split process_dives() in post-import and post-load versionsGravatar Berthold Stoeger
process_dives() is used to post-process the dive table after loading or importing. The first parameter states whether this was after load or import. Especially in the light of undo, load and import are fundamentally different things. Notably, that latter should be undo-able, whereas the former is not. Therefore, as a first step to make import undo-able, split the function in two versions and remove the first parameter. It turns out the the load-version is very light. It only sets the DC nicknames and sorts the dive-table. There seems to be no reason to merge dives. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-23Parse: pass dive_table argument to parse_file()Gravatar Berthold Stoeger
To enable undo of divelog-importing it is crucial that parse_file() can parse into arbitrary dive tables. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-26Whitespace cleanup testsGravatar Dirk Hohndel
Again, entirely script based. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-04-29Add SPDX header to testsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-24Use SUBSURFACE_TEST_DATA definition to point to test data dirGravatar Jeremie Guichard
Update tests with a (compile time) option SUBSURFACE_TEST_DATA, pointing to test data base path. It is needed for cross compilation cases. SUBSURFACE_TEST_DATA is set to SUBSURFACE_SOURCE by default, or configurable via cmake option -DSUBSURFACE_TEST_DATA="...". Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2017-02-05Our tests are actually GUILESSGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05Fix compilation with the new folder architectureGravatar Tomaz Canabrava
A few more fixes for things that broke in commit 7be962bfc287 ("Move subsurface-core to core and qt-mobile to mobile-widgets"). [Dirk Hohndel: slightly edited and overlap with Linus' patch removed] Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-07Remove unnecessary call from testsGravatar Dirk Hohndel
Now that the WindowTitleUpdater is fixed we don't need to create an instance in the tests, either. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-05Add test for import, merge and renumberingGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>