@@ -1,5 +1,5 @@ | |||||
SUBDIRS = src deushax monsterz tools art gfx | |||||
SUBDIRS = src test deushax monsterz tools art gfx | |||||
DIST_SUBDIRS = $(SUBDIRS) maps | DIST_SUBDIRS = $(SUBDIRS) maps | ||||
EXTRA_DIST = bootstrap build-linux build-mingw | EXTRA_DIST = bootstrap build-linux build-mingw | ||||
@@ -44,6 +44,9 @@ AC_ARG_ENABLE(debug, | |||||
AC_ARG_ENABLE(release, | AC_ARG_ENABLE(release, | ||||
[ --enable-release build final release of the game (default no)]) | [ --enable-release build final release of the game (default no)]) | ||||
AC_ARG_ENABLE(cppunit, | |||||
[ --enable-cppunit use cppunit for unit tests (autodetected)]) | |||||
AC_CHECK_HEADERS(stdio.h stdarg.h inttypes.h endian.h stdint.h getopt.h) | AC_CHECK_HEADERS(stdio.h stdarg.h inttypes.h endian.h stdint.h getopt.h) | ||||
if test "${enable_debug}" = "yes"; then | if test "${enable_debug}" = "yes"; then | ||||
@@ -114,6 +117,12 @@ if test "${ac_cv_my_have_gtkgl}" != "no"; then | |||||
fi | fi | ||||
AM_CONDITIONAL(USE_GTKGL, test "${ac_cv_my_have_gtkgl}" != "no") | AM_CONDITIONAL(USE_GTKGL, test "${ac_cv_my_have_gtkgl}" != "no") | ||||
dnl Use cppunit for unit tests? | |||||
PKG_CHECK_MODULES(CPPUNIT, cppunit, [CPPUNIT="yes"], [CPPUNIT="no"]) | |||||
AM_CONDITIONAL(USE_CPPUNIT, test "$CPPUNIT" = "yes") | |||||
# How to use the Lol Engine inside this tree | # How to use the Lol Engine inside this tree | ||||
LOL_CFLAGS="$LOL_CFLAGS -I \$(top_srcdir)/src $SDL_CFLAGS" | LOL_CFLAGS="$LOL_CFLAGS -I \$(top_srcdir)/src $SDL_CFLAGS" | ||||
LOL_LIBS="$LOL_LIBS $SDL_LIBS" | LOL_LIBS="$LOL_LIBS $SDL_LIBS" | ||||
@@ -129,6 +138,7 @@ AC_SUBST(LOL_LIBS) | |||||
AC_CONFIG_FILES([ | AC_CONFIG_FILES([ | ||||
Makefile | Makefile | ||||
src/Makefile | src/Makefile | ||||
test/Makefile | |||||
monsterz/Makefile | monsterz/Makefile | ||||
deushax/Makefile | deushax/Makefile | ||||
tools/Makefile | tools/Makefile | ||||
@@ -0,0 +1,18 @@ | |||||
AM_CPPFLAGS = -I$(top_srcdir)/src | |||||
if USE_CPPUNIT | |||||
cppunit_tests = lol-test | |||||
endif | |||||
noinst_PROGRAMS = $(cppunit_tests) | |||||
TESTS = $(cppunit_tests) | |||||
lol_test_SOURCES = lol-test.cpp matrix.cpp | |||||
lol_test_CXXFLAGS = $(CPPUNIT_CFLAGS) | |||||
lol_test_CPPFLAGS = @LOL_CFLAGS@ @PIPI_CFLAGS@ | |||||
lol_test_LDADD = $(CPPUNIT_LIBS) | |||||
lol_test_LDFLAGS = $(top_builddir)/src/liblol.a @LOL_LIBS@ @PIPI_LIBS@ | |||||
lol_test_DEPENDENCIES = $(top_builddir)/src/liblol.a | |||||
@@ -0,0 +1,25 @@ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | |||||
#if defined HAVE_CONFIG_H | |||||
# include "config.h" | |||||
#endif | |||||
#include <cppunit/TextTestRunner.h> | |||||
#include <cppunit/extensions/TestFactoryRegistry.h> | |||||
int main(int argc, char *argv[]) | |||||
{ | |||||
CppUnit::TextTestRunner runner; | |||||
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); | |||||
return !runner.run(); | |||||
} | |||||
@@ -0,0 +1,53 @@ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | |||||
#if defined HAVE_CONFIG_H | |||||
# include "config.h" | |||||
#endif | |||||
#include <cppunit/extensions/HelperMacros.h> | |||||
#include <cppunit/TestCaller.h> | |||||
#include <cppunit/TestCase.h> | |||||
#include <cppunit/TestSuite.h> | |||||
#include "core.h" | |||||
class MatrixTest : public CppUnit::TestCase | |||||
{ | |||||
CPPUNIT_TEST_SUITE(MatrixTest); | |||||
CPPUNIT_TEST(test_mat_mul); | |||||
CPPUNIT_TEST_SUITE_END(); | |||||
public: | |||||
MatrixTest() : CppUnit::TestCase("Matrix Test") {} | |||||
void setUp() {} | |||||
void tearDown() {} | |||||
void test_mat_mul() | |||||
{ | |||||
float4 v0(1.0f, 0.0f, 0.0f, 0.0f); | |||||
float4 v1(0.0f, 1.0f, 0.0f, 0.0f); | |||||
float4 v2(0.0f, 0.0f, 1.0f, 0.0f); | |||||
float4 v3(0.0f, 0.0f, 0.0f, 1.0f); | |||||
float4x4 m0(v0, v1, v2, v3); | |||||
float4x4 m1(v0, v1, v2, v3); | |||||
float4x4 m2 = m0 * m1; | |||||
CPPUNIT_ASSERT(m2[0][0] == 1.0f); | |||||
CPPUNIT_ASSERT(m2[1][1] == 1.0f); | |||||
CPPUNIT_ASSERT(m2[2][2] == 1.0f); | |||||
CPPUNIT_ASSERT(m2[3][3] == 1.0f); | |||||
} | |||||
}; | |||||
CPPUNIT_TEST_SUITE_REGISTRATION(MatrixTest); | |||||