Commit Graph

296 Commits

Author SHA1 Message Date
Martchus 6cb0e63921 Avoid warnings about unused return values by MSVC 2024-02-15 18:40:44 +01:00
Martchus a4be8a56d1 Avoid problems with CppUnit's macros when doing unity builds 2024-02-04 20:56:27 +01:00
Martchus ce31de2c6f Fix tests when making a unity build
The formatting for chrono types needs to be included before CppUnit
headers. This change makes sure of that by simply including that header via
`tests/testutils.h`. The `chrono/format.h` header is not big (including the
header it includes) so this should not be a big deal.
2024-01-30 23:08:14 +01:00
Martchus b526d79eaf Always use a process group in helper for involing test applications
So far only the implementation using Boost.Process was using a process
group; with this change also the implementation using POSIX APIs uses a
process group. This way the code can wait until all sub processes have
terminated.
2024-01-28 21:55:13 +01:00
Martchus c25a3c9c9a Improve error handling when launching test process
* Use `EXIT_FAILURE` instead of an arbitrary exit status
* Print the error message
2024-01-20 17:38:14 +01:00
Martchus c9dea06cfe Remove outdated remarks about `execApp()` and similar test helpers
These functions are supported also on other platforms via Boost.Process.
2024-01-20 17:35:17 +01:00
Martchus 11de58141b Support units in `TimeSpan::fromString()` 2023-11-23 20:20:07 +01:00
Martchus a425363eac Improve `TimeSpan::fromString()`
* Avoid heap allocation and counting separators
* Avoid code repetition
* Throw an exception if too many parts are present (as the documentation
  suggests this function would do)
* Allow emptry separators as this seems useful
2023-11-23 18:48:48 +01:00
Martchus 132d25fbb1 Apply clang-format 2023-08-20 20:29:54 +02:00
Martchus 0349037711 Fix passing non-ASCII arguments in `execApp()` under Windows 2023-08-19 00:11:06 +02:00
Martchus af200403de Support `execApp()` test helper under Windows as well via Boost.Process 2023-08-18 22:57:54 +02:00
Martchus 2137568ad8 Remove debugging leftover in IO tests 2023-08-09 01:26:23 +02:00
Martchus 08a1c5c2eb Close output stream in IO tests before re-opening 2023-06-20 14:03:36 +02:00
Martchus cb5ca77658 Improve test helper for launching an app
* Add helper that allows to specify the exit code (in case a non-zero
  exit code is actually expected)
* Use the proper macros to inspect the status returned by `waitpid()` to
  print/check the exit status correctly
2023-04-29 13:06:31 +02:00
Martchus 2a123df86d Avoid use of non-standard escape character to avoid MSVC warning about it 2023-03-26 21:49:54 +02:00
Martchus bcd5816d23 Apply clang-format and cmake-format 2023-03-25 18:52:13 +01:00
Martchus ec891b48f6 Use `sendfile()` to speed up copying 2023-03-19 20:02:32 +01:00
Martchus ab298b200f Apply clang-format 2023-03-11 17:05:08 +01:00
Martchus 169756fce4 Fix loop-condition in `iotests.cpp` 2023-02-28 21:18:15 +01:00
Martchus 30819d9e85 Improve condition for use of `pubsetbuf`
Using this function like this seems only be possible with `libstdc++`. The
standard lib of MSVC and Clang both don't support this (so it is not just
MSVC and thus not Windows-specific).
2023-02-28 21:17:33 +01:00
Martchus 78d57902a7 Workaround MSVC-specific issues in testsuite so tests pass with MSVC 2023-02-28 00:07:56 +01:00
Martchus 2b6f26895d Support multiple source directories in `srcdirref` file
* Locate test files in all source directories specified in `srcdirref`
* Allow overriding contents of `srcdirref` so the directory of another
  component (within the same repository) can be appended to share testfiles
2023-02-27 18:29:31 +01:00
Martchus a703813b4c Mark helper functions of `testutils.cpp` as static; they're not used elsewhere 2023-02-27 18:29:21 +01:00
Martchus 147d36a578 Improve messages of conversion tests 2023-02-05 21:21:26 +01:00
Martchus 31f369d051 Add signed versions of `swapOrder()` functions 2023-02-05 21:20:53 +01:00
Martchus 024865cc44 Fix building conversion tests with MSVC 2023-02-01 00:42:44 +01:00
Martchus 3a4d71ef5c Avoid unqualified call to `std::move` 2023-01-28 20:20:30 +01:00
Martchus d8c38699ba Avoid warning about unqualified std cast 2022-11-04 16:50:13 +01:00
Martchus 5acf422f71 Add useful operators to `DateTimeExpression`
* Add serialization back to string, useful for implementing
  `TagValue::toString()`
