Skip to content

Commit

Permalink
only build testempires, fix time.h
Browse files Browse the repository at this point in the history
time.h extern "C" { ... } stuff was misplaced and would break when
_WIN32 isn't defined
  • Loading branch information
FolkertVanVerseveld committed Feb 5, 2024
1 parent d2f0a9b commit 82dd052
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
submodules: true
- name: configure
run: mkdir build && cd build && cmake ../
- name: make
run: cd build && make; find . -type d
- name: make testempires
run: cd build && make testempires; find . -type d
- name: run
run: ./test/testempires
8 changes: 5 additions & 3 deletions game/src/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

#include <time.h>

#if __cplusplus
extern "C" {
#endif

#if _WIN32
#include <Windows.h>
#include <stdint.h> // portable: uint64_t MSVC: __int64
Expand All @@ -17,9 +21,6 @@
#define exp9 1000000000i64 //1E+9
#define w2ux 116444736000000000i64 //1.jan1601 to 1.jan1970

#if __cplusplus
extern "C" {
#endif

static void unix_time(struct timespec *spec)
{
Expand All @@ -45,6 +46,7 @@ static int clock_gettime(int dummy, struct timespec *spec)
if (!(spec->tv_nsec < exp9)) { spec->tv_sec++; spec->tv_nsec -= exp9; }
return 0;
}

// END code taken from https://stackoverflow.com/questions/5404277/porting-clock-gettime-to-windows
#endif

Expand Down
16 changes: 10 additions & 6 deletions game/tests/sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@ static bool skip_chk_stall = false;
class SDLFixture : public ::testing::Test {
protected:
void SetUp() override {
const char *exp = "test", *got;
#define EXP "test"
const char *got;

SDL_SetError(exp);
if (strcmp(got = SDL_GetError(), exp))
GTEST_SKIP() << "expected \"" << exp << "\", but got \"" << got << "\"";
SDL_SetError(EXP);
if (strcmp(got = SDL_GetError(), EXP))
GTEST_SKIP() << "expected \"" << EXP << "\", but got \"" << got << "\"";

SDL_ClearError();
if (strcmp(got = SDL_GetError(), exp = ""))
GTEST_SKIP() << "expected \"" << exp << "\", but got \"" << got << "\"";
#undef EXP
#define EXP ""
if (strcmp(got = SDL_GetError(), EXP))
GTEST_SKIP() << "expected \"" << EXP << "\", but got \"" << got << "\"";
#undef EXP
}
};

Expand Down

0 comments on commit 82dd052

Please sign in to comment.