void unaugmentMany()
    {
       cards::AssetMetadataMapping::AssetSet    expectedAssetSet;

       cards::AssetMetadataMapping::MetadataSet inputMetadataSet1;
       cards::AssetMetadataMapping::MetadataSet inputMetadataSet2;
       cards::AssetMetadataMapping::MetadataSet inputMetadataSet3;

       inputMetadataSet1.insert(mt1);
       inputMetadataSet2.insert(mt2);
       inputMetadataSet3.insert(mt1);
       inputMetadataSet3.insert(mt2);

       mAssetMetadataMapping->unaugmentAsset(at1,mt1);
       mAssetMetadataMapping->unaugmentAsset(at2,mt2);
       mAssetMetadataMapping->unaugmentAsset(at3,mt1);
       mAssetMetadataMapping->unaugmentAsset(at3,mt2);

       TEST_ASSERT_MSG( mAssetMetadataMapping->describedAssets(inputMetadataSet1) == expectedAssetSet,
            (mClassMsg + ":\t Failed to return proper EmptySet").c_str() );

       TEST_ASSERT_MSG( mAssetMetadataMapping->describedAssets(inputMetadataSet2) == expectedAssetSet,
            (mClassMsg + ":\t Failed to return proper EmptySet").c_str() );

       TEST_ASSERT_MSG( mAssetMetadataMapping->describedAssets(inputMetadataSet3) == expectedAssetSet,
            (mClassMsg + ":\t Failed to return proper EmptySet").c_str() );

    }