* Add equality comparition
2022-08-13 14:10:40 +02:00
Martchus 5fe03c23a2 Rename `DateTimeParts::Millisecond` to `…::SubSecond`
We're currently just tracking whether the second has a fraction so this is
more fitting.
2022-08-13 14:07:37 +02:00
Martchus f20d596785 Add `DateTimeExpression` to keep track of parsed timestamp parts
The existing timestamp parsers already internally keep track what parts
have been parsed via an index variable. This change exposes this
information as it can sometimes be useful to know what parts were actually
present in the timestamp.
2022-08-12 20:45:06 +02:00
Martchus a1aef36c83 Add `checkFlagEnum()` and tests for `flagenumclass.h` 2022-07-29 22:01:51 +02:00
Martchus 639018285d Fix typos 2022-06-26 11:48:44 +02:00
Martchus 3c769fa242 Add greedy-flag for argument parser
This is useful if one needs to pass subsequent arguments as-is to another
nested argument parser.
2022-06-26 11:24:36 +02:00
Martchus 3444e4bbb1 Improve argument parser tests
* Use auto
* Use `CPPUNIT_ASSERT_EQUAL` with `std::string_view` instead of `strcmp`
  for better error messages in case of a failure
* Avoid instantiating an `std::string` in checks using `std::string_view`
  instead
2022-06-26 11:18:36 +02:00
Martchus c931e2d928 Fix missing `#pragma GCC diagnostic push` 2022-05-21 12:13:01 +02:00
Martchus 7555e6854b Add test helper to use std::optional via CPPUNIT_ASSERT_EQUAL 2022-05-15 02:18:07 +02:00
Martchus c1152ca062 Ignore warning about possible null pointer dereferences appearing with GCC 12
Not sure why this warning is occurring but it is likely incorrect
2022-05-12 20:31:05 +02:00
Martchus f88ca7d16d Silence warning about type conversion in test helper
It is a possibly lossy conversion but good enough for a test helper.
2022-03-20 16:56:11 +01:00
Martchus 052f8d2bd2 Add helper to make native path from internal representaton 2022-03-17 22:31:11 +01:00
Martchus 77c353fb6c Add `TickType` and integer overloads to chrono utilities 2022-02-15 23:01:25 +01:00
Martchus a8fddad804 Add WorkingCopyMode::Cleanup 2022-01-08 23:35:01 +01:00
Martchus f81607be82 Possibly avoid ambiguous function call in conversion tests
This might avoid
```
/Users/oldfaithful/Local/tageditor/cpp-utilities/tests/conversiontests.cpp:29:15: error: call to 'swapOrder' is ambiguous static_assert(swapOrder(0xABCDEF1234567890ul) == 0x9078563412EFCDABul, "swapOrder(uint64)");
```

reported by https://github.com/Martchus/cpp-utilities/issues/22
2021-12-12 22:58:01 +01:00
Martchus 3b0ed313bc Avoid warning about using uninitialized variable 2021-12-11 23:58:51 +01:00
Martchus 15fddad46d Log error when "srcdirref" cannot be opened 2021-08-03 14:05:33 +02:00
Martchus b16fff4b0a Test splitString*() with an empty input 2021-07-24 23:38:44 +02:00
Martchus 6558ff487a Add BufferSearch (from arch-repo-manager) to use it in syncthingtray as well 2021-07-15 02:24:28 +02:00
Martchus b3ebe5ce38 Fix typos found via `codespell --skip .git -w` 2021-07-03 19:07:49 +02:00
Martchus 95202d059a Fix typo 2021-06-04 16:04:26 +02:00
Martchus a116c9e790 Avoid possibility of overflow in DateTime parsing functions
* This is strictly undefined behavior so let's avoid it
* As a side-effect it is now possible to omit the separators in
  DateTime::fromIsoString()
2021-05-24 21:27:18 +02:00