Commit Graph

243 Commits

Author SHA1 Message Date
Martchus f50321f414 Improve coding style in testutils.cpp 2018-07-28 20:00:28 +02:00
Martchus 0f45817956 Make output of workingCopyPathMode() even more verbose 2018-07-28 19:39:11 +02:00
Martchus c53472fdce Make failing TestApplication::workingCopyPathMode() more verbose 2018-07-28 15:59:31 +02:00
Marius Kittler 9743dc7d28 Improve dereferenceMaybe()
* Support smart-pointers and other types which can
  be dereferenced
* Add tests
* Add documentation
2018-07-10 13:17:04 +02:00
Martchus d029b33a19 Add TESTUTILS_ASSERT_LIKE macro 2018-07-02 23:09:52 +02:00
Martchus 27d5041e06 Add Traits::IsSpecializingAnyOf 2018-06-24 20:13:41 +02:00
Martchus 0fb92e3685 Add Traits::None 2018-06-23 14:33:00 +02:00
Martchus e0fee70d58 Print vector<char> and similar in hex notation on assert fail 2018-06-21 23:27:05 +02:00
Martchus e4bf7142f5 Add Traits::Is{Any,None}Of 2018-06-20 23:07:08 +02:00
Martchus 5e8d8cb7d1 Show dashes in suggestions 2018-05-11 16:15:02 +02:00
Martchus 24720bbbc1 Fix passing cursor position to findSuggestions() 2018-05-11 15:51:30 +02:00
Martchus 1aa8b387e1 Apply clang-format 2018-05-08 00:35:51 +02:00
Martchus f0b777207e Fix dependency version under GCC 8 2018-05-08 00:35:41 +02:00
Martchus a4435bbcf3 Fix usage of enable_if with GCC 8
Seems like the trick with the three dots isn't working
with GCC 8 anymore. So let's make it a default template
parameter then.

Not sure whether GCC 8 is here correct and whether this
workaround causes further trouble.
2018-05-07 23:22:43 +02:00
Martchus 8ef92cbf47 Use Levenshtein algo to provide suggestions if arg not found 2018-05-07 21:59:23 +02:00
Martchus 44f0206a13 Refactor ArgumentReader::read()
* Use return-code for error handling
* Improve documentation/comments
* Improve const correctness
2018-05-07 20:04:30 +02:00
Martchus 429de98836 Add algorithm for computing Damerau–Levenshtein distance 2018-05-05 23:26:53 +02:00
Martchus 034b8a75d1 Add min(), max() for any number of arguments 2018-05-05 23:06:51 +02:00
Martchus 52bf075317 Move creation of srcdirref and testfiles dir to BasicConfig
Those make testing more convenient and are also useful when
there's no test target, eg. when testing syncthingtray with
mocked configuration.
2018-05-01 23:59:28 +02:00
Martchus df7a3ee93c Apply clang-format from LLVM 6 2018-03-24 17:00:30 +01:00
Martchus 007235973a Use DateTime::exactGmtNow in stringbuilder benchmark 2018-03-07 18:52:03 +01:00
Martchus da5a027ea3 Add simplified, string_view-compatible version of splitString() 2018-02-28 18:03:07 +01:00
Martchus 3a768508fd Use src dir as fallback unless arg *and* env var specified 2018-02-03 17:16:30 +01:00
Martchus e3310792d3 Improve tests for IO utilities 2018-01-29 16:26:02 +01:00
Martchus bc61461b7a Improve tests of conversion utilities 2018-01-29 16:25:31 +01:00
Martchus 9ed143e7d5 Improve chrono tests 2018-01-29 16:24:17 +01:00
Martchus 368fc46e47 Improve tests of argument parser 2018-01-29 16:23:10 +01:00
Martchus ff5eb6c7c9 Do not show help for --help 2018-01-28 00:43:03 +01:00
Martchus 09f9181281 Split operations from other top-level args in --help 2018-01-28 00:38:05 +01:00
Martchus 37c98b2f91 Allow ~OutputCheck() to throw so assert behaves as expected
* Required because assertion might throw
* No ABI break because not part of ABI anyways
2017-12-11 14:01:40 +01:00
Martchus 26cd303422 Improve period compution 2017-12-03 01:45:54 +01:00
Martchus 602993aa05 Add tests for TimeSpanOutputFormat::TotalSeconds 2017-12-02 22:26:26 +01:00
Martchus a3192a1113 Fix parsing top-level argument after abbreviation 2017-11-29 22:52:50 +01:00
Martchus 4e4e13e4c8 Improve argument parser tests 2017-11-29 20:29:51 +01:00
Martchus 2264ea5cf2 Add trait to check whether type is complete 2017-11-16 02:00:03 +01:00
Martchus cf4789e94d testutils: Allow asserting maps/hashes 2017-11-13 20:06:09 +01:00
Martchus ab42e9d96c Improve documentation of testutils 2017-11-12 16:58:53 +01:00
Martchus cc5d6052f5 test application: Allow to skip argument parsing 2017-11-12 16:17:08 +01:00
Martchus 924481b033 Fix platform check for readFallback...() functions 2017-11-01 19:30:55 +01:00
Martchus 6fd2603cff teat application: Prevent copying dir entries 2017-11-01 19:17:57 +01:00
Martchus 34f3ebb45d Let tests find the application path without extra args
Currently the path of the application to be tested always had to
be specified either manually using the -a argument or by running
the tests via the build system targets. The first option is annoying
and the second option not so nice when using Qt Creator and the
debugger.

