Changed: Removed "using namespace" in *.h

This commit is contained in:
kervala 2010-09-25 16:14:34 +02:00
parent c86d923901
commit 4a62ca74e5
15 changed files with 508 additions and 514 deletions

View file

@ -19,8 +19,6 @@
#include <nel/ligo/primitive.h>
using namespace NLLIGO;
#include "ut_ligo_primitive.h"
// Add a line here when adding a new test CLASS

View file

@ -35,8 +35,8 @@ private:
string _RefPrimFileName;
void setup()
{
_RestorePath = CPath::getCurrentPath();
CPath::setCurrentPath(_WorkingPath.c_str());
_RestorePath = NLMISC::CPath::getCurrentPath();
NLMISC::CPath::setCurrentPath(_WorkingPath.c_str());
_RefPrimFileName = "__test_prim.primitive";
@ -79,30 +79,30 @@ private:
fclose(fp);
// init ligo
CPrimitiveContext::instance().CurrentLigoConfig = &_LigoConfig;
NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig = &_LigoConfig;
_LigoConfig.readPrimitiveClass(CLASS_FILE_NAME, false);
// create a reference primitive
if (CFile::isExists(_RefPrimFileName))
if (NLMISC::CFile::isExists(_RefPrimFileName))
{
CFile::deleteFile(_RefPrimFileName);
NLMISC::CFile::deleteFile(_RefPrimFileName);
}
CPrimitives primDoc;
NLLIGO::CPrimitives primDoc;
nlassert(primDoc.RootNode != NULL);
CPrimitiveContext::instance().CurrentPrimitive = &primDoc;
NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = &primDoc;
IPrimitive *p = dynamic_cast<IPrimitive *> (CClassRegistry::create ("CPrimNode"));
p->addPropertyByName("class", new CPropertyString("test"));
p->addPropertyByName("name", new CPropertyString("test_root"));
NLLIGO::IPrimitive *p = dynamic_cast<NLLIGO::IPrimitive *> (NLMISC::CClassRegistry::create ("CPrimNode"));
p->addPropertyByName("class", new NLLIGO::CPropertyString("test"));
p->addPropertyByName("name", new NLLIGO::CPropertyString("test_root"));
primDoc.RootNode->insertChild(p);
CPrimAlias *pa = dynamic_cast<CPrimAlias *> (CClassRegistry::create ("CPrimAlias"));
pa->addPropertyByName("class", new CPropertyString("alias"));
pa->addPropertyByName("name", new CPropertyString("alias"));
NLLIGO::CPrimAlias *pa = dynamic_cast<NLLIGO::CPrimAlias *> (NLMISC::CClassRegistry::create ("CPrimAlias"));
pa->addPropertyByName("class", new NLLIGO::CPropertyString("alias"));
pa->addPropertyByName("name", new NLLIGO::CPropertyString("alias"));
p->insertChild(pa);
CPrimitiveContext::instance().CurrentPrimitive = NULL;
NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = NULL;
// save the file
saveXmlPrimitiveFile(primDoc, _RefPrimFileName);
@ -110,7 +110,7 @@ private:
void tear_down()
{
CPath::setCurrentPath(_RestorePath.c_str());
NLMISC::CPath::setCurrentPath(_RestorePath.c_str());
}
void testAliasGenerator()
@ -121,17 +121,17 @@ private:
// First, load then save the doc
{
CPrimitives primDoc;
NLLIGO::CPrimitives primDoc;
CPrimitiveContext::instance().CurrentPrimitive = &primDoc;
NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = &primDoc;
loadXmlPrimitiveFile(primDoc, _RefPrimFileName, _LigoConfig);
CPrimitiveContext::instance().CurrentPrimitive = NULL;
NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = NULL;
lastGeneratedAlias = primDoc.getLastGeneratedAlias();
// get a copy of the primitive
IPrimitive *prim = NULL;
IPrimitive *primCopy = NULL;
NLLIGO::IPrimitive *prim = NULL;
NLLIGO::IPrimitive *primCopy = NULL;
TEST_ASSERT(primDoc.RootNode->getChild(prim, 0));
if (prim)
{
@ -143,9 +143,9 @@ private:
primDoc.RootNode->removeChild(prim);
// insert the copy
CPrimitiveContext::instance().CurrentPrimitive = &primDoc;
NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = &primDoc;
primDoc.RootNode->insertChild(primCopy);
CPrimitiveContext::instance().CurrentPrimitive = NULL;
NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = NULL;
}
}
@ -155,17 +155,17 @@ private:
// second, reload the file and check the last generated alias
{
CPrimitives primDoc;
NLLIGO::CPrimitives primDoc;
CPrimitiveContext::instance().CurrentPrimitive = &primDoc;
NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = &primDoc;
loadXmlPrimitiveFile(primDoc, _RefPrimFileName, _LigoConfig);
CPrimitiveContext::instance().CurrentPrimitive = NULL;
NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = NULL;
TEST_ASSERT(lastGeneratedAlias == primDoc.getLastGeneratedAlias());
}
}
CLigoConfig _LigoConfig;
NLLIGO::CLigoConfig _LigoConfig;
};
#endif

