From 1e255ec19ececda196874f751a81682169cf64c3 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 11 Feb 2012 18:32:53 +0300 Subject: Add support for gtest framework. --- src/Makefile.am | 4 ++++ src/main.cpp | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 204c21bfc..62b762af6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -21,6 +21,10 @@ else manaplus_SOURCES = endif +if ENABLE_UNITTESTS +manaplus_CXXFLAGS += -DUNITTESTS +endif + if USE_INTERNALGUICHAN manaplus_CXXFLAGS += -DUSE_INTERNALGUICHAN manaplus_SOURCES += guichan/include/guichan/actionevent.hpp \ diff --git a/src/main.cpp b/src/main.cpp index dc87ca9e0..f30e7bc62 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -35,6 +35,10 @@ #include "utils/stringutils.h" #include "utils/xml.h" +#ifdef UNITTESTS +#include +#endif + #ifdef __MINGW32__ #include #endif @@ -210,6 +214,8 @@ static void parseOptions(int argc, char *argv[], Client::Options &options) extern "C" char const *_nl_locale_name_default(void); #endif +#ifndef UNITTESTS +// main for normal game usage int main(int argc, char *argv[]) { #if defined(__MINGW32__) @@ -262,3 +268,14 @@ int main(int argc, char *argv[]) return client.testsExec(); } } + +#else + +// main for unit testing +int main(int argc, char **argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} + +#endif -- cgit v1.2.3-60-g2f50