This commit makes tests assume the application to be tested is
called like the test executable itself, just without "_tests"-suffix.
2017-10-30 23:03:43 +01:00
Martchus 2bb4aa36a4 Let tests find the testfiles from sources without extra args
Currently the path of the testfiles always had to be specified
either manually using the -p argument or by running the tests
via the build system targets. The first option is annoying and
the second option not so nice when using Qt Creator and the
debugger.

This commit allows tests to find the testfiles from the source
directory automatically (as fallback). This is achieved by
creating a file containing the path of the source directory
with CMake. Note that this file can only be found if the working
directory is set to the binary directory (default in Qt Creator).
2017-10-30 23:01:07 +01:00
Martchus fa39e2a1aa Add traits to check for reserve() and size() 2017-10-27 18:25:32 +02:00
Martchus dab05bdade Improve coding style in test utilities 2017-10-24 01:02:07 +02:00
Martchus e393af5dbb testutils: Print indices of iteratables (on assert equal fail) 2017-10-23 01:11:11 +02:00
Martchus 2ec3df889f Allow accessing application path from TestApplication
Make it static because when this function becomes useful,
the (singleton) instance is likely not available.
2017-10-21 21:25:26 +02:00
Martchus 46f652ad00 Improve readability of ArgumentReader::read and use Phrases 2017-10-19 00:51:47 +02:00
Martchus b4556c0481 Move OutputCheck to its own header file
* So it can be used in tests for tageditor and
  other applications
* Make it a header-only class so c++utilities
  does not depend on cppunit
2017-09-20 17:09:34 +02:00
Martchus 5f14d55f25 Use Argument::varValueCount to fix warnings 2017-09-20 17:07:06 +02:00
Martchus 868162742b Adjust argument parser tests 2017-09-19 16:02:42 +02:00
Martchus e52fd5a4af Apply tidy after updating to clang-format 5.0.0
The behavior of clang-format slightly changed in Clang 5.0.0:
http://releases.llvm.org/5.0.0/tools/clang/docs/ReleaseNotes.html#clang-format
2017-09-17 21:45:23 +02:00
Martchus 840700d7af Fix compiling math tests under 32-bit architectures
Same problem as with size_t. The types must match exactly
when using CPPUNIT_ASSERT_EQUAL and using 'l' or 'ul' suffix
is not sufficient under 32-bit.
2017-09-03 20:13:27 +02:00
Martchus 357ede4ee7 chrono utils: Improve handling micro- and nanoseconds
DateTime and TimeSpan have an accuracy of 100 nanoseconds.