Example #2
0
void TestDSMTP::simple_test()
{
	DSMTP mail;
	DSMTP::ERRNO code;
	DURL server;
	DStringList transaction;
	DStringList::const_iterator it;

	server.setURL( "smtp://localhost.localdomain:25" );

	mail.setHost ( server );
	mail.setSender ( "root@localhost" );
	mail.addReceiver ( "root@localhost" );
	
	DString buffer = "This is just a simple DLibs test, SMTP part\n\n";
	buffer += utf8chars;
	mail.setEmail ( "DLibs test", buffer );
	code = mail.send();
	
	TEST_ASSERT_MSG( mail.getLastError() == DString::empty(), "Error reported when sending email" )
	TEST_ASSERT_MSG( code == DSMTP::SUCCESS, "Email not sent" )
	
	transaction = mail.getTransactionLog();
	for ( it = transaction.begin() ; it != transaction.end() ; it++ )
	{
		std::cout << *it << std::endl;
	}
}
Example #3
0
static void
test_trie_strings(void)
{
	struct mtree_trie	*trie;
	char			 buf[16];
	char			*s;
	size_t			 i;
	int			 ret;

	trie = mtree_trie_create();
	TEST_ASSERT_ERRNO(trie != NULL);
	if (trie == NULL)
		return;
	TEST_ASSERT(mtree_trie_count(trie) == 0);

	for (i = 0; i < TRIE_STRINGS; i++) {
		snprintf(buf, sizeof(buf), "%zu", i);
		s = strdup(buf);
		TEST_ASSERT_ERRNO(s != NULL);
		if (s == NULL)
			continue;
		ret = mtree_trie_insert(trie, buf, s);
		TEST_ASSERT_ERRNO(ret != -1);
		if (ret != -1)
			TEST_ASSERT_MSG(ret == 0, "key: %s", buf);
	}
	TEST_ASSERT(mtree_trie_count(trie) == TRIE_STRINGS);

	/*
	 * Make sure all the items can be found.
	 */
	for (i = 0; i < TRIE_STRINGS + 1; i++) {
		snprintf(buf, sizeof(buf), "%zu", i);
		if (i < TRIE_STRINGS) {
			s = mtree_trie_find(trie, buf);
			TEST_ASSERT_MSG(s != NULL, "key: %s", buf);
		} else
			TEST_ASSERT(mtree_trie_find(trie, buf) == NULL);
	}

	/*
	 * Replace the first item, the function returns 1 on successful
	 * replacement.
	 */
	// XXX leaks the old 0
	ret = mtree_trie_insert(trie, "0", strdup("xy"));
	TEST_ASSERT_ERRNO(ret == 0 || ret == 1);
	if (ret != 1) {
		TEST_ASSERT(ret == 1);
		s = mtree_trie_find(trie, "0");
		TEST_ASSERT(s != NULL);
		if (s != NULL)
			TEST_ASSERT_STRCMP(s, "xy");
	}
	mtree_trie_free(trie, free);
}
Example #4
0
void TestParameters::testParseParameters()
{
    TEST_ASSERT_MSG(false == params.parseParameters(0, nullptr), "Empty parameters not detected");
    char* arguments[] = {
        (char*)"progName",
        (char*)"--remote-address=127.0.0.1",
        (char*)"-a=Proc1",
        (char*)"-a=Proc2"
    };
    TEST_ASSERT_MSG(params.parseParameters(4, arguments) == true, "Parameter parsing failed");
}
Example #5
0
void TestDMail::mail_subject_test()
{
	DString str = "=?utf-8?B?UkU6IENvb3Jkb25uw6llcyBkdSBjb25zdWx0YW50IGRlIHZvdHJlIE9mZnJl?= =?utf-8?B?IDogRlI2OSBDT05EUklFVSAtIEZSNjkgU0FJTlQtR0VPUkdFUy1ERS1SRU5F?= =?utf-8?Q?INS_-_TEST?=";
	std::cout << std::endl;
	TEST_ASSERT_MSG( DMail::decodeSubject( str ) == "RE: Coordonnées du consultant de votre Offre : FR69 CONDRIEU - FR69 SAINT-GEORGES-DE-RENEINS_-_TEST", "Bad UTF-8 Base64 decode process" )	
	
	str = "=?iso-8859-1?Q?Automatische_Antwort:_Vos_statistiques_de_d=E9poses_quotid?= =?iso-8859-1?Q?iennes.?=";
	TEST_ASSERT_MSG( DMail::decodeSubject( str ) == "Automatische_Antwort:_Vos_statistiques_de_déposes_quotidiennes.", "Bad ISO-8859 Quoted Printable decode process" )
	
	str = "=?UTF-8?Q?RE:_Coordonn=C3=A9es_du_consultant_de?= =?UTF-8?Q?_votre_Offre_:_FR28_CHATEAUDUN_-?= =?UTF-8?Q?_PL60_POZNAN_-_TEST?=";
	TEST_ASSERT_MSG( DMail::decodeSubject( str ) == "RE:_Coordonnées_du_consultant_de_votre_Offre_:_FR28_CHATEAUDUN_-_PL60_POZNAN_-_TEST", "Bad UTF-8 Quoted Printable decode process" )
}
Example #6
0
void TemblorTestSuite::testFrecPeligrosa() {
	Entrada e(ARCHIVO_DE_ENTRADA_3);
	Temblor t(&e);

	TEST_ASSERT_MSG( t.frecuenciaInvalida( FREC_TERREMOTO ),
	                 "3 Hz es una frecuencia peligrosa, y no se detecta como tal");

	TEST_ASSERT_MSG( ! t.frecuenciaInvalida( FREC_MAX + 1 ),
	                 "4.3 Hz NO es una frecuencia peligrosa, y se detecta como si lo fuera");

	TEST_ASSERT_MSG( ! t.frecuenciaInvalida( FREC_MIN - 1 ),
	                 "1.7 Hz NO es una frecuencia peligrosa, y se detecta como si lo fuera");
}
void MatrizFullFullTestSuite::igual() {
	MatrizFullFull a(1), b(1);
	a.set(0, 9);
	b.set(0, 9);

	TEST_ASSERT_MSG(a.get(0) == b.get(0),"Deben ser iguales");
	TEST_ASSERT_MSG(a == b, "Deben ser iguales (operator==)");
	TEST_ASSERT_MSG(a.esParecidaA(b, (FLOTANTE) 0), "Deben ser parecidas con error = 0");

	FLOTANTE error = 0.1;
	b.set(0, b.get(0) + 2 * error);
	TEST_ASSERT_MSG(a.esParecidaA(b, error) == false, "NO Deben ser parecidas con error = 0");
}
Example #8
0
void TestDSMTP::html_test()
{
	DSMTP mail;
	DSMTP::ERRNO code;
	DURL server;
	DStringList transaction, charlist;
	DStringList::const_iterator it;
	int i = 2;

	server.setURL( "smtp://localhost.localdomain:25" );

	mail.setHost ( server );
	mail.setSender ( "root@localhost" );
	mail.addReceiver ( "root@localhost" );
	
	DString buffer = "This is just a simple DLibs test, SMTP part\n\n";
	buffer += utf8chars;
	
	charlist = utf8chars.split( " " );
	DString html = "<!DOCTYPE html>\n<html>\n<body>\n<h1>This is just a simple DLibs test, SMTP part</h1>\n";
	html += "<table>\n";
	html += "<tr>\n";
	for ( it = charlist.begin() ; it != charlist.end() ; ++it )
	{
		if ( ! ( i % 16 ) )
		{
			html += "</tr>\n";
			html += "<tr>\n";
		}
		html += "<td>";
		html += it->toHTML();
		html += "</td>\n";
		i++;
	}

	html += "</tr>\n";
	html += "</table>\n";
	html += "</body>\n</html>";
	mail.setEmail ( "DLibs test", buffer, html );
	code = mail.send();
	
	TEST_ASSERT_MSG( mail.getLastError() == DString::empty(), "Error reported when sending email" )
	TEST_ASSERT_MSG( code == DSMTP::SUCCESS, "Email not sent" )
	
	transaction = mail.getTransactionLog();
	for ( it = transaction.begin() ; it != transaction.end() ; it++ )
	{
		std::cout << *it << std::endl;
	}
}
Example #9
0
void TemblorTestSuite::testSeCaeTodo() {
	Entrada e(ARCHIVO_DE_ENTRADA_3);
	Temblor t(&e);

	// El archivo de prueba tiene 3 pisos, así que pongo 3 frecuencias
	FLOTANTE frecNoSeCae[] = { 3.4, 2.6, 5 };
	TEST_ASSERT_MSG( ! t.seCaeTodo( frecNoSeCae ),
	                 "Oops, todo se cae y no debería");

	FLOTANTE frecHacePumba[] = { 3.0, 2.6, 5 };
	TEST_ASSERT_MSG( t.seCaeTodo( frecHacePumba ),
	                 "Oops, dice que no pasa nada pero todo se cae");


}
void RequestTests::Test_DaemonStatus()
{
    bool bExec = false;
    CMtClient client("127.0.0.1", 50);
    std::string sErrorMsg;
	int nServerRetCode = -1;
	std::string sServerResponse;

	// Execute daemon status command - assume success
    bExec = client.ExecuteRequest("daemon status\n", nServerRetCode, sServerResponse, sErrorMsg);
	TEST_ASSERT_MSG(bExec, sErrorMsg.c_str());
	TEST_ASSERT_MSG(nServerRetCode==0, "Invalid ret code %d", nServerRetCode);

    __TEST_CLEANUP__;
}
Example #11
0
void idTest::test_symbols()
{
    IdConverter converter;
    std::string id = "a1a2", id_out;
    int rc = converter.Convert(id, id_out);
    TEST_ASSERT_MSG(rc == 1, "FAILED CHECK OF WRONG SYMBOLS");
    id = "D1F9G0";
    rc = converter.Convert(id, id_out);
    TEST_ASSERT_MSG(rc == 1, "FAILED CHECK OF WRONG SYMBOLS");
    id = "!@#$%";
    rc = converter.Convert(id, id_out);
    TEST_ASSERT_MSG(rc == 1, "FAILED CHECK OF WRONG SYMBOLS");
    id = "Z9-Z9";
    rc = converter.Convert(id, id_out);
    TEST_ASSERT_MSG(rc == 3, "FAILED CHECK OF WRONG SYMBOLS");
}
Example #12
0
void UserManagerTestSuite::login_nonexisting_user()
{
    User_Manager m;
    Security_Status status = m.login_user(bad_username, good_password);
    std::string str_status = strStatus(status);
    TEST_ASSERT_MSG(status==Security_Status::err_user_not_found, str_status.c_str());
}
Example #13
0
void UserManagerTestSuite::login_existing_success()
{
    User_Manager m;
    Security_Status status = m.login_user(good_username, good_password);
    std::string str_status = strStatus(status);
    TEST_ASSERT_MSG(status==Security_Status::ok_login, str_status.c_str());
}
Example #14
0
void UserManagerTestSuite::register_existing_user()
{
    User_Manager m;
    Security_Status status = m.register_user(good_username, bad_password);
    std::string str_status = strStatus(status);
    TEST_ASSERT_MSG(status==Security_Status::err_user_exists, str_status.c_str());
}
Example #15
0
void UserManagerTestSuite::login_existing_CAPS_fail()
{
    User_Manager m;
    Security_Status status = m.login_user(caps_username, caps_password);
    std::string str_status = strStatus(status);
    TEST_ASSERT_MSG(status==Security_Status::err_bad_auth, str_status.c_str());
}
Example #16
0
void idTest::test_convert()
{
    IdConverter converter;
    std::string id = "A1A9Z9A1-A9A1-Z9", id_out;
    int rc = converter.Convert(id, id_out);
    TEST_ASSERT_MSG(rc == 0, "FAILED CONVERT VALID IDENTIFIER");
}
Example #17
0
void ServiceTests::Test_StartKillDaemon()
{
    bool bStart = false;
    bool bStop = false;
    std::string sErrorMsg;

    bStart = StartDaemon(sErrorMsg);
    TEST_ASSERT_MSG(bStart, sErrorMsg.c_str());

    bStop = KillDaemon(sErrorMsg);
    TEST_ASSERT_MSG(bStop, sErrorMsg.c_str());

    __TEST_CLEANUP__;

    StopDaemon(sErrorMsg);
}
Example #18
0
void idTest::test_length()
{
    IdConverter converter;
    std::string id = "A1A2A3A4A5A6A7A8A9B1B2", id_out;
    int rc = converter.Convert(id, id_out);
    TEST_ASSERT_MSG(rc == 2, "FAILED CHECK OF INVALID LENGTH");
}
Example #19
0
//##ModelId=4C31F9F801D4
void fluid::glExtension::btGLTexture1D::create(GLint sz, GLint internalFormat, GLint clr)
{
	TEST_ASSERT_MSG(sz <= getMaxSize(),
					"Image Size Out Of Bounds.");

	if(texture != -1)
		glDeleteTextures(1,&texture);

	glGenTextures(1,&texture);
	glBindTexture(GL_TEXTURE_1D,texture);
	
	GLint* clrData=(GLint*)malloc(sz << 2);
	for(int i=0;i < sz;i++)
		clrData[i]=clr;
	glTexImage1D(GL_TEXTURE_1D,0,internalFormat,sz,0,GL_RGBA,GL_UNSIGNED_BYTE,clrData);
	free(clrData);

	parameter.szWidth=sz;
	parameter.internalFormat=internalFormat;
	parameter.magFilter=GL_NEAREST;
	parameter.minFilter=GL_NEAREST;
	parameter.wrapModeS=GL_CLAMP_TO_EDGE;

	setParameterSet(&parameter);

	glBindTexture(GL_TEXTURE_1D,0);
}
void RequestTests::Test_PdbImport()
{
	bool bExec = false;
    CMtClient client("127.0.0.1", 50);
    std::string sErrorMsg;
	int nServerRetCode = -1;
	std::string sServerResponse;
	std::ostringstream stCommand;
	std::wstring sPdbName;
	std::wstring sSymDir;
	std::wstring sOutFile;
	int nCreateDir = -1;

	sPdbName = Utils::GetTestDataFolder();
	sPdbName += L"CrashRpt.pdb";

	// Create symbol store dir
	sSymDir = Utils::GetTestDataFolder();
	sSymDir += L"sym";
	RmDir(sSymDir, false);
	nCreateDir = CreateDir(sSymDir);
	TEST_ASSERT_MSG(nCreateDir==0, "Error creating directory '%s'", strconv::w2a(sSymDir).c_str());

	sOutFile = sSymDir;
#ifdef _WIN32
	sOutFile += L"\\CrashRpt.pdb.txt";
#else
    sOutFile += L"/CrashRpt.pdb.txt";
#endif

	// Format command
	stCommand << "dumper --import-pdb \"" <<
		strconv::w2utf8(sPdbName) << "\" \"" <<
		strconv::w2utf8(sSymDir) << "\" \"" <<
		strconv::w2utf8(sOutFile) << "\"\n";

	// Execute daemon status command - assume success
    bExec = client.ExecuteRequest(stCommand.str().c_str(), nServerRetCode, sServerResponse, sErrorMsg);
	TEST_ASSERT_MSG(bExec, sErrorMsg.c_str());
	TEST_ASSERT_MSG(nServerRetCode==0, "Invalid ret code %d, msg = %s", nServerRetCode, sServerResponse.c_str());

	__TEST_CLEANUP__;

	// Delete sym directory
    RmDir(sSymDir, false);

}
Example #21
0
//##ModelId=4C32C80701B5
CGprofile fluid::glExtension::btGLShaderModel_4_0::getProfile(CGGLenum mode)
{
	TEST_ASSERT_MSG(mode == CG_GL_VERTEX ||
					mode == CG_GL_FRAGMENT ||
					mode == CG_GL_GEOMETRY,
					"Mode Type Invalid,Must Be Vertex,Geometry Or Fragment.");
	return cgGLGetLatestProfile(mode);
}
Example #22
0
void RequestSuite::TestReqeustsByteForByte() {

	SiteOptions so;
	so.SetPort(50);

	Site site(&so);
	const int NR = 11;

	const char
			*getstring[NR] =
					{
							"GET / HTTP/1.0\r\n\r\n",
							"GET /good.html HTTP/1.1\r\nConnection: keep-alive\r\nHost: \t   localhost:80\r\n\r\n",
							"GET /good.html HTTP/1.1\r\nConnection: close\r\nHost:    localhost:81\r\n\r\n",
							"GET /good.html HTTP/1.0\r\nConnection: keep-alive\r\n\r\n",
							"GET /good.html HTTP/1.0\r\nConnection: close\r\n\r\n",
							"GET /good.html HTTP/1.0\r\n\r\n",
							"GET / HTTP/1.1\r\nHost: localhost:8080\r\n\r\n",
							"GET /last.html HTTP/1.0\r\nHost: localhost:8080\r\n\r\n",
							"GET /last.html HTTP/1.0\r\n\r\n",
							"GET /last.html HTTP/1.1\r\nHost: localhost:8080\r\nConnection:        \t close\r\n\r\n",
							"GET /last.html HTTP/1.0\r\nConnection:        \t close\r\n\r\n" };

	ByteBuffer* buf = new ByteBuffer(2000);
	for (int i = 0; i < NR; i++) {
		Request *r = new Request(NULL, &site);
		buf->Clear();
		size_t len=strlen(getstring[i]);
		for (size_t j=0;j<len;j++)
		{
			buf->Add(getstring[i]+j, 1);
			bool result = Request::ParseRequest(r, buf);
			if (j+1<len)
			{
				TEST_ASSERT_MSG(result==false,getstring[i]);
			}
			else
			{
				TEST_ASSERT_MSG(result,getstring[i]);
				TEST_ASSERT_MSG(r->GetStatus() == Http::HTTP_OK,getstring[i]);
			}
		}
		delete r;
	}
	delete buf;
}
void equalityTestSuite::verifyEqual(const partialSolution & expected, const partialSolution & actual) {
	char msg[128];
	for(size_t i=0;i<SUDOKU_GRID_SIZE;i++)
		for(size_t j=0;j<SUDOKU_GRID_SIZE;j++){
			sprintf(msg,"i: %u\t j: %u\t Expected: %08X\t Actual: %08X\n",i,j,expected.state[i][j],actual.state[i][j]);
			TEST_ASSERT_MSG(expected.state[i][j] == actual.state[i][j],msg);
		}	
}
void equalityTestSuite::verifyEqual(const int expected[SUDOKU_GRID_SIZE][SUDOKU_GRID_SIZE],
					  							const int actual[SUDOKU_GRID_SIZE][SUDOKU_GRID_SIZE]) {
	for(size_t i=0;i<SUDOKU_GRID_SIZE;i++)
		for(size_t j=0;j<SUDOKU_GRID_SIZE;j++){
			char msg[128];
			sprintf(msg,"i: %u\t j: %u\t Expected: %u\t Actual: %u\n",i,j,expected[i][j],actual[i][j]);
			TEST_ASSERT_MSG(expected[i][j] == actual[i][j],msg);
		}			  
}
Example #25
0
void UserManagerTestSuite::register_new_user()
{
    User_Manager m;
    Security_Status status = m.register_user(good_username, good_password);
    std::string str_status = strStatus(status);
    TEST_ASSERT_MSG(status==Security_Status::ok_register, str_status.c_str());
    TEST_ASSERT(m.get_user()!=-1);
    assigned_id = m.get_user();
}
void RequestTests::Test_ExtractFile()
{
	bool bExec = false;
    CMtClient client("127.0.0.1", 50);
    std::string sErrorMsg;
	int nServerRetCode = -1;
	std::string sServerResponse;
	std::ostringstream stCommand;
	std::wstring sCrashReportFileName;
	std::wstring sFileItemName;
	std::wstring sOutFile;
	struct stat st;
	int nStatRes = -1;

	sCrashReportFileName = Utils::GetTestDataFolder();
	sCrashReportFileName += L"crashreport.zip";

	sFileItemName = L"crashdump.dmp";

	sOutFile = Utils::GetCurrentDir();
#ifdef _WIN32
	sOutFile += L"\\crashdump.dmp";
#else
    sOutFile += L"/crashdump.dmp";
#endif

	// Format command
	stCommand << "dumper --extract-file \"" <<
		strconv::w2utf8(sCrashReportFileName) << "\" \"" <<
		strconv::w2utf8(sFileItemName) << "\" \"" <<
		strconv::w2utf8(sOutFile) << "\"\n";

	// Execute daemon command - assume success
    bExec = client.ExecuteRequest(stCommand.str().c_str(), nServerRetCode, sServerResponse, sErrorMsg);
	TEST_ASSERT_MSG(bExec, sErrorMsg.c_str());
	TEST_ASSERT_MSG(nServerRetCode==0, "Invalid ret code %d", nServerRetCode);

	// Check that file really exists and is of correct length
	nStatRes = stat(strconv::w2a(sOutFile).c_str(), &st);
	TEST_ASSERT_MSG(nStatRes==0, "Couldn't stat output file.");
	TEST_ASSERT_MSG(st.st_size==16159, "Output file length is incorrect.");

	__TEST_CLEANUP__;
}
    void emptyAssetsSet()
    {
       cards::AssetMetadataMapping::AssetSet    expectedAssetSet;
       cards::AssetMetadataMapping::MetadataSet inputMetadataSet;

       inputMetadataSet.insert(mt0);
       
       TEST_ASSERT_MSG( mAssetMetadataMapping->describedAssets(inputMetadataSet) == expectedAssetSet,
            (mClassMsg + ":\t Failed to return proper EmptySet").c_str() );
    }
