• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ AssertTrue函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中AssertTrue函数的典型用法代码示例。如果您正苦于以下问题:C++ AssertTrue函数的具体用法?C++ AssertTrue怎么用?C++ AssertTrue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了AssertTrue函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: audio_enumerateAndNameAudioDevicesNegativeTests

/**
 * \brief Negative tests around enumeration and naming of audio devices.
 * 
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_GetNumAudioDevices
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_GetAudioDeviceName
 */
int audio_enumerateAndNameAudioDevicesNegativeTests()
{
   int ret;
   int t;
   int i, j, no, nc;
   const char *name;
      
   /* Get number of devices. */
   no = SDL_GetNumAudioDevices(0);
   nc = SDL_GetNumAudioDevices(1);
   
   /* Invalid device index when getting name */
   for (t=0; t<2; t++) {
      /* Negative device index */
      i = -1;
      name = SDL_GetAudioDeviceName(i, t);
      AssertTrue(name == NULL, "SDL_GetAudioDeviceName(%i, %i): returned a name, should return NULL", i, t);
      
      /* Device index past range */
      for (j=0; j<3; j++) {
         i = (t) ? nc+j : no+j;
         name = SDL_GetAudioDeviceName(i, t);
         AssertTrue(name == NULL, "SDL_GetAudioDeviceName(%i, %i): returned a name, should return NULL", i, t);
      }
      
      /* Capture index past capture range but within output range */
      if ((no>0) && (no>nc) && (t==1)) {
         i = no-1;
         name = SDL_GetAudioDeviceName(i, t);
         AssertTrue(name == NULL, "SDL_GetAudioDeviceName(%i, %i): returned a name, should return NULL", i, t);
      }
   }
}
开发者ID:CliffsDover,项目名称:wesnoth_ios,代码行数:39,代码来源:testaudio.c


示例2: TestDict

 static void TestDict(DictPtr dict) {
   Optional<DictEntry> entry;
   entry = dict->MatchPrefix("BYVoid");
   AssertTrue(!entry.IsNull());
   AssertEquals("BYVoid", entry.Get().key);
   AssertEquals("byv", entry.Get().GetDefault());
   
   entry = dict->MatchPrefix("BYVoid123");
   AssertTrue(!entry.IsNull());
   AssertEquals("BYVoid", entry.Get().key);
   AssertEquals("byv", entry.Get().GetDefault());
   
   entry = dict->MatchPrefix(utf8("積羽沉舟"));
   AssertTrue(!entry.IsNull());
   AssertEquals(utf8("積羽沉舟"), entry.Get().key);
   AssertEquals(utf8("羣輕折軸"), entry.Get().GetDefault());
   
   entry = dict->MatchPrefix("Unknown");
   AssertTrue(entry.IsNull());
   
   const vector<DictEntry> matches = dict->MatchAllPrefixes(utf8("清華大學計算機系"));
   AssertEquals(3, matches.size());
   AssertEquals(utf8("清華大學"), matches.at(0).key);
   AssertEquals("TsinghuaUniversity", matches.at(0).GetDefault());
   AssertEquals(utf8("清華"), matches.at(1).key);
   AssertEquals("Tsinghua", matches.at(1).GetDefault());
   AssertEquals(utf8("清"), matches.at(2).key);
   AssertEquals("Tsing", matches.at(2).GetDefault());
 }
开发者ID:jy4618272,项目名称:OpenCC,代码行数:29,代码来源:DictTestUtils.hpp


示例3: TestIndexTreeMemoryPutPtrDuplicate

void TestIndexTreeMemoryPutPtrDuplicate(void)
{
	CIndexTreeMemory		cIndex;
	CTestIndexTreeObject	andrew;
	CTestIndexTreeObject	andrewToo;
	CTestIndexTreeObject**	pcResult;
	CArrayVoidPtr			avp;
	BOOL					bResult;

	cIndex.Init();

	andrew.Init("Andrew");
	bResult = cIndex.PutPtr(andrew.mszName, &andrew);
	AssertTrue(bResult);
	AssertTrue(cIndex.ValidateSize());
	AssertInt(1, cIndex.NumElements());

	andrewToo.Init("Andrew");
	bResult = cIndex.PutPtr(andrewToo.GetName(), &andrewToo);
	AssertTrue(bResult);
	AssertTrue(cIndex.ValidateSize());
	AssertInt(1, cIndex.NumElements());

	pcResult = (CTestIndexTreeObject**)cIndex.Get("Andrew");
	AssertPointer(&andrewToo, *pcResult);

	avp.Init();
	cIndex.FindAll(&avp);
	AssertInt(1, avp.NumElements());
	avp.Kill();

	cIndex.Kill();
}
开发者ID:andrewpaterson,项目名称:Codaphela.Test,代码行数:33,代码来源:TestIndexTreeBlockMemory.cpp


