43 Commits

Author SHA1 Message Date
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
Clarence "Sparr" Risher 8b27b967ae Replace point constants with static class members 2024-11-26 10:14:26 -05:00
PatrikLundell ef6b53acfb typified a little bit of map.h + dependents (#76340)
* typified a little bit of map.h + dependents
2024-09-27 15:10:36 -07: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 52baacdf7f Replace count_*_flag with has_*_flag (#64759) 2023-04-02 22:56:10 +03:00
Alexey Kim 8032980aa1 Remove 0.G obsoletions from json/items/migration.json 2023-03-22 05:10:11 +02:00
John Bytheway cc8c613f0a Convert various 2D C arrays
For the various 2D C-style arrays, do one of the following:
- Make them a 2D std::array.
- Make them a cata::mdarray.
- Suppress the new clang-tidy warning on them.
2022-08-03 16:51:24 -04:00
Venera3 2c41bdfa83 Add ability to count character flags, move all trait flag checks over to character flag (#55061)
Co-authored-by: Venera3 <Venera3@users.noreply.github.com>
2022-02-03 16:11:48 -08:00
Venera3 dd5ae68efb Modify monster melee targeting (#53089) 2021-12-12 17:22:34 -08:00
John Bytheway e95a4fc9b8 Promote string_id constants to global statics
Our string_id constants were a mixture of temporaries, locals, and
globals.  Pull them all out as globals, for consistency and efficiency.
The efficiency comes from the fact that each string_id instance caches
its respective int_id, and sharing one instance means that value need
not be recomputed.
2021-11-19 19:10:09 -05:00
Curtis Merrill 6a49389678 allow the player to gain and lose limbs (#47561) 2021-08-05 22:39:42 -07: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
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
Ivan Zaitsev 2aac912b30 Housekeeping: remove obsolete mtype::species_ptrs (#45664) 2020-11-27 14:54:50 +03: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
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
Fris0uman 98f32ab0a3 Replace some body_part with bodypart_id (#42677) 2020-08-16 16:16:05 +03:00
John Bytheway 27f4b43c5f Test body_part sorting 2020-08-11 00:56:41 -04:00
Kevin Granade 2684dcbcf1 Merge pull request #42480 from ZhilkinSerg/sa-2020-06-29
Code optimizations reported by static code analysis (2020-06-29)
2020-07-29 23:55:24 +00: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 77377005d0 Use F literal for floats 2020-07-28 22:46:55 +03:00
ZhilkinSerg afa1ed9986 Rename creature_size and make it a class enum 2020-05-30 10:59:58 +03:00
Fris0uman 5a22b480b7 Remove body_part from body part name functions (#40475) 2020-05-17 03:42:01 +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 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
John Bytheway 4760c3febd Fix probabilities in creature_test
The leg weights are not what was listed here.  I'm not sure when this
changed or why, but it's making the tests fail.
2018-12-01 14:26:30 +00:00
John Bytheway 914f5f58db More statistics in creature_test
Model the observations as a binomial distribution explicitly, rather
than using an arbitrary epsilon.

Achieve this via a Catch matcher newly added to test_statistics.h.

Without this change, the tests break when upgrading to Catch2,
presumably because of variation in how the RNG is called.
2018-12-01 12:02:35 +00:00
John Bytheway 3f054ee621 More test feedback on failures
A couple of INFO commands to help understand test failures.
2018-12-01 11:59:26 +00:00
Coolthulhu e39fda29a1 Decrease expected precision of bp_dist test 2017-08-18 19:39:36 +02:00
Coolthulhu bbd137a3a7 Revert mechanical changes for now 2017-08-18 19:19:03 +02:00
Kevin Granade bf076b66fb Still more astyling. 2017-08-05 03:46:17 +00:00
Kevin Granade bc6f67f2da refactor test for ensmallening. 2017-06-07 04:14:15 +00:00
Kevin Granade 9ed50f0791 Style creature_test 2017-06-07 04:14:15 +00:00
Kevin Granade e319f95f99 De-randomize bodypart distribution test. 2017-06-07 04:14:15 +00:00
Kevin Granade 69248ea66a Make clang and mingw happy with parenthization. 2016-03-05 15:35:08 +00:00
Kevin Granade 345896d35c Merge tests into a single executable. 2015-07-22 21:10:56 +00:00
Kevin Granade 80aa41c926 Remove printf statements from test. 2015-07-22 20:20:56 +00:00
MacrosBlackD a8dc410af1 Update creature test with calculated weights 2015-07-22 22:05:56 -05:00
Kevin Granade 04f62c91fb Add a prototype test for limb hit weights. 2015-07-21 19:26:37 +00:00