This commit ensures this is also handled in toString() and
fromString() methods and adds relevant convenience methods.
2017-08-31 02:17:05 +02:00
Martchus c88fd9f9a8 Fix calculation of overall test coverage 2017-08-17 17:59:29 +02:00
Martchus 32210c2dca Remove unused header in math tests 2017-08-05 18:34:50 +02:00
Martchus de6b4be8b3 Test math utilities 2017-08-02 13:29:22 +02:00
Martchus 8bed0adc00 Test printing dependency versions 2017-07-28 20:47:49 +02:00
Martchus f2b8ee4184 Test ownership also for BinaryWriter class 2017-07-28 20:35:05 +02:00
Martchus 1d4a4bd2be binary reader/writer: Increase limit of length-prefixed strings
So strings with a size up to 0xFFFFFFFFFFFFFF byte can be handled.
2017-07-28 20:34:50 +02:00
Martchus f4faf652fd Improve argument parser tests 2017-07-28 19:33:55 +02:00
Martchus d7cf4312bf bash completion: Fix case when no current word index specified 2017-07-28 18:24:52 +02:00
Martchus 1af88c964e bash completion: Show values for implicit args
So eg. `tageditor get [tab][tab]` also suggests specifying
field names directly instead of only via --fields.
2017-07-28 17:32:16 +02:00
Martchus 144175bb3a Document necessity to run chrono test with different timezones 2017-07-16 18:34:42 +02:00
Martchus f2189a15ce Make check for DateTime::fromTimeStamp timezone-independent 2017-07-16 18:20:41 +02:00
Martchus 37a8b78689 Update summary of stringbuilder benchmark
So it matches new results of commit
17fe42e0ad
2017-07-11 19:16:32 +02:00
Martchus 442f7a9b25 Exclude generated files from coverage
* So files generated by moc or qdbusxml2cpp are not
  part of coverage statistics
* When filtering files, llvm-cov prints multiple tables
  showing coverage on function level.
  -> Generate overall coverage stats via awk.
