1. Adds a `libdevilution_so` target when tests are enabled. 2. Each test file is now a separate binary target linked against `libdevilutionx_so` (can now run tests in parallel). 3. Tests are now defined in a separate `test/CMakeLists.txt` file. 4. Building the tests is now controlled by the standard `BUILD_TESTING` option (defined by CTest). 5. Tests are now built by default. 6. On CI, test errors are now reported. Also: * `.clang-format`: Enable SortIncludes in tests * `path_test.cpp`: Fix -Wsign-compare
41 lines
572 B
C++
41 lines
572 B
C++
/**
|
|
* @file player_test.h
|
|
*
|
|
* Helpers for player related tests.
|
|
*/
|
|
#pragma once
|
|
|
|
#include "items.h"
|
|
#include "player.h"
|
|
|
|
using namespace devilution;
|
|
|
|
static int CountItems(Item *items, int n)
|
|
{
|
|
int count = n;
|
|
for (int i = 0; i < n; i++)
|
|
if (items[i].isEmpty())
|
|
count--;
|
|
|
|
return count;
|
|
}
|
|
|
|
static int Count8(int8_t *ints, int n)
|
|
{
|
|
int count = n;
|
|
for (int i = 0; i < n; i++)
|
|
if (ints[i] == 0)
|
|
count--;
|
|
|
|
return count;
|
|
}
|
|
|
|
static int CountBool(bool *bools, int n)
|
|
{
|
|
int count = n;
|
|
for (int i = 0; i < n; i++)
|
|
if (!bools[i])
|
|
count--;
|
|
|
|
return count;
|
|
}
|