patch.patch
b/code/CMakeLists.txt Wed Dec 22 22:14:17 2010 +0200 | ||
---|---|---|
197 | 197 |
ENDIF(BUILD_DASHBOARD) |
198 | 198 |
ENDIF(WITH_NEL_TESTS) |
199 |
IF(WITH_SERVER_SHARE_TESTS) |
|
200 |
ENABLE_TESTING() |
|
201 |
ADD_TEST(server_share_unit_test ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/server_share_unit_test) |
|
202 |
ENDIF(WITH_SERVER_SHARE_TESTS) |
|
203 | ||
199 | 204 |
# packaging information |
200 | 205 |
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "NeL MMORPG Framework") |
201 | 206 |
SET(CPACK_PACKAGE_VENDOR "NeL") |
b/code/ryzom/tools/CMakeLists.txt Wed Dec 22 22:14:17 2010 +0200 | ||
---|---|---|
9 | 9 |
ADD_SUBDIRECTORY(patch_gen) |
10 | 10 |
ADD_SUBDIRECTORY(pdr_util) |
11 | 11 |
ADD_SUBDIRECTORY(stats_scan) |
12 |
ADD_SUBDIRECTORY(tests) |
|
12 | 13 |
IF(WITH_RYZOM_CLIENT) |
b/code/ryzom/tools/tests/CMakeLists.txt Wed Dec 22 22:14:17 2010 +0200 | ||
---|---|---|
1 |
ADD_SUBDIRECTORY(server_share_test) |
b/code/ryzom/tools/tests/server_share_test/CMakeLists.txt Wed Dec 22 22:14:17 2010 +0200 | ||
---|---|---|
1 |
FILE(GLOB SRC *.cpp *.h) |
|
2 | ||
3 |
ADD_EXECUTABLE(server_share_unit_test ${SRC}) |
|
4 | ||
5 |
INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${NEL_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CPPTEST_INCLUDE_DIR} ${RZ_SERVER_SRC_DIR}) |
|
6 |
TARGET_LINK_LIBRARIES(server_share_unit_test ryzom_servershare nelmisc nelnet nelligo nelgeorges ${LIBXML2_LIBRARIES} ${CPPTEST_LIBRARIES} ${ZLIB_LIBRARIES}) |
|
7 |
ADD_DEFINITIONS(${LIBXML2_DEFINITIONS}) |
|
8 | ||
9 |
NL_DEFAULT_PROPS(server_share_unit_test "Ryzom, Tools, Misc: server_share_unit_test") |
|
10 |
NL_ADD_RUNTIME_FLAGS(server_share_unit_test) |
|
11 | ||
12 |
INSTALL(TARGETS server_share_unit_test RUNTIME DESTINATION bin COMPONENT tools) |
b/code/ryzom/tools/tests/server_share_test/server_share_unit_test.cpp Wed Dec 22 22:14:17 2010 +0200 | ||
---|---|---|
1 | ||
2 |
#include <fstream> |
|
3 |
#include <cpptest.h> |
|
4 | ||
5 |
#include "ut_target.h" |
|
6 |
#include "ut_taming_tool_type.h" |
|
7 |
#include "ut_creature_size.h" |
|
8 |
#include "ut_place_type.h" |
|
9 |
#include "ut_item_service_type.h" |
|
10 | ||
11 |
#include <nel/misc/debug.h> |
|
12 | ||
13 |
using namespace std; |
|
14 |
static void usage() |
|
15 |
{ |
|
16 |
cout << "usage: mytest [MODE]\n" |
|
17 |
<< "where MODE may be one of:\n" |
|
18 |
<< " --compiler\n" |
|
19 |
<< " --html\n" |
|
20 |
<< " --text-terse (default)\n" |
|
21 |
<< " --text-verbose\n"; |
|
22 |
exit(0); |
|
23 |
} |
|
24 | ||
25 |
static auto_ptr<Test::Output> cmdline(int argc, char* argv[]) |
|
26 |
{ |
|
27 |
if (argc > 2) |
|
28 |
usage(); // will not return |
|
29 | ||
30 |
Test::Output* output = 0; |
|
31 | ||
32 |
if (argc == 1) |
|
33 |
output = new Test::TextOutput(Test::TextOutput::Verbose); |
|
34 |
else |
|
35 |
{ |
|
36 |
const char* arg = argv[1]; |
|
37 |
if (strcmp(arg, "--compiler") == 0) |
|
38 |
{ |
|
39 |
#ifdef _MSC_VER |
|
40 |
output = new Test::CompilerOutput(Test::CompilerOutput::MSVC, msvDebug); |
|
41 |
#elif defined(__GNUC__) |
|
42 |
output = new Test::CompilerOutput(Test::CompilerOutput::GCC); |
|
43 |
#else |
|
44 |
output = new Test::CompilerOutput; |
|
45 |
#endif |
|
46 |
} |
|
47 |
else if (strcmp(arg, "--html") == 0) |
|
48 |
output = new Test::HtmlOutput; |
|
49 |
else if (strcmp(arg, "--text-terse") == 0) |
|
50 |
output = new Test::TextOutput(Test::TextOutput::Terse); |
|
51 |
else if (strcmp(arg, "--text-verbose") == 0) |
|
52 |
output = new Test::TextOutput(Test::TextOutput::Verbose); |
|
53 |
else |
|
54 |
{ |
|
55 |
cout << "invalid commandline argument: " << arg << endl; |
|
56 |
usage(); // will not return |
|
57 |
} |
|
58 |
} |
|
59 | ||
60 |
return auto_ptr<Test::Output>(output); |
|
61 |
} |
|
62 | ||
63 |
// Main test program |
|
64 |
// |
|
65 |
int main(int argc, char *argv[]) |
|
66 |
{ |
|
67 | ||
68 |
static const char *outputFileName = "result.html"; |
|
69 | ||
70 |
Test::Suite ts; |
|
71 |
ts.add(auto_ptr<Test::Suite>(new CUTTarget)); |
|
72 |
ts.add(auto_ptr<Test::Suite>(new CUTToolType)); |
|
73 |
ts.add(auto_ptr<Test::Suite>(new CUTCreatureSize)); |
|
74 |
ts.add(auto_ptr<Test::Suite>(new CUTPlaceType)); |
|
75 |
ts.add(auto_ptr<Test::Suite>(new CUTItemServiceType)); |
|
76 |
// Add a line here when adding a new test MODULE |
|
77 | ||
78 |
auto_ptr<Test::Output> output(cmdline(argc, argv)); |
|
79 |
ts.run(*output); |
|
80 | ||
81 |
Test::HtmlOutput* const html = dynamic_cast<Test::HtmlOutput*>(output.get()); |
|
82 |
if (html) |
|
83 |
{ |
|
84 |
std::ofstream fout(outputFileName); |
|
85 |
html->generate(fout, true, "ServerShareTest"); |
|
86 |
} |
|
87 |
return 0; |
|
88 |
} |
b/code/ryzom/tools/tests/server_share_test/ut_creature_size.h Wed Dec 22 22:14:17 2010 +0200 | ||
---|---|---|
1 |
#ifndef UT_CREATURE_SIZE |
|
2 |
#define UT_CREATURE_SIZE |
|
3 | ||
4 |
#include <server_share/creature_size.h> |
|
5 | ||
6 |
class CUTCreatureSize: public Test::Suite |
|
7 |
{ |
|
8 |
public: |
|
9 |
CUTCreatureSize() |
|
10 |
{ |
|
11 |
TEST_ADD(CUTCreatureSize::testToString); |
|
12 |
TEST_ADD(CUTCreatureSize::testToCreatureSize); |
|
13 |
} |
|
14 | ||
15 |
void testToString() |
|
16 |
{ |
|
17 |
TEST_ASSERT(CREATURE_SIZE::creatureSizeToString(CREATURE_SIZE::SMALL)=="SMALL"); |
|
18 |
TEST_ASSERT(CREATURE_SIZE::creatureSizeToString(CREATURE_SIZE::HOMIN)=="HOMIN"); |
|
19 |
TEST_ASSERT(CREATURE_SIZE::creatureSizeToString(CREATURE_SIZE::BIG)=="BIG"); |
|
20 |
} |
|
21 | ||
22 |
void testToCreatureSize() |
|
23 |
{ |
|
24 |
TEST_ASSERT(CREATURE_SIZE::stringToCreatureSize("SMALL")==CREATURE_SIZE::SMALL); |
|
25 |
TEST_ASSERT(CREATURE_SIZE::stringToCreatureSize("HOMIN")==CREATURE_SIZE::HOMIN); |
|
26 |
TEST_ASSERT(CREATURE_SIZE::stringToCreatureSize("BIG")==CREATURE_SIZE::BIG); |
|
27 |
} |
|
28 |
}; |
|
29 | ||
30 |
#endif |
b/code/ryzom/tools/tests/server_share_test/ut_item_service_type.h Wed Dec 22 22:14:17 2010 +0200 | ||
---|---|---|
1 |
#ifndef UT_ITEM_SERVICE_TYPE |
|
2 |
#define UT_ITEM_SERVICE_TYPE |
|
3 | ||
4 |
#include <server_share/item_service_type.h> |
|
5 | ||
6 |
class CUTItemServiceType: public Test::Suite |
|
7 |
{ |
|
8 |
public: |
|
9 |
CUTItemServiceType() |
|
10 |
{ |
|
11 |
TEST_ADD(CUTItemServiceType::toString); |
|
12 |
TEST_ADD(CUTItemServiceType::fromString); |
|
13 |
} |
|
14 | ||
15 |
void toString() |
|
16 |
{ |
|
17 |
TEST_ASSERT(ITEM_SERVICE_TYPE::toString(ITEM_SERVICE_TYPE::StableFeedAnimal1)=="StableFeedAnimal1"); |
|
18 |
TEST_ASSERT(ITEM_SERVICE_TYPE::toString(ITEM_SERVICE_TYPE::StableFeedAnimal2)=="StableFeedAnimal2"); |
|
19 |
TEST_ASSERT(ITEM_SERVICE_TYPE::toString(ITEM_SERVICE_TYPE::StableFeedAnimal3)=="StableFeedAnimal3"); |
|
20 |
TEST_ASSERT(ITEM_SERVICE_TYPE::toString(ITEM_SERVICE_TYPE::StableFeedAnimal4)=="StableFeedAnimal4"); |
|
21 |
TEST_ASSERT(ITEM_SERVICE_TYPE::toString(ITEM_SERVICE_TYPE::StableFeedAllAnimals)=="StableFeedAllAnimals"); |
|
22 |
TEST_ASSERT(ITEM_SERVICE_TYPE::toString(ITEM_SERVICE_TYPE::SpeedUpDPLoss)=="SpeedUpDPLoss"); |
|
23 |
TEST_ASSERT(ITEM_SERVICE_TYPE::toString(ITEM_SERVICE_TYPE::Unknown)=="Unknown"); |
|
24 |
} |
|
25 | ||
26 |
void fromString() |
|
27 |
{ |
|
28 |
TEST_ASSERT(ITEM_SERVICE_TYPE::fromString("StableFeedAnimal1")==ITEM_SERVICE_TYPE::StableFeedAnimal1); |
|
29 |
TEST_ASSERT(ITEM_SERVICE_TYPE::fromString("StableFeedAnimal2")==ITEM_SERVICE_TYPE::StableFeedAnimal2); |
|
30 |
TEST_ASSERT(ITEM_SERVICE_TYPE::fromString("StableFeedAnimal3")==ITEM_SERVICE_TYPE::StableFeedAnimal3); |
|
31 |
TEST_ASSERT(ITEM_SERVICE_TYPE::fromString("StableFeedAnimal4")==ITEM_SERVICE_TYPE::StableFeedAnimal4); |
|
32 |
TEST_ASSERT(ITEM_SERVICE_TYPE::fromString("StableFeedAllAnimals")==ITEM_SERVICE_TYPE::StableFeedAllAnimals); |
|
33 |
TEST_ASSERT(ITEM_SERVICE_TYPE::fromString("SpeedUpDPLoss")==ITEM_SERVICE_TYPE::SpeedUpDPLoss); |
|
34 |
TEST_ASSERT(ITEM_SERVICE_TYPE::fromString("Unknown")==ITEM_SERVICE_TYPE::Unknown); |
|
35 |
} |
|
36 |
}; |
|
37 | ||
38 |
#endif |
b/code/ryzom/tools/tests/server_share_test/ut_place_type.h Wed Dec 22 22:14:17 2010 +0200 | ||
---|---|---|
1 |
#ifndef UT_PLACETYPE |
|
2 |
#define UT_PLACETYPE |
|
3 | ||
4 |
#include <server_share/place_type.h> |
|
5 | ||
6 |
class CUTPlaceType: public Test::Suite |
|
7 |
{ |
|
8 |
public: |
|
9 |
CUTPlaceType() |
|
10 |
{ |
|
11 |
TEST_ADD(CUTPlaceType::testToString); |
|
12 |
TEST_ADD(CUTPlaceType::testFromString); |
|
13 |
} |
|
14 | ||
15 |
void testToString() |
|
16 |
{ |
|
17 |
TEST_ASSERT(PLACE_TYPE::toString(PLACE_TYPE::Capital)=="Capital"); |
|
18 |
TEST_ASSERT(PLACE_TYPE::toString(PLACE_TYPE::Village)=="Village"); |
|
19 |
TEST_ASSERT(PLACE_TYPE::toString(PLACE_TYPE::Outpost)=="Outpost"); |
|
20 |
TEST_ASSERT(PLACE_TYPE::toString(PLACE_TYPE::Place)=="Place"); |
|
21 |
TEST_ASSERT(PLACE_TYPE::toString(PLACE_TYPE::Street)=="Street"); |
|
22 |
TEST_ASSERT(PLACE_TYPE::toString(PLACE_TYPE::Undefined)=="Undefined"); |
|
23 |
} |
|
24 | ||
25 |
void testFromString() |
|
26 |
{ |
|
27 |
TEST_ASSERT(PLACE_TYPE::fromString("Capital")==PLACE_TYPE::Capital); |
|
28 |
TEST_ASSERT(PLACE_TYPE::fromString("Village")==PLACE_TYPE::Village); |
|
29 |
TEST_ASSERT(PLACE_TYPE::fromString("Outpost")==PLACE_TYPE::Outpost); |
|
30 |
TEST_ASSERT(PLACE_TYPE::fromString("Place")==PLACE_TYPE::Place); |
|
31 |
TEST_ASSERT(PLACE_TYPE::fromString("Street")==PLACE_TYPE::Street); |
|
32 |
TEST_ASSERT(PLACE_TYPE::fromString("Undefined")==PLACE_TYPE::Undefined); |
|
33 |
} |
|
34 |
}; |
|
35 | ||
36 |
#endif |
b/code/ryzom/tools/tests/server_share_test/ut_taming_tool_type.h Wed Dec 22 22:14:17 2010 +0200 | ||
---|---|---|
1 |
#ifndef UT_TAMING_TOOL_TYPE |
|
2 |
#define UT_TAMING_TOOL_TYPE |
|
3 | ||
4 |
#include <server_share/taming_tool_type.h> |
|
5 | ||
6 |
class CUTToolType: public Test::Suite |
|
7 |
{ |
|
8 |
public: |
|
9 |
CUTToolType() |
|
10 |
{ |
|
11 |
TEST_ADD(CUTToolType::testToString); |
|
12 |
TEST_ADD(CUTToolType::testToToolType); |
|
13 |
} |
|
14 | ||
15 |
void testToString() |
|
16 |
{ |
|
17 |
TEST_ASSERT(TAMING_TOOL_TYPE::toString(TAMING_TOOL_TYPE::Unknown)=="Unknown"); |
|
18 |
TEST_ASSERT(TAMING_TOOL_TYPE::toString(TAMING_TOOL_TYPE::Cattleprod)=="Cattleprod"); |
|
19 |
TEST_ASSERT(TAMING_TOOL_TYPE::toString(TAMING_TOOL_TYPE::Stick)=="Stick"); |
|
20 |
TEST_ASSERT(TAMING_TOOL_TYPE::toString(TAMING_TOOL_TYPE::Whip)=="Whip"); |
|
21 |
} |
|
22 | ||
23 |
void testToToolType() |
|
24 |
{ |
|
25 |
TEST_ASSERT(TAMING_TOOL_TYPE::toToolType("Unknown")==TAMING_TOOL_TYPE::Unknown); |
|
26 |
TEST_ASSERT(TAMING_TOOL_TYPE::toToolType("Cattleprod")==TAMING_TOOL_TYPE::Cattleprod); |
|
27 |
TEST_ASSERT(TAMING_TOOL_TYPE::toToolType("Stick")==TAMING_TOOL_TYPE::Stick); |
|
28 |
TEST_ASSERT(TAMING_TOOL_TYPE::toToolType("Whip")==TAMING_TOOL_TYPE::Whip); |
|
29 |
} |
|
30 |
}; |
|
31 | ||
32 |
#endif |
b/code/ryzom/tools/tests/server_share_test/ut_target.h Wed Dec 22 22:14:17 2010 +0200 | ||
---|---|---|
1 |
#ifndef UT_TARGET |
|
2 |
#define UT_TARGET |
|
3 | ||
4 |
#include <server_share/target.h> |
|
5 | ||
6 |
class CUTTarget: public Test::Suite |
|
7 |
{ |
|
8 |
public: |
|
9 |
CUTTarget() |
|
10 |
{ |
|
11 |
TEST_ADD(CUTTarget::testToString); |
|
12 |
TEST_ADD(CUTTarget::testToTargetRestriction); |
|
13 |
} |
|
14 | ||
15 |
void testToString() |
|
16 |
{ |
|
17 |
TEST_ASSERT(TARGET::targetRestrictionToString(TARGET::SelfOnly)=="SelfOnly"); |
|
18 |
TEST_ASSERT(TARGET::targetRestrictionToString(TARGET::TargetRestrictionCount)=="TargetRestrictionCount"); |
|
19 |
} |
|
20 | ||
21 |
void testToTargetRestriction() |
|
22 |
{ |
|
23 |
TEST_ASSERT(TARGET::stringToTargetRestriction("SelfOnly")==TARGET::SelfOnly); |
|
24 |
TEST_ASSERT(TARGET::stringToTargetRestriction("TargetRestrictionCount")==TARGET::TargetRestrictionCount); |
|
25 |
} |
|
26 |
}; |
|
27 | ||
28 |
#endif |