23 Commits

Author SHA1 Message Date
dobbry-vechur 07f34d9ddf Treat inverted tripoint_range bounds as empty
- made tripoint_range end on its first point when min is above max
- made tripoint_range::size() return 0 for inverted bounds
- added inverted bounds tests to map_iterator_test
- added off-map center tests for map::points_in_radius
2026-09-20 09:58:36 +04:00
moxian c44d65a8ae Run IWYU again to pick up the changes 2025-02-11 13:02:19 -08:00
moxian e2f7aaf95f Modernize c headers (stddef.h -> cstddef &co)
Code size:
includes:
$ cat obj/tiles/*.inc | wc
 278247  556494 17375710
$ cat tests/obj/tiles/*.inc | wc
 163745  327490 10307041

post-processed source (clang -E):
./make_preproc.sh src/
65903054 170378741 2049783477
./make_preproc.sh tests/
38434408 100326802 1215849078
2025-02-10 13:56:09 -08:00
moxian 2ee44002fd Mechanically IWYU the tests
python3 ~/github/include-what-you-use/iwyu_tool.py -j5 -p build $( find
src/ tests/ -maxdepth 1 -name '*.cpp' | grep -v -f
tools/iwyu/bad_files.txt )  --  -Xiwyu --comment_style=long -Xiwyu -
-max_line_length=1000 -Xiwyu --cxx17ns -Xiwyu
--mapping_file=../tools/iwyu/cata.imp   | tee out/iwyu/f-a-01.txt >
/dev/null

followed by

cat out/iwyu/f-a-02.txt | python3
~/github/include-what-you-use/fix_includes.py --reorder --nosafe_headers

followed by manual fixups of <stddef.h> -> <cstddef> and similar.

tests/generic_factory_test.cpp gets mangled very badly (IWYU bug) so
it's excluded from the list.

Code size:
includes:
$ cat obj/tiles/*.inc | wc
 288068  576136 17898260
$ cat tests/obj/tiles/*.inc | wc
 167044  334088 10465766

post-processed source (clang -E):
./make_preproc.sh src/
68567896 177775140 2134075721
./make_preproc.sh tests/
39341957 102891720 1243323710
2025-02-10 00:46:57 -08:00
Clarence "Sparr" Risher 8b27b967ae Replace point constants with static class members 2024-11-26 10:14:26 -05:00
Jianxiang Wang (王健翔) f074b39501 Suppress -Wmaybe-uninitialized false positives triggered by lambda's implicit anonymous data structure in debug builds (#66893)
Also remove redundant std::optional used for std::function
2023-07-15 01:27:55 -04:00
Alexey 07356b65a5 Normalize TEST_CASE names (#66241)
* Convert integer parsing test to use normal TEST_CASEs

* Rename test name too similar to another

* Test to enforce normalized test names

* Normalize TEST_CASE names (scripted)
2023-06-17 13:57:19 -03:00
Clarence "Sparr" Risher 2cc0e73953 Fix compiler warning uninitialized anonymous func (#64638) 2023-03-29 20:07:28 -04:00
anothersimulacrum c0f5953bd3 Appease clang-tidy (#57267)
These comments don't work until clang-tidy 14, just apply suggestions
2022-04-29 16:31:20 -04:00
anothersimulacrum 3d98a929a9 Allow applying arbitrary filters to tripoint_range
In the aim of adding a circular points_in_radius function, and allowing
other extension to points_in_radius, expand tripoint_range to take an
(optional) 'predicate' function which determines whether or not a
selected point is 'valid' - whether it belongs in the range.

If a point does not match this predicate, we advance through the rest
of the range until we either find a point which does, or we reach the
end.

Due to the nature of allowing an arbitrary function to determine
membership in the range, the size function has been modified to go
through and manually count all points, otherwise it would not be
accurate. This is the motivation for making the predicate optional, as
opposed to simply using an 'always true' function for when no predicate
is specified.

The non-predicate size function is modified to construct the range
tripoint in a way that works for arbitrary point types, instead of only
tripoints.

The circle function may not be exactly what is expected due to requiring
an integer radius as opposed to a diameter. I did what I believed was
most correct, but others may have other expectations.

There's some template voodoo in the points_in_radius_where function to
allow passing in non-templated lambda functions, as it would be poorly
usable otherwise.
2022-04-26 21:29:57 +00:00
John Bytheway ebd549b300 Fix StringMaker ODR violations in tests
Catch2 provides a customization point for converting our types to
strings by specializing the StringMaker template.

We have some specializations in stringmaker.h, but this feature was only
working intermittently.  I finally figured out that was due to an ODR
violation.  The test files that didn't include stringmaker.h were
compiling a different specialization than the ones that did.

Re-jig the test includes so that any file including catch.hpp also
includes stringmaker.h, thereby ensuring that the custom
specializations are used everywhere and there is no ODR violation.

I achieved this by adding a new cata_catch.h header and making all
existing headers include catch.hpp via the new header.
2021-07-03 07:42:06 -07:00
John Bytheway ebfe558c2a Make more things static
Factor out some variables into a new very-low-weight
cached_options.{h,cpp}.  This helps for users of e.g. test_mode.
2020-09-05 23:13:04 -04: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
John Bytheway 84afc8ef78 Make tripoint_range work for coord_point types
Make the point type of tripoint_range be a template parameter, so that
it can work for coord_point types as well as simple tripoint.

Provide that template parameter wherever needed, and add a test.
2020-07-12 19:26:07 -07:00
ZhilkinSerg e1f432d11f Code style (2020-01-13) (#37021)
* Appease clang
* Remove excessive empty lines
* Remove excessive whitespaces before semicolons
* Remove excessive empty lines (tests)
* Remove excessive whitespaces before semicolons (tests)
2020-01-14 01:31:43 +00:00
John Bytheway 7bda6884c3 Custom clang-tidy check to suggest use of named point constants (#33200)
* Initial version of UseNamedPointConstantsCheck

This is intended to convert hand-rolled point constants like
point( 0, 0 ) into point_zero.

* Apply refactoring pass

* Manual fixup of refactored code

Add various manual tweaks to the automatically refactored code where I
think it makes sense.

* Remove some unnecessary initializations
2019-08-13 23:04:51 +03: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 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 91b8c2dcb4 Misc astyling. 2017-10-13 05:50:05 +00:00
Kevin Granade 345896d35c Merge tests into a single executable. 2015-07-22 21:10:56 +00:00
Kevin Granade 1f10e3c84d Add some minimal map iterator tests. 2015-05-15 20:51:18 +00:00