示例4: TestIndexesAddAndRemove

void TestIndexesAddAndRemove(void)
{
	CIndexes			cIndexes;
	void*				pvMem;
	int					i;

	i = 391287491;
	pvMem = &i;

	cIndexes.Init(512);
	AssertInt(0, (int)cIndexes.NumIndexed());
	
	cIndexes.Add(1, pvMem);
	AssertInt(1, (int)cIndexes.NumIndexed());

	cIndexes.Remove(1);
	AssertInt(0, (int)cIndexes.NumIndexed());
	AssertTrue(cIndexes.TestTopIsEmpty());

	cIndexes.Add(1, pvMem);
	AssertInt(1, (int)cIndexes.NumIndexed());

	cIndexes.Remove(1);
	AssertInt(0, (int)cIndexes.NumIndexed());
	AssertTrue(cIndexes.TestTopIsEmpty());

	cIndexes.Kill();
}
开发者ID:chrisjaquet,项目名称:Codaphela.Test,代码行数:28,代码来源:TestIndexes.cpp


示例5: test_find_one_input_for_xor

static int test_find_one_input_for_xor(OE oe) {
	CircuitVisitor cv = 0;
	CircuitParser cp = 0;
	Tokenizer tk = 0;
	List circuit = 0;
	Map input_gates = 0;
	List address_of_input_gates = 0;
	Gate g = 0;
	_Bool ok = 0;

	tk = FunCallTokenizer_New(oe);
	cp = CircuitParser_New(oe, tk);
	circuit = cp->parseSource((byte*)"XOR(0,1,1)",11);

	cv = InputGateVisitor_New(oe);
	input_gates = cv->visit(circuit);

	AssertTrue(input_gates != 0)
	address_of_input_gates = input_gates->get_keys();

	AssertTrue(((uint)address_of_input_gates->get_element(0) == 1));

	InputGateVisitor_Destroy(&cv);
	SingleLinkedList_destroy(&address_of_input_gates);

test_end:
	return ok;
}
开发者ID:AarhusCrypto,项目名称:EmpiricalZeroKnowledge,代码行数:28,代码来源:test_inputgatevisitor.c


示例6: test_server_CyaSSL_new

static void test_server_CyaSSL_new(void)
{
#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && !defined(NO_RSA)
    CYASSL_CTX *ctx;
    CYASSL_CTX *ctx_nocert;
    CYASSL *ssl;

    AssertNotNull(ctx_nocert = CyaSSL_CTX_new(CyaSSLv23_server_method()));
    AssertNotNull(ctx        = CyaSSL_CTX_new(CyaSSLv23_server_method()));

    AssertTrue(CyaSSL_CTX_use_certificate_file(ctx, svrCert, SSL_FILETYPE_PEM));
    AssertTrue(CyaSSL_CTX_use_PrivateKey_file(ctx, svrKey, SSL_FILETYPE_PEM));

    /* invalid context */
    AssertNull(ssl = CyaSSL_new(NULL));
    AssertNull(ssl = CyaSSL_new(ctx_nocert));

    /* success */
    AssertNotNull(ssl = CyaSSL_new(ctx));

    CyaSSL_free(ssl);
    CyaSSL_CTX_free(ctx);
    CyaSSL_CTX_free(ctx_nocert);
#endif
}
开发者ID:UNIVERSAL-IT-SYSTEMS,项目名称:cyassl,代码行数:25,代码来源:api.c


示例7: TestChunkFileMD5ing

