Commit Graph

296 Commits

Author SHA1 Message Date
Martchus 2e93882882 Reduce redundant code in stringconversion.h 2021-05-24 19:51:49 +02:00
Martchus 3afed30760 Detect overflow in functions to convert strings to numbers
Otherwise these functions can strictly run into undefined behavior which
should be prevented.
2021-05-24 19:51:49 +02:00
Martchus 546b1fecb7 Fix parsing ISO timestamp with negative timezone offset and no seconds fraction
See https://github.com/Martchus/syncthingtray/issues/93
2021-05-21 19:40:37 +02:00
Martchus f549285fde Fix splitString()/splitStringSimple() for case of empty trailing part 2021-05-11 16:42:28 +02:00
Martchus 0fb533ffc5 Format attempted test file/dir lookups more nicely in the error case 2021-04-06 17:46:15 +02:00
Martchus f30947cc75 Fix plural of parameter 2021-03-30 20:48:05 +02:00
Martchus 8c033ca243 Fix warnings 2021-03-20 21:56:45 +01:00
Martchus 1f4fabcd9f Add operators '*' and '/' to TimeSpan 2020-10-24 22:10:25 +02:00
Martchus dd41762b70 Add testDirPath() for finding directories with test files
The same as testFilePath(), just for directories.
2020-09-23 22:49:33 +02:00
Martchus 9d59ab5c29 Fix Traits::IsSpecializationOf for references
This check is also supposed to work for references so use the same approach
as for ignoring cv qualifiers.
2020-06-17 21:41:00 +02:00
Martchus 940593429a Allow ArgumentParserTests to pass when working dir present within testfiles dir 2020-06-16 01:03:39 +02:00
Martchus 52722be407 Add test helper execHelperAppInSearchPath() 2020-06-10 18:42:50 +02:00
Martchus 26b0d2d97c Avoid some test classes to show up in the documentation 2020-05-01 13:47:06 +02:00
Martchus 43550b6d55 Add AdvancedIniFile for better preserving certain aspects like comments 2020-05-01 13:47:06 +02:00
Martchus 32780ed6a6 Support formatting ISO timestamps via DateTime::toString() with option to omit defaults
Omitting components are also allowed when parsing ISO timestamps so it makes sense to
have something similar in the other direction as well.

Note that the idea comes from ID3v2.4.0 which stores timestamps in a subset of ISO 8601
similarily to what this library supports and it allows to omit default components as
well.
2020-04-26 21:38:02 +02:00
Martchus c834f8923d Allow omitting month and day when parsing ISO date
This leaves only the year as mandatory component (other components
can already be omitted).
2020-04-24 22:15:49 +02:00
Martchus 73470d0b65 Fix DateTime::fromDateAndTime() for the day 0001-01-01 2020-04-24 21:55:45 +02:00
Martchus 3fe1ea64cf Improve documentation of some test utilities 2020-04-13 23:35:22 +02:00
Martchus 06e29dd751 test utils: Use /proc/self/exe to find srcdirref, at least where supported
So it also works if e.g. chdir() is called before instantiating
the TestApplication.
2020-04-11 22:12:49 +02:00
Martchus 9fe7053869 Print "Executing test" via cppunit.h
Otherwise it is a bit annoying if one just wants to instantiate
a TestApplication for looking up test files.
2020-04-11 21:50:55 +02:00
Martchus e1313c77a0 Add test for fileName() without parent directories 2020-04-11 21:44:07 +02:00
Martchus a7564b8dde Add TESTUTILS_ASSERT_LIKE_FLAGS to pass regex flags 2020-03-02 18:24:06 +01:00
Martchus 8744cf95ef Ensure no copy is made when using argsToString()
It seems that std::make_tuple() is using __decay_and_strip so
the arguments get copied. Using the std::tuple c'tor directly
instead.

When using the %-operator it is already taken care that strings
are stored as pointers and not by value.
2020-02-18 19:29:23 +01:00
Martchus c7c5352325 Use a universal reference to implement dereferenceMaybe() 2020-02-18 19:20:24 +01:00
Martchus 561f298567 Fix string builder tests for Windows 2020-02-14 17:14:06 +01:00
Martchus 1154ed4d1c Improve exception messages of NativeFileStream
So one gets e.g. "open failed: Permission denied" instead of
just "open failed: iostream error".
2020-02-14 17:13:05 +01:00
Martchus 7204bc6f06 Support using string builder with types convertible to target string type
So e.g. std::filesystem::path can be used to build an std::string.
2020-02-13 17:05:46 +01:00
Martchus a5283535cc Support nested tuples in string builder
This is useful to concatenate previously constructed sub
strings passed around as tuples.
2020-01-26 19:02:22 +01:00
Martchus 0cdf2c3492 Use const where possible in code dealing with profiling data 2020-01-12 21:02:43 +01:00
Martchus 1bdc088b54 Close workingCopy in workingCopyPathAs() for correct error handling 2019-12-15 19:01:04 +01:00
Martchus 07ae1588fa Add writeFile()
Due to the required `file.close()` at then end this is easy
to get wrong. So let's add a helper.
2019-12-15 19:00:15 +01:00
Martchus b8a60a0cd4 Support string builder operator '%' for std::string_view 2019-11-28 23:05:55 +01:00
Martchus 8e3aa84780 Support std::string_view in stringbuilder.h 2019-11-28 22:34:10 +01:00
Martchus 085ec2feca Improve DateTime
* Improve documentation about time zone handling
* Add DateTime::toTimeStamp()
* Add experimental DateTime::fromChronoTimePoint()
  and DateTime::fromChronoTimePointGmt()
