RetroShare/tests/unittests/libretroshare/gxs/nxs_test/nxsmsgtestscenario.cc
chrisparker126 c6059906d0 Added msg sync unit test
- not passing yet but almost, more tweaking needed 
TODO: identity and circle vet test
- added retrieve msg id for convenience
- updated .pro file

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7303 b45a01b8-16f6-495d-af2f-9b41ad6348cc
2014-04-26 10:07:25 +00:00

73 lines
1.5 KiB
C++

/*
* nxsmsgtestscenario.cpp
*
* Created on: 26 Apr 2014
* Author: crispy
*/
#include "nxsmsgtestscenario.h"
namespace rs_nxs_test {
NxsMsgTestScenario::NxsMsgTestScenario() {
// TODO Auto-generated constructor stub
}
NxsMsgTestScenario::~NxsMsgTestScenario() {
// TODO Auto-generated destructor stub
}
bool NxsMsgTestScenario::checkTestPassed() {
// so we expect all peers to all messages for each group
const ExpectedMap& exMap = getExpectedMap();
ExpectedMap::const_iterator mit = exMap.begin();
bool passed = true;
for(; mit != exMap.end(); mit++)
{
const RsPeerId& pid = mit->first;
const ExpectedMsgs& exMsgs = mit->second;
ExpectedMsgs::const_iterator cit = exMsgs.begin();
RsGeneralDataService* ds = getDataService(pid);
for(; cit != exMsgs.end(); cit++)
{
const RsGxsGroupId& grpId = cit->first;
RsGxsMessageId::std_vector expMsgIds = cit->second;
RsGxsMessageId::std_vector msgIds;
ds->retrieveMsgIds(grpId, msgIds);
RsGxsMessageId::std_vector result(expMsgIds.size()+msgIds.size());
std::sort(msgIds.begin(), msgIds.end());
std::sort(expMsgIds.begin(), expMsgIds.end());
RsGxsMessageId::std_vector::iterator it = std::set_difference(msgIds.begin(), msgIds.end(),
expMsgIds.begin(), expMsgIds.end(), result.begin());
result.resize(it - result.begin());
passed &= result.size() == 0;
}
}
return passed;
}
bool NxsMsgTestScenario::checkDeepTestPassed() {
return false;
}
}
/* namespace rs_nxs_test */