void TestChunkFileMD5ing(void)
{
	char			szFox[] = "The quick brown fox jumps over the lazy dog";
	unsigned char	ucFoxMD5[] = {0x9e, 0x10, 0x7d, 0x9d, 0x37, 0x2b, 0xb6, 0x82, 0x6b, 0xd8, 0x1d, 0x35, 0x42, 0xa4, 0x19, 0xd6};
	int				iFoxLen;
	char			szLorem[] = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
	unsigned char	ucLoremMD5[] = {0xfa, 0x5c, 0x89, 0xf3, 0xc8, 0x8b, 0x81, 0xbf, 0xd5, 0xe8, 0x21, 0xb0, 0x31, 0x65, 0x69, 0xaf};
	int				iLoremLen;
	CChunkFile		cChunkFile;

	iFoxLen = (int)strlen(szFox);
	iLoremLen = (int)strlen(szLorem);

	cChunkFile.Init(MemoryFile());
	AssertTrue(cChunkFile.WriteOpen());
	AssertTrue(cChunkFile.WriteChunkBegin());
	AssertTrue(cChunkFile.Write(szFox, 1, iFoxLen) > 0);
	AssertTrue(cChunkFile.WriteChunkEnd("ChunkName"));
	AssertTrue(cChunkFile.Write(szLorem, 1, iLoremLen) > 0);
	AssertTrue(cChunkFile.WriteClose());

	AssertTrue(cChunkFile.ReadOpen());
	AssertMD5(ucLoremMD5, (unsigned char *)cChunkFile.GetMD5Hash());
	AssertTrue(cChunkFile.ReadChunkBegin(0));
	AssertMD5(ucFoxMD5, (unsigned char *)cChunkFile.GetMD5Hash());
	AssertTrue(cChunkFile.ReadChunkEnd());
	AssertTrue(cChunkFile.ReadClose());

	cChunkFile.Kill();
}
开发者ID:andrewpaterson,项目名称:Codaphela.Test,代码行数:30,代码来源:TestChunkFile.cpp


示例8: TestSetTypeInstantiation

void TestSetTypeInstantiation(void)
{
	UnknownsInit();

	CSetType<CTestUnknown>	cSet;
	CTestUnknown*			pcTest1;
	CTestUnknown*			pcTest2;
	CTestUnknown*			pcTest;
	int						iSize;
	char*					szName;
	SSetIterator			sIter;
	int						iCount;

	cSet.Init();

	pcTest1 = cSet.Add();
	pcTest1->Init();
	pcTest2 = UMalloc(CTestUnknown);
	pcTest2->Init();
	cSet.Add(pcTest2);

	iCount = 0;
	pcTest = cSet.StartIteration(&sIter);
	while (pcTest)
	{
		iCount++;
		pcTest = cSet.Iterate(&sIter);
	}
	AssertInt(2, iCount);
	AssertInt(2, cSet.NumElements());

	//This test is not correct.  The order is not guaranteed.
	//However it necessary to make the template compile.
	AssertTrue(cSet.Contains(pcTest1));
	AssertTrue(cSet.Contains(pcTest2));

	pcTest = cSet.StartIteration(&sIter);
	AssertPointer(pcTest1, pcTest);
	pcTest = cSet.Iterate(&sIter);
	AssertPointer(pcTest2, pcTest);

	pcTest = cSet.StartIteration(&sIter);
	cSet.RemoveDuringIteration(&sIter);
	pcTest = cSet.Iterate(&sIter);
	AssertPointer(pcTest2, pcTest);

	AssertInt(1, cSet.NumElements());

	cSet.Remove(pcTest2);
	AssertInt(0, cSet.NumElements());

	iSize = cSet.ClassSize();
	AssertInt(40, iSize);

	szName = cSet.ClassName();
	AssertString("CSetType", szName);

	cSet.Kill();
	UnknownsKill();
}
开发者ID:chrisjaquet,项目名称:Codaphela.Test,代码行数:60,代码来源:TestSetType.cpp


示例9: MediaItem_GetProperty

template<> const std::string&& MediaItem_GetProperty(MediaItem* item, const char* property)
{
   AssertTrue(item != 0);
   AssertTrue(property != 0);
      
   char* resultPtr = reinterpret_cast<char*>(GetSetMediaItemInfo(item, property, 0));
   std::string value(resultPtr);
   return std::move(value);
}
开发者ID:Ultraschall,项目名称:Legacy,代码行数:9,代码来源:Auphonic.cpp


