62 Commits

Author SHA1 Message Date
Kevin Granade 3a78b9d65f Give hordes a little bit of obstacle avoidance ability (#83085) 2025-09-29 18:45:40 -04:00
moxian c44d65a8ae Run IWYU again to pick up the changes 2025-02-11 13:02:19 -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
PatrikLundell befd4486d1 sundry typification (#78985)
* sundry typification

* demanded work around
2025-01-06 22:26:26 -06:00
Clarence "Sparr" Risher 8b27b967ae Replace point constants with static class members 2024-11-26 10:14:26 -05:00
PatrikLundell 456a199f5c typified a bit of map.cpp and dependents 2024-10-08 16:23:15 +02: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
John Bytheway c000771088 Re-enable cata-almost-never-auto
In LLVM 16 this check was a lot more effective.  So, it was briefly
disabled during the migration.  This fixes all its warnings again, and
re-enables it.
2023-05-20 08:55:37 -04: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 51b5b6c052 Enable clang-tidy readability-function-size (#48407)
* Enable readability-function-size

Suppress the remaining cases for functions I don't care to refactor.

* Typo in iteminfo_test
2021-07-03 07:42:05 -07: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
John Bytheway d09ec17d5e Remove uses of srand
The creature_test tests were still using srand to seed the RNG.  This
serves no purpose now since we don't use rand for randomness.  Moreover,
it was causing the tests to fail more often than they used to when this
mattered.

Switch these tests over to rng_set_engine_seed instead, and expand the
existing clang-tidy check looking for uses of rand to also flag uses of
srand (and similar library randomness functions).
2020-10-18 22:49:37 +00:00
Kevin Granade c5ccf0c2c7 IWYU for tests (#42806) 2020-08-09 09:46:57 +03: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 b66068ac0c Add a few more functions for coord_point (#42141)
Things we want to be able to call on these new point types:
* square_dist
* trig_dist
* rl_dist
* manhattan_dist
* direction_from
* line_to
* midpoint

And tests for all the above.
2020-07-16 06:14:07 +00:00
ZhilkinSerg e32c4a8b30 Use constexpr instead of macros 2020-06-15 21:24:43 +03:00
John Bytheway 78cb7c199a Automated refactoring of remaining code 2020-06-12 08:29:42 -04:00
John Bytheway 79e544f702 Port even more functions to point
Previously missed things in the test code.
2020-06-09 08:51:05 -04:00
John Bytheway 5d06b4e69b Port make_xyz_unit to tripoint
Convert make_xyz_unit to take a tripoint argument.

Update callers to be more manifestly correct.
2020-06-08 20:58:47 -04:00
John Bytheway bbf5301cbf Make tripoint <-> direction consistent
The vertical axis was reversed for various functions dealing with
the direction enum, so tests looked illogical and z-coordinates had to
be reversed in one place.

Rationalize this inconsistency, and add some additional tests.
2020-06-08 14:56:22 -04:00
John Bytheway 5c85df16b8 Add [line] tag to line tests
To make testing specific changes easier.
2020-06-08 14:05:47 -04:00
Kevin Granade 97e34b759e Merge branch 'master' into enum-classes-2020-04-11 2020-04-14 23:10:34 +00:00
Kevin Granade 7867cd80f3 Use namespaced math functions (#39553) 2020-04-14 22:09:06 +03:00
ZhilkinSerg 61f0bbbb89 Make direction a class enum 2020-04-13 22:07:42 +03:00
John Bytheway e189957ff2 Run IWYU 20200408 (#39364)
* Helper script to run IWYU

* Run IWYU

* Update deprecated headers

* Run IWYU again

* Re-suppress cxxabi.h

This pragma got accidentally removed because it was deemed to be a
comment attached to a #include.

* Remove extra SDL header includes

* Fix ime.cpp headers

Some tweaks to help IWYU not break this file by messing with
platform-specific stuff not relevant on Linux.

* Update game.h

* Move new point.h includes inside #ifdef

* Re-add platform_win.h to mapsharing.cpp

* Apply suggestions from code review

Co-authored-by: ZhilkinSerg <ZhilkinSerg@users.noreply.github.com>
2020-04-10 12:16:19 +03:00
Alexey Mostovoy 3876adcd0e ignore cata-use-named-point-constants
ignore cata-use-named-point-constants warnings in line_test.cpp
2020-03-17 10:03:19 +04:00
Kevin Granade 82459174ac Add a bresenham test 2020-03-14 05:26:38 +00: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
John Bytheway ee8d5721bf Refactor callers of line functions 2019-08-18 19:59:00 -04:00
John Bytheway 63fcc096e7 Refactor callers 2019-08-18 16:27:15 -04: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 a360c3ae1a clang-tidy modernize-use-nullptr (#32808)
* Remove constructor for quantity from nullptr

This was to allow a zero integer literal to be used as a zero of any
quantity.  But it confuses static analysis into thinking quantity is a
pointer-like type and that nullptr should be used instead, so better to
do without.

You can still use the default constructor or a user-defined literal to
get a zero quantity fairly easily.

* Remove constructor for time_point / _duration from nullptr

This was to allow a zero integer literal to be used as a zero of any
quantity.  But it confuses static analysis into thinking quantity is a
pointer-like type and that nullptr should be used instead, so better to
do without.

You can still use the default constructor or a user-defined literal to
get a zero value fairly easily.  However, to make that true I had to
update the time_duration default constructor to zero-initialize where
previously it might have left the value uninitialized.

* Prefer nullptr as null pointer value

These are changes performed automatically by clang-tidy's
modernize-use-nullptr check.

* Enable modernize-use-nullptr
2019-08-01 18:54:48 +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 a58d75539b Update printf format specifiers
Can't find any format specifier that works portably for int64_t (PRId64
is problematic on MSYS) so just use long longs instead.
2019-06-18 19:10:50 +01:00
John Bytheway e5127560e3 Use int64_t for microsecond counts 2019-06-18 07:43:38 +01:00
John Bytheway d7dd842370 Make some loop counters ints 2019-06-18 07:43:38 +01:00
John Bytheway f3049e5eea Fix missing declarations (#30739)
* Fix missing declarations
Mark functions with no prior declarations as static, and remove the
unused ones.
* Move debug_is_safe_string definition
Put it inside !WIN32 since it's only used there.
2019-05-22 11:00:54 -07:00
John Bytheway e3e7700aef Apply IWYU changes
This is a run of IWYU followed by astyle.
2019-04-22 11:42:51 +01:00
ZhilkinSerg c0bce91fa1 Used const where appropriate 2019-01-06 23:00:08 +03: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 2326eb0fe4 Astyled line_test.cpp 2018-09-08 22:18:05 +00:00
Kevin Granade f270b0749b Correct get_normalized_angle() test. 2015-11-07 16:24:38 +00:00
Kevin Granade b5f31a688d Experimental change to get_normalized_angle(). 2015-11-07 16:24:38 +00:00
Kevin Granade 4eeb849e63 Add squares_closer_to() and a unit test for same. 2015-08-26 20:11:08 +00:00
Kevin Granade e19bb4cc84 Add a basic sanity check for line drawing parameters. 2015-08-10 20:10:17 +00:00
Kevin Granade 5fd2a7ce3d Refactor line and shadowcasting unit tests. 2015-08-10 20:10:16 +00:00
Kevin Granade 0bc8f3157e Remove dependency on clock_gettime() in favor of modern chrono functions. 2015-08-01 10:23:54 +00:00
Kevin Granade 873702868a Use std::srand() for fixing the windows build, hopefully. 2015-07-27 22:19:07 +00:00
Kevin Granade 345896d35c Merge tests into a single executable. 2015-07-22 21:10:56 +00:00