cyphesis/tests/SpawnEntityTest.cpp

186 lines
3.6 KiB
C++
Raw Permalink Normal View History

2010-03-23 01:20:21 +00:00
// Cyphesis Online RPG Server and AI Engine
// Copyright (C) 2010 Alistair Riddoch
//
// This program 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.
//
// This program 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 this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2011-02-15 09:30:46 +00:00
#ifdef NDEBUG
#undef NDEBUG
#endif
#ifndef DEBUG
#define DEBUG
#endif
2012-12-27 01:02:23 +00:00
#include "TestBase.h"
#include "modules/Location.h"
#include "common/log.h"
2010-03-23 01:20:21 +00:00
#include "server/SpawnEntity.h"
#include "rulesets/AreaProperty.h"
#include "physics/Vector3D.h"
2010-03-23 01:20:21 +00:00
#include <Atlas/Message/Element.h>
#include <wfmath/point.h>
#include <cassert>
2012-12-27 01:02:23 +00:00
class SpawnEntitytest : public Cyphesis::TestBase
{
private:
SpawnEntity * m_spawn;
public:
SpawnEntitytest();
void setup();
void teardown();
void test_constructor();
void test_setup_string();
void test_setup_list();
void test_setup_contains_string();
void test_setup_contains_list();
2012-12-27 01:02:23 +00:00
};
SpawnEntitytest::SpawnEntitytest()
{
ADD_TEST(SpawnEntitytest::test_constructor);
ADD_TEST(SpawnEntitytest::test_setup_string);
ADD_TEST(SpawnEntitytest::test_setup_list);
ADD_TEST(SpawnEntitytest::test_setup_contains_string);
ADD_TEST(SpawnEntitytest::test_setup_contains_list);
2012-12-27 01:02:23 +00:00
}
void SpawnEntitytest::setup()
{
m_spawn = new SpawnEntity(0);
2012-12-27 01:02:23 +00:00
}
void SpawnEntitytest::teardown()
{
delete m_spawn;
2012-12-27 01:02:23 +00:00
}
void SpawnEntitytest::test_constructor()
2010-03-23 01:20:21 +00:00
{
Spawn * s = new SpawnEntity(0);
2010-03-23 01:20:21 +00:00
2012-12-27 01:02:23 +00:00
delete s;
}
void SpawnEntitytest::test_setup_string()
2012-12-27 01:02:23 +00:00
{
Atlas::Message::MapType spawn_data;
spawn_data["character_types"] = "bob";
m_spawn->setup(spawn_data);
2012-12-27 01:02:23 +00:00
}
2010-03-23 01:20:21 +00:00
void SpawnEntitytest::test_setup_list()
2012-12-27 01:02:23 +00:00
{
Atlas::Message::MapType spawn_data;
spawn_data["character_types"] = Atlas::Message::ListType(1, "bob");
m_spawn->setup(spawn_data);
2012-12-27 01:02:23 +00:00
}
2010-03-23 01:20:21 +00:00
void SpawnEntitytest::test_setup_contains_string()
2012-12-27 01:02:23 +00:00
{
Atlas::Message::MapType spawn_data;
spawn_data["contains"] = "bob";
m_spawn->setup(spawn_data);
2012-12-27 01:02:23 +00:00
}
2010-03-23 01:20:21 +00:00
void SpawnEntitytest::test_setup_contains_list()
2012-12-27 01:02:23 +00:00
{
Atlas::Message::MapType spawn_data;
spawn_data["contains"] = Atlas::Message::ListType(1, "bob");
m_spawn->setup(spawn_data);
2012-12-27 01:02:23 +00:00
}
2010-03-23 01:20:21 +00:00
2012-12-27 01:02:23 +00:00
int main()
{
SpawnEntitytest t;
2010-03-23 01:20:21 +00:00
2012-12-27 01:02:23 +00:00
return t.run();
2010-03-23 01:20:21 +00:00
}
2012-12-27 01:02:23 +00:00
// Stubs
2010-03-23 01:20:21 +00:00
2017-08-02 10:03:58 +02:00
#include "stubs/common/stubProperty.h"
2010-03-23 01:20:21 +00:00
void addToEntity(const Point3D & p, std::vector<double> & vd)
{
vd.resize(3);
vd[0] = p[0];
vd[1] = p[1];
vd[2] = p[2];
}
EntityRef::EntityRef(LocatedEntity* e) : m_inner(e)
2010-03-23 01:20:21 +00:00
{
}
EntityRef::EntityRef(const EntityRef& ref) : m_inner(ref.m_inner)
{
}
EntityRef& EntityRef::operator=(const EntityRef& ref)
{
m_inner = ref.m_inner;
return *this;
}
void EntityRef::onEntityDeleted()
{
}
AreaProperty::AreaProperty()
{
}
2010-07-04 11:44:56 +01:00
AreaProperty::~AreaProperty()
{
}
void AreaProperty::set(const Atlas::Message::Element & ent)
{
}
AreaProperty * AreaProperty::copy() const
{
return 0;
}
void AreaProperty::apply(LocatedEntity * owner)
{
}
Location::Location() : m_loc(0)
{
}
void Location::addToEntity(const Atlas::Objects::Entity::RootEntity & ent) const
{
}
void log(LogLevel, const std::string & msg)
{
}