示例10: MediaTrack_GetProperty

template<> const std::string&& MediaTrack_GetProperty(MediaTrack* track, const char* property)
{
   AssertTrue(track != 0);
   AssertTrue(property != 0);
      
   char* resultPtr = reinterpret_cast<char*>(GetSetMediaTrackInfo(track, property, 0));
   std::string value(resultPtr);
   return std::move(value);
}
开发者ID:Ultraschall,项目名称:Legacy,代码行数:9,代码来源:Auphonic.cpp


示例11: TestDehollowficationFromDatabaseOfTwoPointers

void TestDehollowficationFromDatabaseOfTwoPointers(void)
{
	CIndexedConfig	cConfig;
	CFileUtil		cFileUtil;

	cConfig.Manual("Output\\Dehollowfication\\Database",
		FALSE,
		TRUE,
		FALSE,
		1 MB);

	cFileUtil.RemoveDir("Output\\Dehollowfication\\Database");

	MemoryInit();
	ObjectsInit(&cConfig);
	SetupDehollowficationScene();
	gcObjects.Flush(FALSE, FALSE);
	ObjectsKill();
	MemoryKill();

	MemoryInit();
	ObjectsInit(&cConfig);
	SetupDehollowficationConstructors();

	Ptr<CRoot> pRoot = ORoot();
	Ptr<CTestDoubleNamedString> pDouble = pRoot->Get<CTestDoubleNamedString>("Double Start");

	Ptr<CTestNamedString> pString1 = pDouble->mpSplit1;
	Ptr<CTestNamedString> pString2 = pDouble->mpSplit2;
	pString1->ClassName();
	pString2->ClassName();

	Ptr<CTestNamedString> pDiamond1 = pString1->mpAnother;
	Ptr<CTestNamedString> pDiamond2 = pString2->mpAnother;

	AssertTrue(pDiamond1.IsHollow());
	AssertTrue(pDiamond2.IsHollow());
	AssertPointer(pDiamond1.Object(), pDiamond2.Object());
	AssertPointer(pString1->mpAnother.Object(), pString2->mpAnother.Object());
	AssertLongLongInt(3LL, pDiamond1.GetIndex());
	AssertLongLongInt(3LL, pDiamond2.GetIndex());

	//Dehollofication of pDiamond1 happens here. pString1->mpAnother and pString2->mpAnother are remapped to the dehollowed diamond object.
	pDiamond1->ClassName();

	AssertFalse(pDiamond1.IsHollow());
	AssertFalse(pDiamond2.IsHollow());  //This should be false but it's not until I remap local pointers.
	AssertPointer(pDiamond1.Object(), pDiamond2.Object());  //These should be the same but they're not until I remap local pointers.
	AssertLongLongInt(3LL, pDiamond1.GetIndex());

	AssertFalse(pString1->mpAnother.IsHollow());
	AssertFalse(pString2->mpAnother.IsHollow());
	AssertPointer(pString1->mpAnother.Object(), pString2->mpAnother.Object());

	ObjectsKill();
	MemoryKill();
}
开发者ID:andrewpaterson,项目名称:Codaphela.Test,代码行数:57,代码来源:TestDehollowfication.cpp


示例12: audio_printCurrentAudioDriver

/**
 * @brief Checks current audio driver name with initialized audio.
 */
int audio_printCurrentAudioDriver()
{
   int ret;
   const char *name;

   /* Check current audio driver */
   name = SDL_GetCurrentAudioDriver();
   AssertTrue(name != NULL, "name != NULL");
   AssertTrue(strlen(name)>0, "name empty");
}
开发者ID:CliffsDover,项目名称:wesnoth_ios,代码行数:13,代码来源:testaudio.c


示例13: TestIndexTreeMemoryAdd

