server_share_tests.patch
| b/code/CMakeLists.txt Sun Jan 02 12:09:05 2011 +0200 | ||
|---|---|---|
| 197 | 197 | ENDIF(BUILD_DASHBOARD) | 
| 198 | 198 | ENDIF(WITH_NEL_TESTS) | 
| 199 | 199 |  | 
| 200 | IF(WITH_SERVER_SHARE_TESTS) | |
| 201 | ENABLE_TESTING() | |
| 202 |   ADD_TEST(server_share_unit_test ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/server_share_unit_test)
 | |
| 203 | ENDIF(WITH_SERVER_SHARE_TESTS) | |
| 204 |  | |
| 200 | 205 | # packaging information | 
| 201 | 206 | SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "NeL MMORPG Framework") | 
| 202 | 207 | SET(CPACK_PACKAGE_VENDOR "NeL") | 
| b/code/nel/tools/nel_unit_test/nel_unit_test.cpp Sun Jan 02 12:09:05 2011 +0200 | ||
|---|---|---|
| 69 | 69 | {
 | 
| 70 | 70 | if (argc > 2) | 
| 71 | 71 | usage(); // will not return | 
| 72 |  | |
| 72 |  | |
| 73 | 73 | Test::Output* output = 0; | 
| 74 |  | |
| 74 |  | |
| 75 | 75 | if (argc == 1) | 
| 76 | 76 | output = new Test::TextOutput(Test::TextOutput::Verbose); | 
| 77 | 77 | else | 
| b/code/ryzom/tools/CMakeLists.txt Sun Jan 02 12:09:05 2011 +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 | |
| 13 | 14 | IF(WITH_RYZOM_CLIENT) | 
| 14 |   ADD_SUBDIRECTORY(sheets_packer)  | |
| 15 | ADD_SUBDIRECTORY(sheets_packer) | |
| 15 | 16 | ADD_SUBDIRECTORY(client) | 
| 16 | 17 | ENDIF(WITH_RYZOM_CLIENT) | 
| 17 | 18 | |
| b/code/ryzom/tools/tests/CMakeLists.txt Sun Jan 02 12:09:05 2011 +0200 | ||
|---|---|---|
| 1 | ADD_SUBDIRECTORY(server_share_test) | |
| b/code/ryzom/tools/tests/server_share_test/CMakeLists.txt Sun Jan 02 12:09:05 2011 +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} -DCOMMON_DIR="${RZ_SERVER_SRC_DIR}/../../common/") | |
| 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 Sun Jan 02 12:09:05 2011 +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 | #include "ut_mirror_equipment.h" | |
| 11 | ||
| 12 | #include <nel/misc/debug.h> | |
| 13 | ||
| 14 | using namespace std; | |
| 15 | static void usage() | |
| 16 | { | |
| 17 | cout << "usage: mytest [MODE]\n" | |
| 18 | << "where MODE may be one of:\n" | |
| 19 | << " --compiler\n" | |
| 20 | << " --html\n" | |
| 21 | << " --text-terse (default)\n" | |
| 22 | << " --text-verbose\n"; | |
| 23 | exit(0); | |
| 24 | } | |
| 25 | ||
| 26 | static auto_ptr<Test::Output> cmdline(int argc, char* argv[]) | |
| 27 | { | |
| 28 | if (argc > 2) | |
| 29 | usage(); // will not return | |
| 30 | ||
| 31 | Test::Output* output = 0; | |
| 32 | ||
| 33 | if (argc == 1) | |
| 34 | output = new Test::TextOutput(Test::TextOutput::Verbose); | |
| 35 | else | |
| 36 | 	{ | |
| 37 | const char* arg = argv[1]; | |
| 38 | if (strcmp(arg, "--compiler") == 0) | |
| 39 | 		{ | |
| 40 | #ifdef _MSC_VER | |
| 41 | output = new Test::CompilerOutput(Test::CompilerOutput::MSVC, msvDebug); | |
| 42 | #elif defined(__GNUC__) | |
| 43 | output = new Test::CompilerOutput(Test::CompilerOutput::GCC); | |
| 44 | #else | |
| 45 | output = new Test::CompilerOutput; | |
| 46 | #endif | |
| 47 | } | |
| 48 | else if (strcmp(arg, "--html") == 0) | |
| 49 | output = new Test::HtmlOutput; | |
| 50 | else if (strcmp(arg, "--text-terse") == 0) | |
| 51 | output = new Test::TextOutput(Test::TextOutput::Terse); | |
| 52 | else if (strcmp(arg, "--text-verbose") == 0) | |
| 53 | output = new Test::TextOutput(Test::TextOutput::Verbose); | |
| 54 | else | |
| 55 | 		{ | |
| 56 | cout << "invalid commandline argument: " << arg << endl; | |
| 57 | usage(); // will not return | |
| 58 | } | |
| 59 | } | |
| 60 | ||
| 61 | return auto_ptr<Test::Output>(output); | |
| 62 | } | |
| 63 | ||
| 64 | // Main test program | |
| 65 | // | |
| 66 | int main(int argc, char *argv[]) | |
| 67 | { | |
| 68 | ||
| 69 | static const char *outputFileName = "result.html"; | |
| 70 | ||
| 71 | Test::Suite ts; | |
| 72 | ts.add(auto_ptr<Test::Suite>(new CUTTarget)); | |
| 73 | ts.add(auto_ptr<Test::Suite>(new CUTToolType)); | |
| 74 | ts.add(auto_ptr<Test::Suite>(new CUTCreatureSize)); | |
| 75 | ts.add(auto_ptr<Test::Suite>(new CUTPlaceType)); | |
| 76 | ts.add(auto_ptr<Test::Suite>(new CUTItemServiceType)); | |
| 77 | ts.add(auto_ptr<Test::Suite>(new CUTMirrorEquipment)); | |
| 78 | ||
| 79 | // Add a line here when adding a new test MODULE | |
| 80 | ||
| 81 | auto_ptr<Test::Output> output(cmdline(argc, argv)); | |
| 82 | ts.run(*output); | |
| 83 | ||
| 84 | Test::HtmlOutput* const html = dynamic_cast<Test::HtmlOutput*>(output.get()); | |
| 85 | if (html) | |
| 86 | 	  { | |
| 87 | std::ofstream fout(outputFileName); | |
| 88 | html->generate(fout, true, "ServerShareTest"); | |
| 89 | } | |
| 90 | return 0; | |
| 91 | } | |
| b/code/ryzom/tools/tests/server_share_test/ut_creature_size.h Sun Jan 02 12:09:05 2011 +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 Sun Jan 02 12:09:05 2011 +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 | } | |
| 24 | ||
| 25 | void fromString() | |
| 26 |   { | |
| 27 |     TEST_ASSERT(ITEM_SERVICE_TYPE::fromString("StableFeedAnimal1")==ITEM_SERVICE_TYPE::StableFeedAnimal1); | |
| 28 |     TEST_ASSERT(ITEM_SERVICE_TYPE::fromString("StableFeedAnimal2")==ITEM_SERVICE_TYPE::StableFeedAnimal2); | |
| 29 |     TEST_ASSERT(ITEM_SERVICE_TYPE::fromString("StableFeedAnimal3")==ITEM_SERVICE_TYPE::StableFeedAnimal3); | |
| 30 |     TEST_ASSERT(ITEM_SERVICE_TYPE::fromString("StableFeedAnimal4")==ITEM_SERVICE_TYPE::StableFeedAnimal4); | |
| 31 |     TEST_ASSERT(ITEM_SERVICE_TYPE::fromString("StableFeedAllAnimals")==ITEM_SERVICE_TYPE::StableFeedAllAnimals); | |
| 32 |     TEST_ASSERT(ITEM_SERVICE_TYPE::fromString("SpeedUpDPLoss")==ITEM_SERVICE_TYPE::SpeedUpDPLoss); | |
| 33 | } | |
| 34 | }; | |
| 35 | ||
| 36 | #endif | |
| b/code/ryzom/tools/tests/server_share_test/ut_mirror_equipment.h Sun Jan 02 12:09:05 2011 +0200 | ||
|---|---|---|
| 1 | #ifndef UT_MIRROR_EQUIPMENT | |
| 2 | #define UT_MIRROR_EQUIPMENT | |
| 3 | ||
| 4 | #ifndef SHEET_ID_DIR | |
| 5 | #define SHEET_ID_DIR "" | |
| 6 | #endif | |
| 7 | ||
| 8 | #include <server_share/mirror_equipment.h> | |
| 9 | #include "nel/misc/path.h" | |
| 10 | ||
| 11 | class CUTMirrorEquipment: public Test::Suite | |
| 12 | { | |
| 13 | public: | |
| 14 | CUTMirrorEquipment() | |
| 15 |     { | |
| 16 | TEST_ADD(CUTMirrorEquipment::testOperators); | |
| 17 | } | |
| 18 | ||
| 19 | void testOperators() | |
| 20 |   { | |
| 21 | NLMISC::CApplicationContext myApplicationContext; | |
| 22 | NLMISC::CPath::addSearchPath(COMMON_DIR "data_leveldesign/leveldesign/Game_elem"); | |
| 23 | SMirrorEquipment m1(NLMISC::CSheetId(0), 3); | |
| 24 | SMirrorEquipment m2(NLMISC::CSheetId(0), 2); | |
| 25 | SMirrorEquipment m3 = m1; | |
| 26 | TEST_ASSERT(m1==m1); | |
| 27 | TEST_ASSERT(m2==m2); | |
| 28 | TEST_ASSERT(m3==m3); | |
| 29 | TEST_ASSERT(m1==m3); | |
| 30 | TEST_ASSERT(!(m1==m2)); | |
| 31 | TEST_ASSERT(!(m2==m3)); | |
| 32 | TEST_ASSERT(m1!=m2); | |
| 33 | TEST_ASSERT(m2!=m3); | |
| 34 | ||
| 35 | } | |
| 36 | }; | |
| 37 | ||
| 38 | #endif | |
| b/code/ryzom/tools/tests/server_share_test/ut_place_type.h Sun Jan 02 12:09:05 2011 +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::Street)=="Street"); | |
| 21 | TEST_ASSERT(PLACE_TYPE::toString(PLACE_TYPE::Undefined)=="Undefined"); | |
| 22 | } | |
| 23 | ||
| 24 | void testFromString() | |
| 25 |   { | |
| 26 |     TEST_ASSERT(PLACE_TYPE::fromString("Capital")==PLACE_TYPE::Capital); | |
| 27 |     TEST_ASSERT(PLACE_TYPE::fromString("Village")==PLACE_TYPE::Village); | |
| 28 |     TEST_ASSERT(PLACE_TYPE::fromString("Outpost")==PLACE_TYPE::Outpost); | |
| 29 |     TEST_ASSERT(PLACE_TYPE::fromString("Street")==PLACE_TYPE::Street); | |
| 30 |     TEST_ASSERT(PLACE_TYPE::fromString("Undefined")==PLACE_TYPE::Undefined); | |
| 31 | } | |
| 32 | }; | |
| 33 | ||
| 34 | #endif | |
| b/code/ryzom/tools/tests/server_share_test/ut_taming_tool_type.h Sun Jan 02 12:09:05 2011 +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 Sun Jan 02 12:09:05 2011 +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::EveryBody)=="EveryBody"); | |
| 19 | } | |
| 20 | ||
| 21 | void testToTargetRestriction() | |
| 22 |   { | |
| 23 |     TEST_ASSERT(TARGET::stringToTargetRestriction("SelfOnly")==TARGET::SelfOnly); | |
| 24 |     TEST_ASSERT(TARGET::stringToTargetRestriction("EveryBody")==TARGET::EveryBody); | |
| 25 | } | |
| 26 | }; | |
| 27 | ||
| 28 | #endif | |