Skip to content

Commit

Permalink
ADDED renderer unit test
Browse files Browse the repository at this point in the history
CHANGED audio unit tests to use libadonthell_audio (if present) instead of rebuilding it
  • Loading branch information
ksterker committed Jun 6, 2010
1 parent 43c754c commit 3fee52b
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/audio/Makefile.am
Expand Up @@ -51,21 +51,21 @@ _sdl_la_DEPENDENCIES = libadonthell_audio.la

## Unit tests
test_CXXFLAGS = $(libgmock_CFLAGS) $(libgtest_CFLAGS)
test_LDADD = $(libgmock_LIBS) $(libgtest_LIBS)
test_LDADD = $(libgmock_LIBS) $(libgtest_LIBS) $(top_builddir)/src/audio/libadonthell_audio.la

test_audio_SOURCES = $(libadonthell_audio_la_SOURCES) test_audio.cc
test_audio_SOURCES = test_audio.cc
test_audio_CXXFLAGS = $(libadonthell_audio_la_CXXFLAGS) $(test_CXXFLAGS)
test_audio_LDADD = $(libadonthell_audio_la_LIBADD) $(test_LDADD)

test_audio_event_SOURCES = $(libadonthell_audio_la_SOURCES) test_audio_event.cc
test_audio_event_SOURCES = test_audio_event.cc
test_audio_event_CXXFLAGS = $(libadonthell_audio_la_CXXFLAGS) $(test_CXXFLAGS)
test_audio_event_LDADD = $(libadonthell_audio_la_LIBADD) $(test_LDADD)

test_audio_manager_SOURCES = $(libadonthell_audio_la_SOURCES) test_audio_manager.cc
test_audio_manager_SOURCES = test_audio_manager.cc
test_audio_manager_CXXFLAGS = $(libadonthell_audio_la_CXXFLAGS) $(test_CXXFLAGS)
test_audio_manager_LDADD = $(libadonthell_audio_la_LIBADD) $(test_LDADD)

test_sound_SOURCES = $(libadonthell_audio_la_SOURCES) test_sound.cc
test_sound_SOURCES = test_sound.cc
test_sound_CXXFLAGS = $(libadonthell_audio_la_CXXFLAGS) $(test_CXXFLAGS)
test_sound_LDADD = $(libadonthell_audio_la_LIBADD) $(test_LDADD)

Expand Down
14 changes: 14 additions & 0 deletions src/world/Makefile.am
Expand Up @@ -73,3 +73,17 @@ libadonthell_world_la_LIBADD = $(PY_LIBS) $(libglog_LIBS) \
$(top_builddir)/src/gfx/libadonthell_gfx.la \
$(top_builddir)/src/rpg/libadonthell_rpg.la \
$(top_builddir)/src/py-runtime/libadonthell_py_runtime.la -lstdc++


## Unit tests
test_CXXFLAGS = $(libgmock_CFLAGS) $(libgtest_CFLAGS)
test_LDADD = $(libgmock_LIBS) $(libgtest_LIBS) $(top_builddir)/src/world/libadonthell_world.la

test_renderer_SOURCES = test_renderer.cc
test_renderer_CXXFLAGS = $(libadonthell_world_la_CXXFLAGS) $(test_CXXFLAGS)
test_renderer_LDADD = $(libadonthell_world_la_LIBADD) $(test_LDADD)

TESTS = \
test_renderer

check_PROGRAMS = $(TESTS)
80 changes: 80 additions & 0 deletions src/world/test_renderer.cc
@@ -0,0 +1,80 @@
/*
Copyright (C) 2010 Kai Sterker <kai.sterker@gmail.com>
Part of the Adonthell Project http://adonthell.linuxgames.com
Adonthell is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Adonthell is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Adonthell; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#include "base/logging.h"
#include <gtest/gtest.h>

#include "world/renderer.h"

namespace world
{
class renderer_Test : public ::testing::Test, public default_renderer
{
protected:
renderer_Test()
{
}

virtual ~renderer_Test()
{
}

// If the constructor and destructor are not enough for setting up
// and cleaning up each test, you can define the following methods:

virtual void SetUp()
{
// Code here will be called immediately after the constructor (right
// before each test).
}

virtual void TearDown()
{
// Code here will be called immediately after each test (right
// before the destructor).
}
}; // class{}

TEST_F(renderer_Test, is_object_below)
{
cube3 c1 (vector3<s_int16>(0, 0, 0), vector3<s_int16>(12, 43, 100));
cube3 c2 (vector3<s_int16>(0, 0, -5), vector3<s_int16>(128, 96, 0));

placeable_shape s1;
s1.add_part (&c1);

placeable_shape s2;
s2.add_part (&c2);

render_info obj1 (&s1, NULL, vector3<s_int32>(250, 341, -100), NULL);
render_info obj2 (&s2, NULL, vector3<s_int32>(256, 288, 0), NULL);

EXPECT_EQ(true, is_object_below (obj1, obj2));
EXPECT_EQ(false, is_object_below (obj2, obj1));
}

} // namespace{}


int main(int argc, char **argv)
{
::google::InitGoogleLogging(argv[0]);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

0 comments on commit 3fee52b

Please sign in to comment.