void TestIndexTreeMemoryAdd(void)
{
	CIndexTreeMemory		cIndex;
	CTestIndexTreeObject	a;
	CTestIndexTreeObject	aa;
	CTestIndexTreeObject	temp;
	CArrayVoidPtr			avp;
	BOOL					bResult;
	CIndexTreeNodeMemory*	pcNode;
	CTestIndexTreeObject**	ppvTest;
	CTestIndexTreeObject***	ppvTestA;
	CTestIndexTreeObject***	ppvTestAA;

	cIndex.Init();
	a.Init("A");
	bResult = cIndex.PutPtr(a.GetName(), &a);
	AssertTrue(bResult);

	pcNode = cIndex.GetNode("A", 1);
	ppvTest = (CTestIndexTreeObject**)pcNode->GetObjectPtr();
	AssertPointer(&a, *ppvTest);

	aa.Init("AA");
	bResult = cIndex.PutPtr(aa.GetName(), &aa);
	AssertTrue(bResult);

	pcNode = cIndex.GetNode("A", 1);
	ppvTest = (CTestIndexTreeObject**)pcNode->GetObjectPtr();
	AssertPointer(&a, *ppvTest);

	pcNode = cIndex.GetNode("AA", 2);
	ppvTest = (CTestIndexTreeObject**)pcNode->GetObjectPtr();
	AssertPointer(&aa, *ppvTest);

	avp.Init();
	cIndex.FindAll(&avp);
	AssertInt(2, avp.NumElements());
	ppvTestA = (CTestIndexTreeObject***)avp.Get(0);
	ppvTestAA = (CTestIndexTreeObject***)avp.Get(1);
	AssertPointer(&a, **ppvTestA);
	AssertPointer(&aa, **ppvTestAA);
	AssertString("A", (**ppvTestA)->mszName);
	AssertString("AA", (**ppvTestAA)->mszName);

	avp.Kill();
	cIndex.Kill();

	cIndex.Init();
	bResult = cIndex.PutPtr(NULL, &temp);
	AssertFalse(bResult);
	bResult = cIndex.PutPtr("", &temp);
	AssertFalse(bResult);

	cIndex.Kill();
}
开发者ID:andrewpaterson,项目名称:Codaphela.Test,代码行数:55,代码来源:TestIndexTreeBlockMemory.cpp


示例14: TestChunkFileSimple

void TestChunkFileSimple(void)
{
	CChunkFile	cChunkFile;
	CFileUtil	cFileUtil;
	int			iChunkNum;
	
	cFileUtil.MakeDir("Output");
	cFileUtil.Delete("Output/ChunkFile.bin");
	cChunkFile.Init(DiskFile("Output/ChunkFile.bin"));
	AssertFalse(cChunkFile.IsOpen());
	AssertTrue(cChunkFile.WriteOpen());
	AssertTrue(cChunkFile.IsOpen());
	AssertTrue(cChunkFile.WriteChunkBegin());
	AssertTrue(cChunkFile.WriteChunkEnd("ThisChunk"));
	AssertTrue(cChunkFile.WriteClose());
	AssertFalse(cChunkFile.IsOpen());
	cChunkFile.Kill();

	cChunkFile.Init(DiskFile("Output/ChunkFile.bin"));
	AssertFalse(cChunkFile.IsOpen());
	AssertTrue(cChunkFile.ReadOpen());
	AssertTrue(cChunkFile.IsOpen());
	iChunkNum = cChunkFile.FindFirstChunkWithName("ThisChunk");
	AssertInt(0, iChunkNum);
	AssertTrue(cChunkFile.ReadChunkBegin(iChunkNum));
	AssertTrue(cChunkFile.ReadClose());
	AssertFalse(cChunkFile.IsOpen());
	cChunkFile.Kill();
}
开发者ID:andrewpaterson,项目名称:Codaphela.Test,代码行数:29,代码来源:TestChunkFile.cpp


示例15: TestObjectReaderSimpleDeserialised