2019-11-17 22:30:51 +01:00
Martchus 4e3393ee72 Apply clang-format 2019-10-30 23:02:30 +01:00
Martchus a383d7dac5 Use CPPUNIT_ASSERT_EQUAL in IoTests::testBinaryReader() 2019-10-30 20:34:34 +01:00
Martchus 1177381521 Add CppUtilities::endsWith() 2019-10-30 20:34:16 +01:00
Martchus 9a95db3773 Add BinaryReader::readRemainingBytes() 2019-10-30 20:29:26 +01:00
Martchus 2cdde81077 Fix startsWith() if strings are equal 2019-10-27 17:59:26 +01:00
Martchus a841d764d5 Use override in test fixtures 2019-10-13 18:27:41 +02:00
Martchus ecdebebab8 Exclude private structs from documentation 2019-09-04 18:51:17 +02:00
Martchus b693c72eb1 Fix old namespaces being mentioned in the documentation 2019-09-04 18:45:28 +02:00
Martchus 5bed21c9d2 Improve NativeFileStream
* Expose native file descriptor/handle to be able to
  use native APIs like POSIX sendfile()
* Fix using Boost.Iostreams under Windows
    * Make it compile
    * Workaround issue with append flag
2019-08-13 00:28:25 +02:00
Martchus 389a0ef4da Apply clang-format 2019-07-26 22:01:25 +02:00
Martchus 780ba7bc18 Show description in --help 2019-07-22 18:17:39 +02:00
Martchus 1be20da35a Make use of std::filesystem optional
It is not available under Android yet and only used for
Bash completion. So make it optional to support Android by
disabling that part of the Bash completion which is not
useful under Android anyways.
2019-07-02 18:40:25 +02:00
Martchus e71d54d93f Make run the default arg of TestApplication 2019-06-17 21:04:13 +02:00
Martchus 66bb3e5253 Rename TestApplication::m_instance to TestApplication::s_instance 2019-06-17 21:03:37 +02:00
Martchus 7249751d30 Apply clang-format and cmake-format 2019-06-16 16:54:26 +02:00
Martchus fc9e1ff703 Add version header to libraries 2019-06-16 15:33:10 +02:00
Martchus 428a67d68b Improve test application for cppunit
* Allow to list available tests
* Fail the test if at least one explicitely specified unit
  is not available
2019-06-14 18:07:45 +02:00
Martchus b48b2f5c06 Have everything in one top-level namespace 2019-06-10 21:56:46 +02:00
Martchus 4c1b733290 Rework ArgumentParser::parseArgs()
* Remove "ext()" and "orExit()" versions
* Exit by default (might be intrusive but it is the most
  common use)
