本文整理汇总了C++中AssertTrue函数的典型用法代码示例。如果您正苦于以下问题:C++ AssertTrue函数的具体用法?C++ AssertTrue怎么用?C++ AssertTrue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AssertTrue函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
}
示例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());
}
示例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();
}
示例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();
}
示例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;
}
示例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
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例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();
}
示例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");
}
示例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();
}
示例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();
}
示例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();
}