void TestObjectReaderSimpleDeserialised(void)
{
	WriteObjectReaderSimpleFile();

	CObjectReaderSimpleDisk		cReader;
	CObjectGraphDeserialiser	cGraphDeserialiser;
	CPointer					cBase;

	Ptr<CTestNamedString>		cNS1;
	Ptr<CTestNamedString>		cNS2;
	CPointer					cTemp;

	CObjectAllocator			cAllocator;
	CDependentReadObjects		cDependentReadObjects;

	MemoryInit();
	ObjectsInit();

	gcObjects.AddConstructor<CTestNamedString>();

	AssertLongLongInt(0, gcObjects.NumDatabaseObjects());
	AssertLongLongInt(0, gcObjects.NumMemoryIndexes());

	cAllocator.Init(&gcObjects);
	cDependentReadObjects.Init();
	cReader.Init("Output\\ObjectReaderSimple\\Test\\");
	cGraphDeserialiser.Init(&cReader, FALSE, &cAllocator, &cDependentReadObjects, gcObjects.GetMemory());
	cBase = cGraphDeserialiser.Read("Waggy");

	AssertLongLongInt(0, gcObjects.NumDatabaseObjects());
	AssertLongLongInt(2, gcObjects.NumMemoryIndexes());

	cNS1 = gcObjects.Get("Waggy");
	AssertTrue(cNS1.IsNotNull());
	AssertString("NS1", cNS1->mszEmbedded.Text());

	cNS2 = gcObjects.Get("Dog");
	AssertTrue(cNS2.IsNotNull());
	AssertString("NS2", cNS2->mszEmbedded.Text());

	AssertTrue(cBase.IsNotNull());
	AssertString("CTestNamedString", cBase->ClassName());
	AssertPointer(&cNS1, &cBase);

	AssertPointer(&cNS2, &cNS1->mpAnother);
	AssertPointer(NULL, &cNS2->mpAnother);

	cGraphDeserialiser.Kill();
	cDependentReadObjects.Kill();
	cAllocator.Kill();
	cReader.Kill();

	ObjectsKill();
}
开发者ID:andrewpaterson,项目名称:Codaphela.Test,代码行数:54,代码来源:TestObjectReaderSimple.cpp


示例16: test_CyaSSL_read_write

static void test_CyaSSL_read_write(void)
{
#ifdef HAVE_IO_TESTS_DEPENDENCIES
    /* The unit testing for read and write shall happen simutaneously, since
     * one can't do anything with one without the other. (Except for a failure
     * test case.) This function will call all the others that will set up,
     * execute, and report their test findings.
     *
     * Set up the success case first. This function will become the template
     * for the other tests. This should eventually be renamed
     *
     * The success case isn't interesting, how can this fail?
     * - Do not give the client context a CA certificate. The connect should
     *   fail. Do not need server for this?
     * - Using NULL for the ssl object on server. Do not need client for this.
     * - Using NULL for the ssl object on client. Do not need server for this.
     * - Good ssl objects for client and server. Client write() without server
     *   read().
     * - Good ssl objects for client and server. Server write() without client
     *   read().
     * - Forgetting the password callback?
    */
    tcp_ready ready;
    func_args client_args;
    func_args server_args;
    THREAD_TYPE serverThread;

#ifdef CYASSL_TIRTOS
    fdOpenSession(Task_self());
#endif

    StartTCP();
    InitTcpReady(&ready);
    
    server_args.signal = &ready;
    client_args.signal = &ready;
    
    start_thread(test_server_nofail, &server_args, &serverThread);
    wait_tcp_ready(&server_args);
    test_client_nofail(&client_args);
    join_thread(serverThread);

    AssertTrue(client_args.return_code);
    AssertTrue(server_args.return_code);

    FreeTcpReady(&ready);

#ifdef CYASSL_TIRTOS
    fdOpenSession(Task_self());
#endif

#endif
}
开发者ID:UNIVERSAL-IT-SYSTEMS,项目名称:cyassl,代码行数:53,代码来源:api.c


示例17: TestVirtualCall

