Commit Graph

24 Commits

Author SHA1 Message Date
alef 678cf6afcd Fix string formatter test in MSVC >= 16.2 (#48236) 2021-03-29 00:10:20 +03:00
Binrui Dong 9fdb7ef59c Run IWYU
* Change _ctype.h and __locale to cctype and clocale

* Change _wctype.h to cwctype in game.cpp

* Change __functional_base to functional

* Remove libcxx internal headers

* Remove UNIX system headers

* Fix clang-tidy error with -nostdinc++
2021-02-06 00:18:41 -05:00
Kevin Granade 6d1841ac67 Precompiled Catch2 header (#42453)
* Hoist catch.hpp include to the top of files

* Precompile the catch header in tests
2020-07-29 01:28:26 +03:00
ZhilkinSerg 2fd202b492 Merge pull request #41973 from jbytheway/format_test_tweaks
Tweak string_formatter test for better errors
2020-07-09 22:08:52 +03:00
John Bytheway fe88cf523b Mark string_formatter test [!mayfail]
This is failing on Visual Studio with no sign of a fix coming soon.  The
failure isn't super critical, and the code under test is not likely to
change, so marking this test mayfail should be pretty low risk.
2020-07-09 09:58:00 -04:00
John Bytheway a24465f2ea Tweak string_formatter test for better errors
The existing string_formatter test has a weird behaviour where a bunch
of unrelated things that were CAPTUREd get printed out when any of the
tests fail.  This can be seen in the current Appveyor test failures.  I
think this is actually a Catch2 bug, or possibly a limitation of how
Catch2 implements required-throw tests, but I'm too lazy to investigate
that so I'm just working around it.

Basically, the tests that throw an error are not removing their strings
from Catch2's output state, so they are still printed out for later test
failures even though they are unrelated.

Fix by separating out the throw-based tests into a separate test case.
2020-07-09 09:21:41 -04:00
John Bytheway 095bd51974 Use C++-style includes
Convert all C library includes to their C++ equivalents (stdio.h ->
cstdio, etc.).
2019-12-24 17:04:16 -05:00
Jianxiang Wang (王健翔) 1f0b039c99 Enable the clang-tidy text style check (#34837)
* Disable space check after unicode ellipses

* Fix spacing

* Suppress false positives

* Do not remove spaces before ellipses and colons to suppress false positives

* Fix spacing of raw strings

* Update text style check test

* Enable cata-text-style
2019-10-18 20:26:00 +03:00
John Bytheway 19f0f67928 clang-tidy bugprone-use-after-move (#33557)
* Enable bugprone-use-after-move

Enable this clang-tidy check and deal with associated warnings.

Mostly these were suppressions for things in the tests that are
specifically testing move constructor semantics, but one case was a
genuine latent bug.

* Fix mismatched declaration name

This error seems to have crept into master.
2019-08-26 13:17:04 +03:00
John Bytheway ee9f22ca12 Avoid unnecessary copy initialization
Refactor or suppress clang-tidy warnings about unnecessary
copy-initialization.
2019-07-29 14:36:12 -04:00
John Bytheway 4321c025d2 IWYU 20190629 (#31990)
* Add IWYU pragma: keep

* Run IWYU and astyle

* Run IWYU a second time

* Prevent #include <cxxabi.h>

Unclear why IWYU thinks this is needed.  It isn't, and it causes
problems on Visual Studio.
2019-07-01 12:25:53 +03:00
John Bytheway dfb9ad5ca3 Support printing with ptrdiff_t length modifier
In printf (at least in POSIX) you can print a ptrdiff_t value with e.g.
%td.  Make that an option for our string formatting also.
2019-06-16 21:06:11 +01:00
John Bytheway 65b592c4c2 Disable format warning
This is a true warning, but we don't want to see it because the whole
point of the code is to test whether this non-portable feature works.
2019-05-17 19:28:50 +01:00
John Bytheway e3e7700aef Apply IWYU changes
This is a run of IWYU followed by astyle.
2019-04-22 11:42:51 +01:00
John Bytheway b0576393e3 Sort headers according to IWYU conventions
A first step towards IWYU support.  Doing the sorting first because it
makes reviewing any additions or removals of headers much simpler.

The IWYU order is:
- Associated headers
- Misc system headers
- C++ STL headers
- Other project headers

The biggest change is moving system headers before project headers (they
are usually afterwards in Cata at the moment.

The associated header for a cpp file is the header file which declares
the functions defined in that cpp file.  Normally that's the one which
shares the same name (up to extension), and if so IWYU figures it out
automatically.

However, in this project there are many corner cases, so we need to use
IWYU pragma: associated to tell it which header (or, in some cases,
which headers) is the associated header.  We are unusual in having
multiple associated headers for some files, which might lead to
discovering some interesting IWYU bugs later, but in theory it is
supported.
2019-01-05 14:03:31 +00:00
ZhilkinSerg f8eb2acd05 Optimized includes (tests) 2018-11-07 03:55:47 +03:00
Kevin Granade 9b8fb338c1 Revert "Treat format strings without arguments as pure string" (#25913) 2018-09-30 21:15:53 +00:00
Qrox a477249b44 Update test cases in string_formatter_test.cpp 2018-09-29 23:29:46 +08:00
Kevin Granade 5c5b2a84a4 Disable now-invalid string formatter tests. 2018-04-29 19:51:40 +00:00
BevapDin ba58017770 Merge vstring_format into string_formatter::raw_string_format
That was the only place that actually called it anyway.

Now there is only one function: `raw_string_format` (which is now public in `string_formatter` so the test code can call it).
2018-04-29 19:51:40 +00:00
BevapDin 7486992a4a Fix for mingw builds using format specifier I64 instead of ll
mingw does not use "ll" for `long long int`, one has to use "I64" instead (or "I32" when `long long int` is only 32 bit).
2017-11-03 22:53:27 +01:00
BevapDin f608ac14e6 Don't test raw string format with positional arguments when it's not supported. 2017-11-03 22:53:27 +01:00
BevapDin 4f2a173bc4 Move raw_string_format into class string_formatter
That class is the only place that uses it.
2017-11-03 22:53:25 +01:00
BevapDin 00a6ca2f56 Implement type safe sprintf wrapper string_formatter
- Rename `string_format` to `raw_string_format`.
- Removed the overload of `string_format` that takes a `std::string`. The other overload (taking a `const char*`) will be used instead.

Add `string_formatter` class and helper function `string_format` (which takes the place of the previously removed / renamed version).
As the implementation of it is in another header, include the new header "string_formatter.h" where it is used.

Add tests for the new code.
2017-10-21 14:48:56 +02:00