Example #28
0
void GMTS::key_resolution()
{
    Group_Manager g {group_id};
    std::string m {cmpstr(g.get_key(),group_key)};
    TEST_ASSERT_MSG(g.get_key()==group_key,m.c_str());
    Group_Manager h {group_key};
    Group_Manager j {group_name, 1};
    TEST_ASSERT(g.get_id()==group_id);
    TEST_ASSERT(j.get_id()==group_id);
}
    void unaugmentMD1toAT1()
    {
       cards::AssetMetadataMapping::AssetSet    expectedAssetSet;
       cards::AssetMetadataMapping::MetadataSet inputMetadataSet;
     
       inputMetadataSet.insert(mt1);
       mAssetMetadataMapping->unaugmentAsset(at1,mt1);

       TEST_ASSERT_MSG( mAssetMetadataMapping->describedAssets(inputMetadataSet) == expectedAssetSet,
            (mClassMsg + ":\t Failed to return proper EmptySet").c_str() );

    }
void RequestTests::SetUp()
{
	bool bStart = false;
	std::string sErrorMsg;

	// First start daemon - assume success
    bStart = StartDaemon(sErrorMsg);
    TEST_ASSERT_MSG(bStart, sErrorMsg.c_str());

	/* initialize random seed: */
	srand ( (unsigned int)time(NULL) );

	__TEST_CLEANUP__;
}