View file

@ -17,8 +17,6 @@
#ifndef UT_MISC
#define UT_MISC
using namespace NLMISC;
#include "ut_misc_co_task.h"
#include "ut_misc_command.h"
#include "ut_misc_config_file.h"

View file

@ -81,7 +81,7 @@ vector<string> result;
vector<string> result2;
// a simple task
class CTask1 : public CCoTask
class CTask1 : public NLMISC::CCoTask
{
vector<string> &Output;
public:
@ -93,7 +93,7 @@ public:
{
for (uint i=0; i<5; ++i)
{
string s = toString("Task1 : %u", i);
string s = NLMISC::toString("Task1 : %u", i);
Output.push_back(s);
yield();
}
@ -101,7 +101,7 @@ public:
};
// another simple task
class CTask2 : public CCoTask
class CTask2 : public NLMISC::CCoTask
{
vector<string> &Output;
@ -122,7 +122,7 @@ public:
};
// a thread runnable class
class CTaskThread : public IRunnable
class CTaskThread : public NLMISC::IRunnable
{
void run()
{
@ -133,7 +133,7 @@ class CTaskThread : public IRunnable
t1.resume();
string s = NLMISC::toString("Thread : %u", i);
result2.push_back(s);
nlSleep(0);
NLMISC::nlSleep(0);
}
}
};
@ -159,7 +159,7 @@ public:
result2.clear();
CTaskThread tt;
IThread *th = IThread::create(&tt);
NLMISC::IThread *th = NLMISC::IThread::create(&tt);
CTask2 t2;
@ -171,7 +171,7 @@ public:
t2.resume();
string s = NLMISC::toString("Main : %u", i);
result.push_back(s);
nlSleep(0);
NLMISC::nlSleep(0);
}
// wait task completion
@ -213,7 +213,7 @@ public:
// loop and run the main task and the two sub task
for (uint i=0; i<2; ++i)
{
string s = toString("Main : %u", i);
string s = NLMISC::toString("Main : %u", i);
result.push_back(s);
t1.resume();
t2.resume();

View file

@ -21,7 +21,7 @@
vector<string> callList;
class TTest : public ICommandsHandler
class TTest : public NLMISC::ICommandsHandler
{
protected:
std::string _Name;
@ -151,11 +151,11 @@ public:
callList.clear();
ICommand::execute("T4.derivedCommand4", *InfoLog);
NLMISC::ICommand::execute("T4.derivedCommand4", *NLMISC::InfoLog);
TEST_ASSERT(callList.size() == 1);
TEST_ASSERT(callList[0] == "T4.derivedCommand4");
ICommand::execute("T4.theCommand1", *InfoLog);
NLMISC::ICommand::execute("T4.theCommand1", *NLMISC::InfoLog);
TEST_ASSERT(callList.size() == 3);
TEST_ASSERT(callList[1] == "T4.recallBase");
TEST_ASSERT(callList[2] == "T4.theCommand1");
@ -170,28 +170,28 @@ public:
callList.clear();
ICommand::execute("T1.theCommand1", *InfoLog);
NLMISC::ICommand::execute("T1.theCommand1", *NLMISC::InfoLog);
TEST_ASSERT(callList.size() == 1);
TEST_ASSERT(callList[0] == "T1.theCommand1");
ICommand::execute("T1.derivedCommand", *InfoLog);
NLMISC::ICommand::execute("T1.derivedCommand", *NLMISC::InfoLog);
TEST_ASSERT(callList.size() == 2);
TEST_ASSERT(callList[1] == "T1.derivedCommand");
ICommand::execute("T1.commandToOverride", *InfoLog);
NLMISC::ICommand::execute("T1.commandToOverride", *NLMISC::InfoLog);
TEST_ASSERT(callList.size() == 3);
TEST_ASSERT(callList[2] == "T1.commandToOverride");
ICommand::execute("T2.theCommand1", *InfoLog);
NLMISC::ICommand::execute("T2.theCommand1", *NLMISC::InfoLog);
TEST_ASSERT(callList.size() == 4);
TEST_ASSERT(callList[3] == "T2.theCommand1");
ICommand::execute("T2.derivedCommand", *InfoLog);
NLMISC::ICommand::execute("T2.derivedCommand", *NLMISC::InfoLog);
TEST_ASSERT(callList.size() == 5);
TEST_ASSERT(callList[4] == "T2.derivedCommand");
ICommand::execute("T2.commandToOverride", *InfoLog);
NLMISC::ICommand::execute("T2.commandToOverride", *NLMISC::InfoLog);
TEST_ASSERT(callList.size() == 6);
TEST_ASSERT(callList[5] == "T2.command Overidden");
}
@ -204,11 +204,11 @@ public:
TEST_ASSERT(callList.empty());
ICommand::execute("inst1.theCommand1", *InfoLog);
NLMISC::ICommand::execute("inst1.theCommand1", *NLMISC::InfoLog);
TEST_ASSERT(callList.size() == 1);
TEST_ASSERT(callList[0] == "inst1.theCommand1");
ICommand::execute("inst1.theCommand2", *InfoLog);
NLMISC::ICommand::execute("inst1.theCommand2", *NLMISC::InfoLog);
TEST_ASSERT(callList.size() == 2);
TEST_ASSERT(callList[0] == "inst1.theCommand1");
TEST_ASSERT(callList[1] == "inst1.theCommand2");
@ -221,13 +221,13 @@ public:
TEST_ASSERT(callList.size() == 2);
ICommand::execute("inst2.theCommand1", *InfoLog);
NLMISC::ICommand::execute("inst2.theCommand1", *NLMISC::InfoLog);
TEST_ASSERT(callList.size() == 3);
TEST_ASSERT(callList[0] == "inst1.theCommand1");
TEST_ASSERT(callList[1] == "inst1.theCommand2");
TEST_ASSERT(callList[2] == "inst2.theCommand1");
ICommand::execute("inst2.theCommand2", *InfoLog);
NLMISC::ICommand::execute("inst2.theCommand2", *NLMISC::InfoLog);
TEST_ASSERT(callList.size() == 4);
TEST_ASSERT(callList[0] == "inst1.theCommand1");
TEST_ASSERT(callList[1] == "inst1.theCommand2");
@ -239,7 +239,7 @@ public:
{
delete t1;
ICommand::execute("inst1.theCommand2", *InfoLog);
NLMISC::ICommand::execute("inst1.theCommand2", *NLMISC::InfoLog);
TEST_ASSERT(callList.size() == 4);
TEST_ASSERT(callList[0] == "inst1.theCommand1");
TEST_ASSERT(callList[1] == "inst1.theCommand2");

View file

@ -41,18 +41,18 @@ public:
void setup()
{
_OldPath = CPath::getCurrentPath();
CPath::setCurrentPath(_WorkingPath.c_str());
_OldPath = NLMISC::CPath::getCurrentPath();
NLMISC::CPath::setCurrentPath(_WorkingPath.c_str());
}
void tear_down()
{
CPath::setCurrentPath(_OldPath.c_str());
NLMISC::CPath::setCurrentPath(_OldPath.c_str());
}
void configWithInclude()
{
CConfigFile configFile;
NLMISC::CConfigFile configFile;
TEST_THROWS_NOTHING(configFile.load(NEL_UNIT_BASE "ut_misc_files/cfg_with_include.cfg"));
@ -65,7 +65,7 @@ public:
void configWithOptional()
{
CConfigFile configFile;
NLMISC::CConfigFile configFile;
TEST_THROWS_NOTHING(configFile.load(NEL_UNIT_BASE "ut_misc_files/cfg_with_optional.cfg"));
@ -79,7 +79,7 @@ public:
void configWithDefine()
{
CConfigFile configFile;
NLMISC::CConfigFile configFile;
TEST_THROWS_NOTHING(configFile.load(NEL_UNIT_BASE "ut_misc_files/cfg_with_define.cfg"));
@ -90,12 +90,12 @@ public:
TEST_ASSERT(configFile.getVarPtr("CfgMustExist") != NULL);
}
class CMyDisplayer : public IDisplayer
class CMyDisplayer : public NLMISC::IDisplayer
{
public:
vector<string> Lines;
virtual void doDisplay( const CLog::TDisplayInfo& args, const char *message)
virtual void doDisplay( const NLMISC::CLog::TDisplayInfo& args, const char *message)
{
Lines.push_back(message);
}
@ -105,11 +105,11 @@ public:
{
// override the warning channel to get the error on unclosed if
CMyDisplayer warnings;
CLog logger;
NLMISC::CLog logger;
logger.addDisplayer(&warnings);
CNLWarningOverride override(&logger);
NLMISC::CNLWarningOverride override(&logger);
CConfigFile configFile;
NLMISC::CConfigFile configFile;
string fullName = NLMISC::CPath::getFullPath(NEL_UNIT_BASE "ut_misc_files/cfg_with_bad_test.cfg", false);
@ -139,11 +139,11 @@ public:
void configIncludeAndOptional()
{
CMyDisplayer warnings;
CLog logger;
NLMISC::CLog logger;
logger.addDisplayer(&warnings);
CNLWarningOverride override(&logger);
NLMISC::CNLWarningOverride override(&logger);
CConfigFile configFile;
NLMISC::CConfigFile configFile;
string fullName = NLMISC::CPath::getFullPath(NEL_UNIT_BASE "ut_misc_files/cfg_with_include_and_optional.cfg", false);
@ -158,17 +158,17 @@ public:
void reportErrorInSubFiles()
{
CMyDisplayer warnings;
CLog logger;
NLMISC::CLog logger;
logger.addDisplayer(&warnings);
CNLWarningOverride override(&logger);
NLMISC::CNLWarningOverride override(&logger);
CConfigFile configFile;
NLMISC::CConfigFile configFile;
string fullName = NLMISC::CPath::getFullPath(NEL_UNIT_BASE "ut_misc_files/cfg_with_error_main.cfg", false);
string subfullName = NLMISC::CPath::getFullPath(NEL_UNIT_BASE "ut_misc_files/cfg_with_error.cfg", false);
TEST_THROWS(configFile.load(NEL_UNIT_BASE "ut_misc_files/cfg_with_error_main.cfg"), EParseError);
TEST_THROWS(configFile.load(NEL_UNIT_BASE "ut_misc_files/cfg_with_error_main.cfg"), NLMISC::EParseError);
// check that we have error report with correct filename and line number
TEST_ASSERT(warnings.Lines.size() == 1);

View file

@ -20,7 +20,7 @@
#include <nel/misc/file.h>
#include <nel/misc/path.h>
// Test suite for CFile behavior
// Test suite for NLMISC::CFile behavior
struct CUTMiscFile : public Test::Suite
{
CUTMiscFile()

View file

@ -55,31 +55,31 @@ public:
void setup()
{
_OldPath = CPath::getCurrentPath();
CPath::setCurrentPath(_WorkingPath.c_str());
string pathAfter = CPath::getCurrentPath();
_OldPath = NLMISC::CPath::getCurrentPath();
NLMISC::CPath::setCurrentPath(_WorkingPath.c_str());
string pathAfter = NLMISC::CPath::getCurrentPath();
}
void tear_down()
{
CPath::setCurrentPath(_OldPath.c_str());
NLMISC::CPath::setCurrentPath(_OldPath.c_str());
}
void addBnp()
{
// add bnp file in the path and access to file inside
CPath::addSearchBigFile(NEL_UNIT_BASE "ut_misc_files/files.bnp", false, false);
NLMISC::CPath::addSearchBigFile(NEL_UNIT_BASE "ut_misc_files/files.bnp", false, false);
}
void loadFromBnp()
{
// lookup for the file
string filename = CPath::lookup("file1_in_bnp.txt", true, true, false);
string filename = NLMISC::CPath::lookup("file1_in_bnp.txt", true, true, false);
TEST_ASSERT(filename == "files.bnp@file1_in_bnp.txt");
// read the first file content
{
CIFile file1(filename);
NLMISC::CIFile file1(filename);
string content1;
content1.resize(file1.getFileSize());
file1.serialBuffer((uint8*)content1.data(), file1.getFileSize());
@ -89,12 +89,12 @@ public:
}
// lookup for the 2nd file
filename = CPath::lookup("file2_in_bnp.txt", true, true, false);
filename = NLMISC::CPath::lookup("file2_in_bnp.txt", true, true, false);
TEST_ASSERT(filename == "files.bnp@file2_in_bnp.txt");
{
// read the second file content
CIFile file2(filename);
NLMISC::CIFile file2(filename);
string content2;
content2.resize(file2.getFileSize());
file2.serialBuffer((uint8*)content2.data(), file2.getFileSize());
@ -107,18 +107,18 @@ public:
void addXmlpack()
{
// add xml_pack file in the path and access to file inside
CPath::addSearchXmlpackFile(NEL_UNIT_BASE "ut_misc_files/xml_files/xml_files.xml_pack", false, false);
NLMISC::CPath::addSearchXmlpackFile(NEL_UNIT_BASE "ut_misc_files/xml_files/xml_files.xml_pack", false, false);
}
void loadFromXmlpack()
{
// lookup for the file
string filename = CPath::lookup("file1_in_xml_pack.xml", true, true, false);
string filename = NLMISC::CPath::lookup("file1_in_xml_pack.xml", true, true, false);
TEST_ASSERT(filename == NEL_UNIT_BASE "ut_misc_files/xml_files/xml_files.xml_pack@@file1_in_xml_pack.xml");
// read the first file content
{
CIFile file1(filename);
NLMISC::CIFile file1(filename);
string content1;
content1.resize(file1.getFileSize());
file1.serialBuffer((uint8*)content1.data(), file1.getFileSize());
@ -129,12 +129,12 @@ public:
}
// lookup for the 2nd file
filename = CPath::lookup("file2_in_xml_pack.xml", true, true, false);
filename = NLMISC::CPath::lookup("file2_in_xml_pack.xml", true, true, false);
TEST_ASSERT(filename == NEL_UNIT_BASE "ut_misc_files/xml_files/xml_files.xml_pack@@file2_in_xml_pack.xml");
{
// read the second file content
CIFile file2(filename);
NLMISC::CIFile file2(filename);
string content2;
content2.resize(file2.getFileSize());
file2.serialBuffer((uint8*)content2.data(), file2.getFileSize());
@ -150,7 +150,7 @@ public:
//#ifdef WIN32
//_CrtCheckMemory();
//#endif
CPath::memoryCompress();
NLMISC::CPath::memoryCompress();
//#ifdef WIN32
//_CrtCheckMemory();
//#endif
@ -170,7 +170,7 @@ public:
void decompressMemory()
{
CPath::memoryUncompress();
NLMISC::CPath::memoryUncompress();
}
void loadFromBnpUncompressed()
@ -191,30 +191,30 @@ public:
// but the 'addSearchPath' or add xml pack must be done
// at a higher discriminant directory
// CPath::addSearchXmlpackFile(NEL_UNIT_BASE "ut_misc_files/xml_files/same_subfolder_1/samename/samename.xml_pack", true, false, NULL);
// CPath::addSearchXmlpackFile(NEL_UNIT_BASE "ut_misc_files/xml_files/same_subfolder_2/samename/samename.xml_pack", true, false, NULL);
CPath::addSearchPath(NEL_UNIT_BASE "ut_misc_files/xml_files", true, false);
// NLMISC::CPath::addSearchXmlpackFile(NEL_UNIT_BASE "ut_misc_files/xml_files/same_subfolder_1/samename/samename.xml_pack", true, false, NULL);
// NLMISC::CPath::addSearchXmlpackFile(NEL_UNIT_BASE "ut_misc_files/xml_files/same_subfolder_2/samename/samename.xml_pack", true, false, NULL);
NLMISC::CPath::addSearchPath(NEL_UNIT_BASE "ut_misc_files/xml_files", true, false);
// lookup for the files in first subdirectory
string filename = CPath::lookup("file1_in_sub_1.xml", true, true, false);
string filename = NLMISC::CPath::lookup("file1_in_sub_1.xml", true, true, false);
TEST_ASSERT(filename == NEL_UNIT_BASE "ut_misc_files/xml_files/same_subfolder_1/samename/samename.xml_pack@@file1_in_sub_1.xml");
filename = CPath::lookup("file2_in_sub_1.xml", true, true, false);
filename = NLMISC::CPath::lookup("file2_in_sub_1.xml", true, true, false);
TEST_ASSERT(filename == NEL_UNIT_BASE "ut_misc_files/xml_files/same_subfolder_1/samename/samename.xml_pack@@file2_in_sub_1.xml");
// lookup for the files in the second subdirectory
filename = CPath::lookup("file1_in_sub_2.xml", true, true, false);
filename = NLMISC::CPath::lookup("file1_in_sub_2.xml", true, true, false);
TEST_ASSERT(filename == NEL_UNIT_BASE "ut_misc_files/xml_files/same_subfolder_2/samename/samename.xml_pack@@file1_in_sub_2.xml");
filename = CPath::lookup("file2_in_sub_2.xml", true, true, false);
filename = NLMISC::CPath::lookup("file2_in_sub_2.xml", true, true, false);
TEST_ASSERT(filename == NEL_UNIT_BASE "ut_misc_files/xml_files/same_subfolder_2/samename/samename.xml_pack@@file2_in_sub_2.xml");
// read the file content of the first file in first pack
filename = CPath::lookup("file1_in_sub_1.xml", true, true, false);
filename = NLMISC::CPath::lookup("file1_in_sub_1.xml", true, true, false);
// check that we can read the file modif date
uint32 d = NLMISC::CFile::getFileModificationDate(filename);
TEST_ASSERT(d != 0);
{
CIFile file1(filename);
NLMISC::CIFile file1(filename);
string content1;
content1.resize(file1.getFileSize());
file1.serialBuffer((uint8*)content1.data(), file1.getFileSize());
@ -225,10 +225,10 @@ public:
}
// read the file content of the second file in the second pack
filename = CPath::lookup("file2_in_sub_2.xml", true, true, false);
filename = NLMISC::CPath::lookup("file2_in_sub_2.xml", true, true, false);
{
// read the second file content
CIFile file2(filename);
NLMISC::CIFile file2(filename);
string content2;
content2.resize(file2.getFileSize());
file2.serialBuffer((uint8*)content2.data(), file2.getFileSize());

View file

@ -80,7 +80,7 @@ public:
void createSingleton()
{
TEST_ASSERT(CInstanceCounterManager::getInstance().getInstanceCounter("CSafeSingleton") == 0);
TEST_ASSERT(NLMISC::CInstanceCounterManager::getInstance().getInstanceCounter("CSafeSingleton") == 0);
CSafeSingleton &ss = CSafeSingleton::getInstance();
TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CSafeSingleton) == 1);
@ -106,7 +106,7 @@ public:
/*void multiDllSingleton()
{
TEST_ASSERT(CCommandRegistry::getInstance().exists("aDynLibCommand") == false);
TEST_ASSERT(NLMISC::CCommandRegistry::getInstance().exists("aDynLibCommand") == false);
CLibrary lib;
if (lib.loadLibrary("dyn_lib_test", true, true, true) != true)
@ -115,7 +115,7 @@ public:
return;
}
TEST_ASSERT(CCommandRegistry::getInstance().isCommand("aDynLibCommand") == true);
TEST_ASSERT(NLMISC::CCommandRegistry::getInstance().isCommand("aDynLibCommand") == true);
IDynLibTest *libTest = dynamic_cast<IDynLibTest*>(lib.getNelLibraryInterface());
TEST_ASSERT(libTest != NULL);

View file

@ -29,9 +29,9 @@ struct CUTMiscSString : public Test::Suite
void testStrtok()
{
CSString testLine(" a=b c (a=e b=c) \t\t c(a=e b=c) toto(bimbo(foo(bar(a=b))))");
NLMISC::CSString testLine(" a=b c (a=e b=c) \t\t c(a=e b=c) toto(bimbo(foo(bar(a=b))))");
CSString part;
NLMISC::CSString part;
part = testLine.strtok(" \t", true, false);
TEST_ASSERT(part == "a=b");
part = testLine.strtok(" \t", true, false);
@ -47,7 +47,7 @@ struct CUTMiscSString : public Test::Suite
part = testLine.strtok(" \t=", true, false);
TEST_ASSERT(part == "(bimbo(foo(bar(a=b))))");
part = part.stripBlockDelimiters();
CSString part2 = part.strtok(" \t=", true, false);
NLMISC::CSString part2 = part.strtok(" \t=", true, false);
TEST_ASSERT(part2 == "bimbo");
part2 = part.strtok(" \t=", true, false);
TEST_ASSERT(part2 == "(foo(bar(a=b)))");

View file

@ -21,7 +21,7 @@
#include <nel/misc/bit_mem_stream.h>
// The following line is known to crash in a Ryzom service
CBitMemStream globalBms( false, 2048 ); // global to avoid reallocation
NLMISC::CBitMemStream globalBms( false, 2048 ); // global to avoid reallocation
// Test suite for stream based classes
// ! not complete at all at time of writing !
@ -38,21 +38,21 @@ public:
void preallocatedBitStream()
{
CBitMemStream localBms( false, 2048 ); // global to avoid reallocation
NLMISC::CBitMemStream localBms( false, 2048 ); // global to avoid reallocation
}
void copyOnWrite()
{
// test the copy on write strategy in the mem stream (and derived) class.
// The point is to be able to copy a mem stream (e.g a CMessage)
// The point is to be able to copy a mem stream (e.g a NLNET::CMessage)
// but to do not copy the stream buffer.
// If more than one stream use the same buffer, any attempt to
// modifye the buffer content while lead to a buffer duplication
CMemStream s1;
CMemStream s2;
CMemStream s3;
NLMISC::CMemStream s1;
NLMISC::CMemStream s2;
NLMISC::CMemStream s3;
uint32 i = 1;
@ -94,7 +94,7 @@ public:
// check that we can serialize with const stream or const object
CMemStream s1;
NLMISC::CMemStream s1;
NLMISC::IStream &is1 = s1;
const string str("toto");
@ -120,7 +120,7 @@ public:
is1.serial(i2);
is1.serialEnum(e2);
const CMemStream &s2 = s1;
const NLMISC::CMemStream &s2 = s1;
const NLMISC::IStream &is2 = s2;
string str3;
@ -157,11 +157,11 @@ public:
void memStreamSwap()
{
CMemStream ms2;
NLMISC::CMemStream ms2;
string s;
{
CMemStream ms1;
NLMISC::CMemStream ms1;
s = "foo1";
ms1.serial(s);

View file

@ -19,8 +19,6 @@
#include <nel/net/message.h>
using namespace NLNET;
#include "ut_net_layer3.h"
#include "ut_net_message.h"
#include "ut_net_module.h"

View file

@ -24,7 +24,7 @@ uint16 TestPort1 = 56000;
uint NbTestReceived = 0;
CMessage msgoutExpectingAnswer0, msgoutSimple0, msgoutSimple50;
NLNET::CMessage msgoutExpectingAnswer0, msgoutSimple0, msgoutSimple50;
// Data structure for messages
struct TData
@ -44,9 +44,9 @@ struct TData
};
// This callback must not take more than 10 ms
void cbTest( CMessage &msgin, TSockId from, CCallbackNetBase &netbase )
void cbTest( NLNET::CMessage &msgin, NLNET::TSockId from, NLNET::CCallbackNetBase &netbase )
{
TTime before = CTime::getLocalTime();
NLMISC::TTime before = NLMISC::CTime::getLocalTime();
// Read data from the message
TData data;
@ -59,21 +59,21 @@ void cbTest( CMessage &msgin, TSockId from, CCallbackNetBase &netbase )
netbase.send( msgoutSimple0, from );
// Check that the duration is compatible with our timeout tests
TTime maxDuration;
NLMISC::TTime maxDuration;
if ( msgin.getName() == "TEST_50" )
{
while ( CTime::getLocalTime() - before < 49 ); // wait
while ( NLMISC::CTime::getLocalTime() - before < 49 ); // wait
maxDuration = 70;
}
else
maxDuration = 10;
TTime actualDuration = CTime::getLocalTime() - before;
NLMISC::TTime actualDuration = NLMISC::CTime::getLocalTime() - before;
if ( actualDuration > maxDuration )
nlerror( "The callback cbTest takes too long (%u) for %s, please fix the test", (uint)actualDuration, msgin.getName().c_str() );
}
static TCallbackItem CallbackArray[] =
static NLNET::TCallbackItem CallbackArray[] =
{
{ "TEST_0", cbTest },
{ "TEST_50", cbTest }
@ -124,12 +124,12 @@ public:
msgoutSimple50.serial( data );
// Init connections
_Server = new CCallbackServer();
_Server = new NLNET::CCallbackServer();
_Server->init( TestPort1 );
_Server->addCallbackArray( CallbackArray, sizeof(CallbackArray)/sizeof(TCallbackItem) );
_Client = new CCallbackClient();
_Client->connect( CInetAddress( "localhost", TestPort1 ) );
_Client->addCallbackArray( CallbackArray, sizeof(CallbackArray)/sizeof(TCallbackItem) );
_Server->addCallbackArray( CallbackArray, sizeof(CallbackArray)/sizeof(NLNET::TCallbackItem) );
_Client = new NLNET::CCallbackClient();
_Client->connect( NLNET::CInetAddress( "localhost", TestPort1 ) );
_Client->addCallbackArray( CallbackArray, sizeof(CallbackArray)/sizeof(NLNET::TCallbackItem) );
// TEST: Simple message transmission
NbTestReceived = 0;
@ -138,7 +138,7 @@ public:
{
_Client->update();
_Server->update(); // legacy version
nlSleep( 50 );
NLMISC::nlSleep( 50 );
}
TEST_ASSERT( NbTestReceived == 2 ); // answer and reply
@ -153,7 +153,7 @@ public:
_Server->update2( 0 ); // shortest time-out = ONE-SHOT mode
TEST_ASSERT( (NbTestReceived == prevNbTestReceived) ||
(NbTestReceived == prevNbTestReceived + 1) );
nlSleep( 10 );
NLMISC::nlSleep( 10 );
}
// TEST: GREEDY update mode on the receiver
@ -163,7 +163,7 @@ public:
for ( uint i=0; i!=10; ++i ) // make sure all messages are flushed
{
_Client->update2();
nlSleep( 10 );
NLMISC::nlSleep( 10 );
}
_Server->update2( -1 ); // receive all
TEST_ASSERT( NbTestReceived == 20 );
@ -175,7 +175,7 @@ public:
for ( uint i=0; i!=10; ++i ) // make sure all messages are flushed
{
_Client->update2();
nlSleep( 10 );
NLMISC::nlSleep( 10 );
}
while ( NbTestReceived < 20 )
{
@ -191,16 +191,16 @@ public:
_Client->send( msgoutSimple0 );
_Client->send( msgoutSimple0 ); // send 2 messages at a time
_Client->update2();
TTime before = CTime::getLocalTime();
NLMISC::TTime before = NLMISC::CTime::getLocalTime();
_Server->update2( -1, 30 );
TTime duration = CTime::getLocalTime() - before;
NLMISC::TTime duration = NLMISC::CTime::getLocalTime() - before;
TEST_ASSERT( duration >= 30 );
}
}
private:
CCallbackServer *_Server;
CCallbackClient *_Client;
NLNET::CCallbackServer *_Server;
NLNET::CCallbackClient *_Client;
};

View file

@ -30,7 +30,7 @@ public:
void lockSubMEssageWithLongName()
{
CMessage master("BIG");
NLNET::CMessage master("BIG");
// serial some stuff
for (uint8 i=0; i<10; ++i)
@ -43,7 +43,7 @@ public:
// serial 4 sub messages
for (uint i=0; i<4; ++i)
{
CMessage sub(toString("A_VERY_LONG_SUB_MESSAGE_NAME_%u", i));
NLNET::CMessage sub(NLMISC::toString("A_VERY_LONG_SUB_MESSAGE_NAME_%u", i));
for (uint8 j=0; j<i*4; ++j)
{
@ -81,7 +81,7 @@ public:
master.lockSubMessage(subSize);
TEST_ASSERT(subSize == sizes[i]);
TEST_ASSERT(master.getName() == toString("A_VERY_LONG_SUB_MESSAGE_NAME_%u", i));
TEST_ASSERT(master.getName() == NLMISC::toString("A_VERY_LONG_SUB_MESSAGE_NAME_%u", i));
TEST_ASSERT(master.length() == sizes[i]);
for (uint8 j=0; j<i*4; ++j)
@ -122,10 +122,10 @@ public:
TEST_ASSERT(subSize == sizes[i]);
TEST_ASSERT(master.getName() == toString("A_VERY_LONG_SUB_MESSAGE_NAME_%u", i));
TEST_ASSERT(master.getName() == NLMISC::toString("A_VERY_LONG_SUB_MESSAGE_NAME_%u", i));
TEST_ASSERT(master.length() == sizes[i]);
CMessage sub;
NLNET::CMessage sub;
sub.assignFromSubMessage(master);
for (uint8 j=0; j<i*4; ++j)
@ -148,7 +148,7 @@ public:
void lockSubMEssage()
{
CMessage master("BIG");
NLNET::CMessage master("BIG");
// serial some stuff
for (uint8 i=0; i<10; ++i)
@ -161,7 +161,7 @@ public:
// serial 4 sub messages
for (uint i=0; i<4; ++i)
{
CMessage sub(toString("SUB_%u", i));
NLNET::CMessage sub(NLMISC::toString("SUB_%u", i));
for (uint8 j=0; j<i*4; ++j)
{
@ -199,7 +199,7 @@ public:
master.lockSubMessage(subSize);
TEST_ASSERT(subSize == sizes[i]);
TEST_ASSERT(master.getName() == toString("SUB_%u", i));
TEST_ASSERT(master.getName() == NLMISC::toString("SUB_%u", i));
TEST_ASSERT(master.length() == sizes[i]);
for (uint8 j=0; j<i*4; ++j)
@ -240,10 +240,10 @@ public:
TEST_ASSERT(subSize == sizes[i]);
TEST_ASSERT(master.getName() == toString("SUB_%u", i));
TEST_ASSERT(master.getName() == NLMISC::toString("SUB_%u", i));
TEST_ASSERT(master.length() == sizes[i]);
CMessage sub;
NLNET::CMessage sub;
sub.assignFromSubMessage(master);
for (uint8 j=0; j<i*4; ++j)
@ -266,12 +266,12 @@ public:
void messageSwap()
{
CMessage msg2;
NLNET::CMessage msg2;
string s;
{
CMessage msg1;
msg1.setType("NAME", CMessage::Request);
NLNET::CMessage msg1;
msg1.setType("NAME", NLNET::CMessage::Request);
s = "foo1";
msg1.serial(s);
@ -290,7 +290,7 @@ public:
msg2.invert();
TEST_ASSERT(msg2.typeIsSet());
TEST_ASSERT(msg2.getName() == "NAME");
TEST_ASSERT(msg2.getType() == CMessage::Request);
TEST_ASSERT(msg2.getType() == NLNET::CMessage::Request);
msg2.serial(s);
TEST_ASSERT(s == "foo1");
msg2.serial(s);

File diff suppressed because it is too large Load diff