2017-07-09 23:38:11 +02:00
Martchus 8b0661713b Improve conversion tests 2017-06-25 16:03:46 +02:00
Martchus 4157f8849a Improve argument parser tests 2017-06-25 16:03:40 +02:00
Martchus a53601e5d0 Improve chrono tests 2017-06-25 16:00:11 +02:00
Martchus 454347c31f Improve IO tests 2017-06-25 16:00:11 +02:00
Martchus f62ed9f63d Test HelpArgument 2017-06-25 01:42:38 +02:00
Martchus 57d5d04d9f Merge prof data of subprocesses created when executing tests
So coverage is accounted correctly when tests create subprocesses
of the application to be tested using execApp().
2017-06-20 23:19:49 +02:00
Martchus ace077f9aa Fix INI test 2017-06-09 12:15:24 +02:00
Martchus 28f37bbbcd string to int: Allow specifying string size 2017-06-08 00:41:29 +02:00
Martchus 045c713cf5 string to int: Ignore whitespaces at beginning 2017-06-08 00:39:54 +02:00
Martchus 5388337bcc Fix compiling tests under 32-bit arch 2017-05-30 23:56:08 +02:00
Martchus 3bc1756425 Add Argument::varValueCount 2017-05-19 00:12:07 +02:00
Martchus 2e98e3bd11 testutils: Fix finding testfiles dir in pwd 2017-05-19 00:08:27 +02:00
Martchus 18fef23724 testutils: Add execHelperApp() 2017-05-19 00:07:38 +02:00
Martchus cab1a76ecf Allow printing iteratable objects
So those can be asserted using CPPUNIT_ASSERT_EQUAL
2017-05-10 23:32:48 +02:00
Martchus 3b74b817ec Add trait to test for strings 2017-05-10 23:31:28 +02:00
Martchus 7faa51c10e Test traits 2017-05-08 19:59:29 +02:00
Martchus db46948f2f Apply clang-format 2017-05-04 22:44:15 +02:00
Martchus 59e20b1043 Apply clang-format 2017-05-01 03:13:11 +02:00
Martchus c728f0ffe0 Add hash functions for chrono objects 2017-05-01 02:54:06 +02:00
Martchus 452954dc1f Add DateTime::exactGmtNow()
* Provides more precise wall-clock time
* Only available under UNIX so far
2017-04-19 21:48:23 +02:00
Martchus 7c189b18e1 Allow nested operation arguments
eg. syncthingctl pwd rescan
2017-04-06 00:04:30 +02:00
Martchus c30011fe09 Fix missleading error message
Unknown arg is treated is causing fatal
error in this case and hence not ignored.
2017-04-05 23:45:56 +02:00
Martchus 52a76a7bd2 Show warning when a testfile could not be located
TODO: Would throwing an exception instead break
something?
2017-03-12 20:25:06 +01:00
Martchus 787d541974 Fix conversion of 0 to string
Return "0" instead of an empty string
2017-03-07 00:28:46 +01:00
Martchus af1ab16d77 Use CPPUNIT_ASSERT_EQUAL where possible 2017-02-06 18:35:20 +01:00
Martchus c4d73b0d7d Use C++14 string literal 2017-02-06 18:32:27 +01:00
Martchus c13eee6fcc Add workingCopyPathMode() to be able to skip actual copy 2017-02-04 20:16:50 +01:00
Martchus 17fe42e0ad string builder: Support integral types directly
Not only convenient but also performance improvement
2017-01-30 00:11:33 +01:00
Martchus 39960ccef1 Add simple benachmark for string builder 2017-01-27 22:16:29 +01:00
Martchus 33d368397f Make use of newly introduced string builder 2017-01-27 18:51:54 +01:00
Martchus 5c004015ce string builder: Fix ambiguity issues 2017-01-27 18:50:51 +01:00
Martchus a772cdf30b Add conveniently usable string builder
which allows fast string building without multiple heap allocations
2017-01-26 22:16:18 +01:00
Martchus 28d2063d33 Fix Bash completion for abbreviations 2016-12-24 16:07:43 +01:00
Martchus cab332bcad Refactor reading arguments
Replace ArgumentParser::readSpecifiedArgs() with
ArgumentReader class to simplify argument list
2016-12-23 22:40:33 +01:00
Martchus 939a43e348 Clean argument parser tests 2016-12-07 21:06:21 +01:00
Martchus 82b5bf3f1d Fix Bash completion when last pre-defined value matches 2016-11-26 00:14:45 +01:00
Martchus 9f3ca443e4 Make ArgumentParser::verifyArgs() more strict 2016-11-15 22:02:40 +01:00
Martchus 4c0a1d1169 Fix minor mistake in argument parser 2016-11-14 22:38:21 +01:00
Martchus 2be349856f Make numberToString/stringToNumber work with u16string
Don't rely on std::basic_stringstream at least for
integral types.
2016-11-13 23:06:03 +01:00
Martchus 5119bb5c6a Improve ArgumentParser::readSpecifiedArgs()
- Fix minor issues
- Add further test cases
2016-10-29 23:54:30 +02:00
Martchus 97925f1252 Don't rely on file completions being in specific order 2016-10-29 00:50:17 +02:00
Martchus 72426e2d4c Fix bash completion when dir/file contains single quote
Also a few other improvements in bash completion code
2016-10-22 20:52:08 +02:00
Martchus a43e9b2baf Fix BitReader test 2016-08-30 19:59:24 +02:00
Martchus 12588c6928 Improve chrono utils
- Support parsing/generating ISO time stamp with
  time zone delta