void TestVirtualCall(void)
{
	MemoryInit();
	UnknownsInit();

	CTestObjectIsListenerWithEvent*		pcTest;
	CTestObjectIsListener*				pcListener;
	CTestAnotherListener				cAnother1;
	CTestAnotherListener				cAnother2;
	CTestAnotherListener				cAnother3;
	BOOL								bResult;

	pcTest = UMalloc(CTestObjectIsListenerWithEvent);
	pcTest->Init();

	pcListener = UMalloc(CTestObjectIsListener);
	pcListener->Init();

	AssertInt(WH_SomeOneSetUpUsTheBomb, pcTest->meWhatHappen);
	AssertString("Nothing to see here", pcListener->mszAlsoBored.Text());
	AssertInt(0, pcTest->miBored);

	bResult = pcTest->AddListener<CTestListener>(pcListener);
	AssertTrue(bResult);
	bResult = pcTest->AddListener(&cAnother1);
	AssertTrue(bResult);
	bResult = pcTest->AddListener(&cAnother2);
	AssertTrue(bResult);

	pcTest->MakeEventStyle1Happen();
	AssertInt(WH_WeGetSignal, pcTest->meWhatHappen);
	AssertString("Sup my homies", pcListener->mszAlsoBored.Text());
	AssertInt(1, pcTest->miBored);

	pcTest->MakeEventStyle2Happen();
	AssertInt(WH_MoveZigForGreatJustice, pcTest->meWhatHappen);
	AssertString("Wikky wikky free styling", pcListener->mszAlsoBored.Text());
	AssertInt(2, pcTest->miBored);

	pcTest->CallListeners(&CTestAnotherListener::Another, pcTest, NULL);
	AssertInt(1, cAnother1.iThisIsNotTheRightWayToUseListeners);
	AssertInt(1, cAnother2.iThisIsNotTheRightWayToUseListeners);
	AssertInt(0, cAnother3.iThisIsNotTheRightWayToUseListeners);

	bResult = pcTest->AddListener<CTestBadListener>(NULL);
	AssertFalse(bResult);

	pcListener->Kill();
	pcTest->Kill();

	UnknownsKill();
	MemoryKill();
}
开发者ID:andrewpaterson,项目名称:Codaphela.Test,代码行数:53,代码来源:TestEvent.cpp


示例18: TestObjectDehollowfication

void TestObjectDehollowfication(void)
{
	CFileUtil						cFileUtil;
	CPointer						pPointer;
	CTestDoubleNamedString*			pcInternal;
	Ptr<CTestDoubleNamedString>		pDouble;
	Ptr<CTestNamedString>			pSingle;
	int								iClassSize;
	OIndex							oiOld;
	OIndex							oiNew;

	cFileUtil.RemoveDir("Output");
	cFileUtil.MakeDir("Output/Dehollowfication");
	ObjectsInit("Output/Dehollowfication");
	SetupObjectsForDehollowfication();
	gcObjects.Flush(TRUE, TRUE);
	AssertLongLongInt(9, gcObjects.NumDatabaseObjects());
	ObjectsKill();

	ObjectsInit("Output/Dehollowfication");
	SetupObjectsConstructors();
	AssertLongLongInt(9, gcObjects.NumDatabaseObjects());

	AssertTrue(gcObjects.Contains("Double"));

	pPointer = gcObjects.Get("Double");
	AssertNotNull(pPointer.Object());
	AssertString("CTestDoubleNamedString", pPointer.ClassName());

	pcInternal = (CTestDoubleNamedString*)pPointer.Object();
	AssertTrue(pcInternal->mpSplit1.IsNotNull());
	AssertTrue(pcInternal->mpSplit1.IsHollow());
	AssertTrue(pcInternal->mpSplit2.IsNotNull());
	AssertTrue(pcInternal->mpSplit2.IsHollow());

	pDouble = pPointer;

	oiOld = pDouble->mpSplit1.GetIndex();
	AssertTrue(pcInternal->mpSplit1.IsHollow());  //Making sure we haven't de-hollowed the object by calling GetIndex.

	//Problem - An oi of 1 is briefly assigned to the de-hollowed object and then it is reassigned back to its original value.
	iClassSize = pDouble->mpSplit1->ClassSize();  //The method call - ClassSize() - is irrelevant as long as the -> operator on mpSplit1 is invoked.
	AssertTrue(pcInternal->mpSplit1.IsNotNull());
	AssertFalse(pcInternal->mpSplit1.IsHollow());
	AssertInt(sizeof(CTestNamedString), iClassSize);
	AssertString("CTestNamedString", pcInternal->mpSplit1.ClassName());
	oiNew = pDouble->mpSplit1.GetIndex();
	AssertLongLongInt(oiOld, oiNew);

	pSingle = pDouble->mpSplit2;
	AssertTrue(pcInternal->mpSplit2.IsNotNull());
	AssertTrue(pcInternal->mpSplit2.IsHollow());

	ObjectsKill();
}
开发者ID:andrewpaterson,项目名称:Codaphela.Test,代码行数:55,代码来源:TestObjects.cpp