* Rename Failure to ParseError
2019-06-10 16:03:27 +02:00
Martchus c701fc25ee Remove directoryEntries() 2019-06-05 23:50:38 +02:00
Martchus 83b7658b04 Add test for Bash completion of directory names 2019-06-05 23:49:53 +02:00
Martchus f95e16bc80 Remove readMultibyteTerminatedString*() functions 2019-06-04 19:10:52 +02:00
Martchus 9a66824739 Add read-only accessors to TestApplication 2019-05-15 15:52:06 +02:00
Martchus c904014794 Make math functions templates and move to misc 2019-05-13 22:42:17 +02:00
Martchus f16703ffc0 Remove workingCopyPathMode() 2019-05-11 19:02:32 +02:00
Martchus f0c6035609 Simplify dealing with multiple testfile paths 2019-05-11 18:47:14 +02:00
Martchus b0b92ff1bf Allow marking argument as deprecated 2019-05-04 23:14:43 +02:00
Martchus 6d4e13f2dc Use struct to store global application info 2019-05-04 22:49:57 +02:00
Martchus 04a8ef02d5 Remove deprecated dependencyVersions 2019-05-04 21:44:25 +02:00
Martchus 497826f634 Prevent warnings in argumentparser{,tests}.cpp 2019-05-04 21:44:25 +02:00
Martchus 151a3ae9e5 Apply clang-format 2019-05-04 20:58:23 +02:00
Martchus c4128799bc Fix test for libstd++/Windows NativeFileStream configuration 2019-05-04 15:49:41 +02:00
Martchus e8f5c5c948 Log total test result 2019-05-04 15:47:31 +02:00
Martchus a6fdb3369a Make unsuccessful testFilePath() throw an exception 2019-04-22 20:42:48 +02:00
Martchus 6d7a6ab735 Don't pretent to add arguments implicitely 2019-04-13 20:33:39 +02:00
Martchus cfdfc302db Use exit function passed to argument parser 2019-04-13 20:33:39 +02:00
Martchus 9a50d2b8df Remove types 2019-04-13 20:33:39 +02:00
Marius Kittler 132f936c57 Remove workaround for GCC Bug 66145 2019-04-13 20:33:39 +02:00
Marius Kittler 2f141adb6f Remove random() function 2019-04-13 20:33:39 +02:00
Marius Kittler 07a74d5fa8 Rename openFromFileDescriptor() to open() 2019-04-13 20:33:39 +02:00
Martchus ac8fe5d2c7 Improve constructors for test application 2019-04-13 20:33:39 +02:00
Martchus bc8ea407bc Prevent use of static variables in ArgumentParser
Have --no-color and --help added by default rather
so argument parser is in control over them and don't
has to use static functions.
2019-04-13 20:33:39 +02:00
Martchus 789af62d97 Add workingCopyPathAs() 2019-01-20 22:56:22 +01:00
Martchus d21cde6fe3 Remove unused variable in testFilePath() 2019-01-20 22:16:07 +01:00
Martchus 8b35d06aa7 Improve documentation for testFilePath()/workingCopyPath() 2019-01-20 22:15:35 +01:00
Martchus 757a3476cc test utilities: Print testfile path in all cases 2018-11-02 22:36:22 +01:00
Martchus 98edb5a67c Allow omitting second fraction in DateTime::fromIsoString 2018-11-01 20:20:32 +01:00
Martchus 44e4d1335a Fix Traits::IsSpecializationOf to ignore cv qualifier
So eg. const/volatile std::string is also considered a
specialization of std::basic_string like one would expect.
2018-10-29 23:16:16 +01:00
Martchus 34eac527ee Log actual application path when testing 2018-10-25 18:20:14 +02:00
Martchus ca6663a6d5 Prevent breaking source compatibility of TESTUTILS_ASSERT_EXEC 2018-10-21 21:21:01 +02:00
Martchus 6825e0367f Test Traits::HasOperatorBool 2018-10-21 21:14:51 +02:00
Martchus 66b4b782cd Improve TESTUTILS_ASSERT_EXEC to print stdout/stderr on failure 2018-10-21 20:22:43 +02:00
Martchus 366f722904 Fix documentation for workingCopyPath() 2018-10-07 21:43:34 +02:00
Martchus 17fc55a2c6 Fix compilation of testutils under Windows without NativeFileStream 2018-10-07 21:14:56 +02:00
Martchus 8e32fc0229 Apply clang-format 2018-10-06 16:18:53 +02:00
Martchus 929c817c08 Test test utilities not used anyways 2018-10-06 16:18:46 +02:00
Martchus 61edf58c3e Fix workingCopyPathMode 2018-10-06 16:18:39 +02:00
Martchus 5356d793fc Make all tests pass under Windows
* Workaround some issues
* Disable some tests (better than not running tests
  at all)
2018-10-03 22:37:55 +02:00
Martchus 8e3c40abb5 Make conversion from multi byte to wide string generic 2018-10-03 21:26:41 +02:00
Martchus d1f3f51769 Disable not working test for random under Windows
The function will be removed in next major release anyways.
2018-09-30 14:48:11 +02:00
Martchus 199a4f9454 Make conversion tests pass under Windows 2018-09-30 14:44:39 +02:00
Martchus ac6b7ae68e Fix some of the IO tests to pass under Windows
Still, the workaround for catching std::ios_base::failure
doesn't seem to work.
2018-09-30 14:40:16 +02:00
Martchus 25ef4e28a2 Make tests compile under Windows 2018-09-30 13:55:30 +02:00
Martchus 749eea2ab6 Support NativeFileStream via Boost.Iostreams
So it can also be enabled when not using libstdc++.
2018-09-30 13:55:30 +02:00
Martchus 3d3378c878 Improve experimental value conversion for arg parser
* Fix issues and handle conversion errors
* Add tests
2018-09-22 17:04:23 +02:00
Martchus 826c43ef8b Include missing cerrno 2018-08-12 22:17:09 +02:00