- Fix minor bugs
- Improve tests
2016-08-30 19:59:04 +02:00
Martchus d6b08b8ed9 Fix decoration for static builds
- Also add improvemnts a few other things in the build system
2016-08-29 15:35:48 +02:00
Martchus 1a4087abbc Use async IO in TestApplication::execApp()
rather than multiple threads
2016-08-15 22:35:37 +02:00
Martchus b36572a4dd Add macro to assert execution of application 2016-08-06 22:02:14 +02:00
Martchus ed527021f9 Improve logging when testing applications 2016-08-05 01:43:46 +02:00
Martchus 994181cbf9 Improve utilities for testing tageditor CLI 2016-08-03 17:31:28 +02:00
Martchus df8d942e1c Improve argument parser
- Fix completion of values already containing '='
- Fix completion when current word contains '='
- Improve formatting of help
- Fix typo
2016-07-31 23:20:31 +02:00
Martchus 17d22be584 Support testing applications 2016-07-30 22:34:31 +02:00
Martchus 0c40a510e5 Add functions for character set conversions 2016-07-27 18:24:37 +02:00
Martchus 23346e1a8e Add convenience method to get first value 2016-07-17 01:26:34 +02:00
Martchus 8efe38dadf Improve details in the build system
- add target to run cross compiled Windows binaries with wine
- quit tests if --help has been specified
2016-07-16 23:04:22 +02:00
Martchus d749ba7cc2 Provide complete occurance info (callbacks) 2016-07-04 23:18:49 +02:00
Martchus 03094a1f61 Add support for bash completion 2016-07-04 02:46:54 +02:00
Martchus cb4246e202 Add methods to get dir path and entries 2016-07-02 02:01:26 +02:00
Martchus e6dfe28149 Skip empty args 2016-06-23 22:06:59 +02:00
Martchus 980794066b Provide workaround for GCC Bug 66145 2016-06-14 22:53:19 +02:00
Martchus 79ce6e9aa6 Improve argument parser
- Fix some implementation details
- Extend tests
2016-06-14 00:43:32 +02:00
Martchus 526cbc5282 Rewrite argument parsing 2016-06-13 00:00:36 +02:00
Martchus 4f87cc1181 Use C-strings where std::string is unneccessary 2016-06-11 19:42:03 +02:00
Martchus d28d477ffe Complete generation of API doc
- Use README.md for main page
- Add install target for API doc
- Improve some doc comments
2016-06-10 22:59:22 +02:00
Martchus 38a9a1e13e Ensure exceptions are thrown in IO tests 2016-06-08 00:15:01 +02:00
Martchus 7bb6875ded Allow testing particular units 2016-05-23 00:03:55 +02:00
Martchus bd0cbd5802 reduce code duplication in build system
- get rid of qmake project file
- provide CMake modules for common tasks
- provide templates for *.desktop files
2016-04-16 02:11:05 +02:00
Martchus 0054a74302 minor adjustments 2016-03-03 19:07:46 +01:00
Martchus 29c0db0090 mingw-w64: workingCopyPath is (currently) not supported 2016-02-27 01:18:54 +01:00
Martchus 78c096e20a added functions to swap the byte order 2016-02-23 19:27:46 +01:00
Martchus 7e780d647a ensure subdirs exist 2016-02-17 20:21:11 +01:00
Martchus a7941b92e2 added BitReader::readUnsignedExpGolombCodedBits() and
BitReader::readSignedExpGolombCodedBits()
2016-02-16 17:25:03 +01:00
Martchus af5b879506 utilize creation of working copies for tests 2016-02-09 02:21:42 +01:00
Martchus 9abe04ce06 make test code public to simplify creation of tests in other projects 2016-02-06 16:55:28 +01:00
Martchus 93582b4ac0 added more tests, fixed some bugs 2016-01-27 02:25:28 +01:00
Martchus 503e4cf3c7 added test for BitReader 2016-01-27 01:14:09 +01:00
Martchus 80a4ce1790 added more test cases 2016-01-27 01:01:43 +01:00
Martchus e4910171e8 added check target and first tests 2016-01-26 18:52:41 +01:00