示例19: TestLogFileRead

void TestLogFileRead(void)
{
	CLogFile*		pcLogFile;
	CMemoryFile*	pcMemoryFile;
	CFileBasic		cFile;
	BOOL			bResult;
	int				iLength;
	char			sz[200];
	filePos			iRead;

	pcMemoryFile = MemoryFile();
	cFile.Init(pcMemoryFile);
	cFile.Open(EFM_Write_Create);
	cFile.WriteString("The suspense is killing me!");
	cFile.Close();

	pcLogFile = LogFile(pcMemoryFile);
	cFile.Init(pcLogFile);

	bResult = cFile.Open(EFM_Read);
	AssertTrue(bResult);

	pcLogFile->Begin();

	bResult = cFile.ReadStringLength(&iLength);
	AssertTrue(bResult);
	AssertInt(28, iLength);
	AssertFalse(cFile.IsEndOfFile());
	bResult = cFile.ReadStringChars(sz, iLength);
	AssertString("The suspense is killing me!", sz);
	AssertTrue(cFile.IsEndOfFile());

	memset(sz, 0, 200);
	bResult = cFile.Seek(20);
	AssertTrue(bResult);
	bResult = cFile.ReadStringChars(sz, 8);
	AssertString("killing ", sz);
	AssertLongLongInt(28, cFile.GetFilePos());
	AssertFalse(cFile.IsEndOfFile());

	memset(sz, 0, 200);
	bResult = cFile.ReadStringChars(sz, 4);
	AssertString("me!", sz);
	AssertLongLongInt(32, cFile.GetFilePos());
	AssertTrue(cFile.IsEndOfFile());

	iRead = cFile.Read(sz, 1, 1);
	AssertLongLongInt(0, iRead);
	AssertLongLongInt(32, cFile.GetFilePos());
	AssertTrue(cFile.IsEndOfFile());

	AssertLongLongInt(32, cFile.GetFilePos());
	AssertTrue(cFile.IsEndOfFile());

	bResult = cFile.Close();
	AssertTrue(bResult);

	cFile.Kill();
}
开发者ID:chrisjaquet,项目名称:Codaphela.Test,代码行数:59,代码来源:TestLogFile.cpp


示例20: TestEmbeddedObjectPointTo

void TestEmbeddedObjectPointTo(void)
{
	BOOL		bResult;
	CFileUtil	cFileUtil;
	OIndex		oiComplex;
	char*		szClassName;
	
	cFileUtil.RemoveDir("Output/EmbeddedObject");

	MemoryInit();
	ObjectsInit("Output/EmbeddedObject/");
	SetupEmbeddedObjectConstructors();

	Ptr<CRoot> pRoot = ORoot();
	Ptr<CEmbeddedComplex> pComplex = OMalloc(CEmbeddedComplex)->Init();
	oiComplex = pComplex->GetOI();

	Ptr<CEmbeddedContainer> pContainer = &pComplex->mcContainer;
	pRoot->Add(pContainer);

	bResult = gcObjects.Flush(TRUE, TRUE);
	AssertTrue(bResult);

	ObjectsKill();
	MemoryKill();

	AssertNull(&pContainer);

	MemoryInit();
	ObjectsInit("Output/EmbeddedObject/");
	SetupEmbeddedObjectConstructors();

	pRoot = gcObjects.GetRoot();
	AssertTrue(pRoot.IsNotNull());
	pContainer = pRoot->Get(0);
	AssertTrue(pContainer.IsHollow());
	AssertInt(0, pContainer.Object()->GetNumEmbedded());
	AssertLongLongInt(-1, pContainer.GetIndex());

	szClassName = pContainer->ClassName();
	AssertString("CEmbeddedContainer", szClassName);

	pComplex = pContainer->GetEmbeddingContainer();
	//Kinda feels like this test just stopped...

	ObjectsKill();
	MemoryKill();
}
开发者ID:andrewpaterson,项目名称:Codaphela.Test,代码行数:48,代码来源:TestEmbedded.cpp



注:本文中的AssertTrue函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ AssertValidStringPtr函数代码示例发布时间:2022-05-30
下一篇:
C++ AssertSz函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap