void TestLinkListAlignedRemove(void)
{
	CLinkListAligned	cLinkListAligned;
	void*				pv1;
	void*				pv2;
	void*				pv3;
	void*				pv;

	cLinkListAligned.Init();
	pv1 = cLinkListAligned.InsertAfterTail(1, 4, 0);
	pv2 = cLinkListAligned.InsertAfterTail(2, 4, 0);
	pv3 = cLinkListAligned.InsertAfterTail(3, 4, 0);
	cLinkListAligned.Remove(pv2);

	pv = cLinkListAligned.GetHead();
	AssertPointer(pv1, pv);
	pv = cLinkListAligned.GetNext(pv);
	AssertPointer(pv3, pv);
	pv = cLinkListAligned.GetNext(pv);
	AssertNull(pv);

	cLinkListAligned.Remove(pv1);
	cLinkListAligned.Remove(pv3);

	pv = cLinkListAligned.GetHead();
	AssertNull(pv);
}
Пример #2
0
void TestIndexTreeBlockMemoryRemoveByObject(void)
{
	CIndexTreeBlockMemory	cIndex;
	CTestIndexTreeObject	object1;
	CTestIndexTreeObject	object2;
	CTestIndexTreeObject	object3;
	CTestIndexTreeObject**	ppcRemoved;

	cIndex.Init();

	AssertInt(1, cIndex.CountAllocatedNodes());

	object1.Init("denarii");
	cIndex.PutPtr(object1.GetName(), &object1);
	AssertInt(8, cIndex.CountAllocatedNodes());

	object2.Init("dendrodra");
	cIndex.PutPtr(object2.GetName(), &object2);

	object3.Init("dendrons");
	cIndex.PutPtr(object3.GetName(), &object3);

	AssertInt(3, cIndex.NumElements());
	ppcRemoved = (CTestIndexTreeObject**)cIndex.Get(object2.GetName());
	AssertPointer(&object2, *ppcRemoved);
	AssertTrue(cIndex.Remove(object2.GetName()));
	ppcRemoved = (CTestIndexTreeObject**)cIndex.Get(object2.GetName());
	AssertNull(ppcRemoved);
	AssertInt(2, cIndex.NumElements());
	AssertFalse(cIndex.Remove(object2.GetName()));
	AssertInt(2, cIndex.NumElements());

	AssertInt(13, cIndex.CountAllocatedNodes());
	cIndex.Remove(object3.GetName());

	AssertInt(1, cIndex.NumElements());
	AssertInt(8, cIndex.CountAllocatedNodes());

	cIndex.PutPtr(object3.GetName(), &object3);
	AssertInt(13, cIndex.CountAllocatedNodes());

	AssertInt(2, cIndex.NumElements());
	ppcRemoved = (CTestIndexTreeObject**)cIndex.Get(object3.GetName());
	AssertPointer(&object3, *ppcRemoved);
	AssertTrue(cIndex.Remove(object3.GetName()));
	ppcRemoved = (CTestIndexTreeObject**)cIndex.Get(object3.GetName());
	AssertNull(ppcRemoved);
	AssertInt(1, cIndex.NumElements());
	ppcRemoved = (CTestIndexTreeObject**)cIndex.Get(object1.GetName());
	AssertPointer(&object1, *ppcRemoved);
	AssertTrue(cIndex.Remove(object1.GetName()));
	ppcRemoved = (CTestIndexTreeObject**)cIndex.Get(object1.GetName());
	AssertNull(ppcRemoved);
	AssertInt(0, cIndex.NumElements());

	AssertFalse(cIndex.Remove(NULL));
	AssertFalse(cIndex.Remove(""));

	cIndex.Kill();
}
Пример #3
0
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();
}
void AssertLinkOrder(CMemoryCache* pcCache)
{
	SMemoryCacheDescriptor*	psCacheDesc;
	SMemoryCacheDescriptor*	psCacheDescReverse;
	CArrayPointer			cPointers;
	int						i;

	AssertPointer(pcCache->TestGetFirst()->psPrev, pcCache->TestGetLast());
	AssertPointer(pcCache->TestGetLast()->psNext, pcCache->TestGetFirst());

	cPointers.Init(10);
	psCacheDesc = pcCache->TestGetFirst();

	for (;;)
	{
		cPointers.Add(psCacheDesc, 0);
		psCacheDesc = psCacheDesc->psNext;
		if (psCacheDesc == pcCache->TestGetFirst())
		{
			break;
		}
	}

	psCacheDesc = pcCache->TestGetLast();
	for (i = cPointers.NumElements() - 1; i >= 0; i--)
	{
		psCacheDescReverse = (SMemoryCacheDescriptor*)cPointers.GetPtr(i);
		
		AssertPointer(psCacheDesc, psCacheDescReverse);

		psCacheDesc = psCacheDesc->psPrev;
	}

	cPointers.Kill();
}
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();
}
Пример #6
0
void TestDurableSetAdd(void)
{
	CFileUtil				cFileUtil;
	CDurableFileController	cController;
	CDurableFile			cDurableFile1;
	CDurableFile			cDurableFile2;
	CDurableFile			cDurableFile3;
	CDurableFile			cDurableFile4;
	char					szDirectory[] = "Durable2";
	char					szRewrite[] = "_Durable2";
	CDurableFile*			pcDurableFile;

	cFileUtil.RemoveDir(szDirectory);
	cFileUtil.MakeDir(szDirectory);
	cFileUtil.RemoveDir(szRewrite);
	cFileUtil.MakeDir(szRewrite);

	cController.Init(szDirectory, szRewrite);

	cDurableFile1.Init(&cController, "Durable" _FS_ "1.txt", "Durable" _FS_ "_1.txt");
	cDurableFile2.Init(&cController, "Durable" _FS_ "2.txt", "Durable" _FS_ "_2.txt");
	cDurableFile3.Init(&cController, "Durable" _FS_ "3.txt", "Durable" _FS_ "_3.txt");
	cDurableFile4.Init(&cController, "Durable" _FS_ "4.txt", "Durable" _FS_ "_4.txt");
	cController.Begin();

	cController.AddFile(&cDurableFile1);
	AssertInt(1, cController.NumFiles());
	pcDurableFile = cController.GetFile(0);
	AssertPointer(&cDurableFile1, pcDurableFile);

	cController.AddFile(&cDurableFile1);
	AssertInt(1, cController.NumFiles());
	pcDurableFile = cController.GetFile(0);
	AssertPointer(&cDurableFile1, pcDurableFile);

	cController.AddFile(&cDurableFile2);
	AssertInt(2, cController.NumFiles());
	cController.AddFile(&cDurableFile3);
	AssertInt(3, cController.NumFiles());
	cController.AddFile(&cDurableFile4);
	AssertInt(4, cController.NumFiles());

	cController.AddFile(&cDurableFile2);
	AssertInt(4, cController.NumFiles());
	cController.AddFile(&cDurableFile3);
	AssertInt(4, cController.NumFiles());
	cController.AddFile(&cDurableFile4);
	AssertInt(4, cController.NumFiles());

	cController.End();
	cDurableFile1.Kill();
	cDurableFile2.Kill();
	cDurableFile3.Kill();
	cDurableFile4.Kill();
	cController.Kill();
}
Пример #7
0
void TestMapBlockInternals(void)
{
	CMapBlock			cMapBlock;
	int					i;
	int					j;
	int					iKey;
	int*				piData;
	CArrayBlockSorted*	paBlock;
	SMNode**			psNode1;
	SMNode**			psNode2;
	int*				piKey;

	cMapBlock.Init(1024, &CompareInt, TRUE);
	i = 7; j = 43;
	cMapBlock.Put(&i, sizeof(int), &j, sizeof(int));

	i = 9; j = 21;
	cMapBlock.Put(&i, sizeof(int), &j, sizeof(int));
	AssertInt(2, cMapBlock.NumElements());

	paBlock = cMapBlock.GetArray();
	paBlock->InsertHoldingIntoSorted();
	psNode1 = (SMNode**)paBlock->GetInSorted(0);
	psNode2 = (SMNode**)paBlock->GetInSorted(1);
	AssertInt(sizeof(int), (*psNode1)->iDataSize);
	AssertInt(sizeof(int), (*psNode1)->iKeySize);
	AssertPointer(&cMapBlock, (*psNode1)->pcMapBlock);
	AssertInt(sizeof(int), (*psNode2)->iDataSize);
	AssertInt(sizeof(int), (*psNode2)->iKeySize);
	AssertPointer(&cMapBlock, (*psNode2)->pcMapBlock);
	piKey = (int*)RemapSinglePointer(*psNode1, sizeof(SMNode));
	AssertInt(7, *piKey);
	piData = (int*)RemapSinglePointer(piKey, (int)sizeof(int));
	AssertInt(43, *piData);
	piKey = (int*)RemapSinglePointer(*psNode2, sizeof(SMNode));
	AssertInt(9, *piKey);
	piData = (int*)RemapSinglePointer(piKey, (int)sizeof(int));
	AssertInt(21, *piData);

	iKey = 7; piData = NULL;
	cMapBlock.Get(&iKey, (void**)&piData, NULL);
	AssertNotNull(piData);
	AssertInt(43, *piData);

	iKey = 9; piData = NULL;
	cMapBlock.Get(&iKey, (void**)&piData, NULL);
	AssertNotNull(piData);
	AssertInt(21, *piData);

	iKey = 3; piData = NULL;
	cMapBlock.Get(&iKey, (void**)&piData, NULL);
	AssertNull(piData);

	cMapBlock.Kill();
}
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();
}
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();
}
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();
}
Пример #11
0
void TestArrayAllocation(void)
{
	CTestArray					asTestArray;
	STestArrayTemplateItem*		psItem;
	int				i;

	asTestArray.Init(10);
	AssertInt(sizeof(STestArrayTemplateItem), asTestArray.ElementSize());
	AssertInt(0, asTestArray.NumElements());
	AssertInt(0, asTestArray.AllocatedElements());
	AssertInt(10, asTestArray.ChunkSize());
	AssertPointer(NULL, asTestArray.GetData());

	psItem = asTestArray.Add();
	AssertInt(1, asTestArray.NumElements());
	AssertInt(10, asTestArray.AllocatedElements());
	AssertInt(10, asTestArray.ChunkSize());
	AssertFalse(asTestArray.GetData() == NULL);

	psItem->i1 = 1;
	psItem->i2 = 2;

	//Add upto and including the eleventh element.  This will cause the array to be reallocated.
	for (i = 0; i < 10; i++)
	{
		asTestArray.Add();
	}

	//Make sure the elements haven't been corrupted on reallocation.
	psItem = asTestArray.Get(0);
	AssertInt(1, psItem->i1);
	AssertInt(2, psItem->i2);

	asTestArray.Kill();
}
void TestArrayTemplateEmbeddedAdd(void)
{
	CArrayTemplateEmbedded<int, 5>	cArray;
	int*					pi;
	int*					piEmbeddedData;

	cArray.Init();
	AssertInt(0, cArray.NumElements());
	piEmbeddedData = cArray.GetData();

	pi = cArray.Add();
	*pi = 7;
	AssertInt(1, cArray.NumElements());
	AssertPointer(piEmbeddedData, cArray.GetData());

	pi = cArray.Get(0);
	AssertInt(7,* pi);

	cArray.AddNum(3);
	AssertInt(4, cArray.NumElements());
	AssertPointer(piEmbeddedData, cArray.GetData());
	*cArray.Get(1) = 6;
	*cArray.Get(2) = 5;
	*cArray.Get(3) = 4;

	pi = cArray.Add();
	*pi = 22;
	AssertInt(5, cArray.NumElements());
	AssertPointer(piEmbeddedData, cArray.GetData());
	AssertInt(7, *cArray.Get(0));
	AssertInt(22, *cArray.Get(4));

	pi = cArray.Add();
	*pi = 20;
	AssertInt(6, cArray.NumElements());
	AssertFalse(piEmbeddedData == cArray.GetData());

	AssertInt(7, *cArray.Get(0));
	AssertInt(6, *cArray.Get(1));
	AssertInt(5, *cArray.Get(2));
	AssertInt(4, *cArray.Get(3));
	AssertInt(22, *cArray.Get(4));
	AssertInt(20, *cArray.Get(5));

	AssertTrue(cArray.TestInternalConsistency());
	cArray.Kill();
}
Пример #13
0
void TestEmbeddedObjectClass(void)
{
	MemoryInit();
	ObjectsInit();

	CEmbeddedComplex	cComplex;
	CPointer*			pcPtr0;
	CPointer*			pcPtr1;
	CPointer*			pcPtr2;
	CPointer*			pcPtr3;
	CPointer*			pcPtr4;
	CPointer*			pcPtr5;

	//Class not yet called.  Always call Class.
	AssertInt(0, cComplex.GetNumFieldPointerTos());
	AssertInt(1, cComplex.GetNumEmbedded());

	cComplex.ClearFlagNumEmbedded();
	cComplex.Class();
	AssertInt(5, cComplex.GetNumFieldPointerTos());
	AssertInt(6, cComplex.GetNumEmbedded());

	pcPtr0 = cComplex.GetFieldPointerTo(0);
	pcPtr1 = cComplex.GetFieldPointerTo(1);
	pcPtr2 = cComplex.GetFieldPointerTo(2);
	pcPtr3 = cComplex.GetFieldPointerTo(3);
	pcPtr4 = cComplex.GetFieldPointerTo(4);
	pcPtr5 = cComplex.GetFieldPointerTo(5);

	AssertPointer(cComplex.mpTest.This(), pcPtr0);
	AssertPointer(cComplex.mcSimple.mpTest.This(), pcPtr1);
	AssertPointer(cComplex.mcContainer.mpTest.This(), pcPtr2);
	AssertPointer(cComplex.mcContainer.mcOne.mpTest.This(), pcPtr3);
	AssertPointer(cComplex.mcContainer.mcTwo.mpTest.This(), pcPtr4);
	AssertNull(pcPtr5);

	AssertInt(0, cComplex.GetFieldPointerToIndex(pcPtr0));
	AssertInt(1, cComplex.GetFieldPointerToIndex(pcPtr1));
	AssertInt(2, cComplex.GetFieldPointerToIndex(pcPtr2));
	AssertInt(3, cComplex.GetFieldPointerToIndex(pcPtr3));
	AssertInt(4, cComplex.GetFieldPointerToIndex(pcPtr4));
	AssertInt(-1, cComplex.GetFieldPointerToIndex(NULL));

	ObjectsKill();
	MemoryKill();
}
void TestLinkListAlignedGrow(void)
{
	CLinkListAligned	cLinkListAligned;
	int*				pi;
	void*				pvOld;
	void*				pvNew;

	cLinkListAligned.Init();
	pi = (int*)cLinkListAligned.InsertAfterTail(20, 4, 0);
	pi[0] = 0;
	pi[1] = 1;
	pi[2] = 2;
	pi[3] = 3;
	pi[4] = 4;
	
	pi = (int*)cLinkListAligned.Grow(pi, 24);
	AssertInt(0, pi[0]);
	AssertInt(1, pi[1]);
	AssertInt(2, pi[2]);
	AssertInt(3, pi[3]);
	AssertInt(4, pi[4]);

	pi[5] = 5;

	pi = (int*)cLinkListAligned.Grow(pi, 8);
	AssertInt(0, pi[0]);
	AssertInt(1, pi[1]);

	pi = (int*)cLinkListAligned.Grow(pi, 0);
	AssertNull(pi);
	cLinkListAligned.Kill();

	cLinkListAligned.Init();
	pvOld = cLinkListAligned.InsertAfterTail(1, 4, 0);
	pvNew = cLinkListAligned.Grow(pvOld, 2);
	AssertPointer(pvOld, pvNew);
	pvNew = cLinkListAligned.Grow(pvOld, 3);
	AssertPointer(pvOld, pvNew);
	pvNew = cLinkListAligned.Grow(pvOld, 3);
	AssertPointer(pvOld, pvNew);
	pvNew = cLinkListAligned.Grow(pvOld, 4);
	AssertPointer(pvOld, pvNew);
	pvNew = cLinkListAligned.Grow(pvOld, 8);
	AssertFalse(pvOld == pvNew);
	cLinkListAligned.Kill();
}
Пример #15
0
void AssertCache(CMemoryCache* pcCache, int iFirstLength, char cFirstChar, int iSecondLength, char cSecondChar)
{
	SMemoryCacheDescriptor*		psFirst;
	SMemoryCacheDescriptor*		psLast;

	AssertInt(2, pcCache->NumCached());

	psFirst = pcCache->GetFirst();
	psLast = pcCache->GetLast();
	AssertNotNull(psFirst);
	AssertFalse(psFirst == psLast);

	AssertPointer(psLast, psFirst->psNext);
	AssertPointer(psFirst, psLast->psNext);

	AssertCacheElement(pcCache, psFirst, iFirstLength, cFirstChar);
	AssertCacheElement(pcCache, psLast, iSecondLength, cSecondChar);
}
void TestArrayTemplateEmbeddedAllocationWithVirtualClass(void)
{
	CTestArrayTemplateEmbedded			ac;
	CTestOverridenArrayTemplateItem*	pc;

	ac.Init();

	pc = ac.Add();
	pc->Init(5);
	AssertInt(5, pc->i1);
	AssertInt(33, pc->i2);

	pc = ac.InsertAt(0);
	pc->Init(6);
	AssertInt(6, pc->i1);
	AssertInt(33, pc->i2);

	pc = ac.Add();
	pc->Init(7);
	AssertInt(7, pc->i1);
	AssertInt(33, pc->i2);
	AssertPointer(ac.Get(2), pc);

	pc = ac.Add();
	pc->Init(8);
	AssertInt(8, pc->i1);
	AssertInt(33, pc->i2);
	AssertPointer(ac.Get(3), pc);

	AssertInt(4, ac.NumElements());

	pc = ac.InsertAt(3);
	pc->Init(9);
	AssertInt(9, pc->i1);
	AssertInt(33, pc->i2);
	AssertPointer(ac.Get(3), pc);
	pc = ac.Get(4);
	AssertInt(8, pc->i1);
	AssertInt(33, pc->i2);

	ac.Kill();
}
Пример #17
0
void AssertCache(CMemoryCache* pcCache, int iFirstLength, char cFirstChar)
{
	SMemoryCacheDescriptor*		psFirst;
	SMemoryCacheDescriptor*		psLast;

	AssertInt(1, pcCache->NumCached());
	
	psFirst = pcCache->GetFirst();
	AssertNotNull(psFirst);
	AssertPointer(psFirst, psFirst->psNext);

	psLast = pcCache->GetLast();
	AssertPointer(psFirst, psLast);

	AssertPointer(psLast, psLast->psNext);
	
	AssertCacheElement(pcCache, psFirst, iFirstLength, cFirstChar);

	AssertLinkOrder(pcCache);
}
Пример #18
0
void AssertCache(CMemoryCache* pcCache, int iLen1, char c1, int iLen2, char c2, int iLen3, char c3)
{
	SMemoryCacheDescriptor*		psFirst;
	SMemoryCacheDescriptor*		psLast;

	AssertInt(3, pcCache->NumCached());

	psFirst = pcCache->GetFirst();
	psLast = pcCache->GetLast();
	AssertNotNull(psFirst);
	AssertFalse(psFirst == psLast);
	AssertFalse(psFirst->psNext == psLast);

	AssertPointer(psFirst->psNext->psNext, psLast);
	AssertPointer(psLast->psNext, psFirst);

	AssertCacheElement(pcCache, psFirst, iLen1, c1);
	AssertCacheElement(pcCache, psFirst->psNext, iLen2, c2);
	AssertCacheElement(pcCache, psFirst->psNext->psNext, iLen3, c3);
}
Пример #19
0
void TestObjectsObjectKillInGraph(void)
{
	Ptr<CTestNamedString>	cNS1;
	Ptr<CTestNamedString>	cNS2;
	Ptr<CRoot>				pRoot;
	Ptr<CString>			cS1;
	Ptr<CString>			cS2;
	CTestNamedString*		pcNS2;
	CString*				pcS2;

	ObjectsInit();

	pRoot = ORoot();

	cS1 = OMalloc(CString);
	cS1->Init("CS1");
	cNS1 = ONMalloc(CTestNamedString, "NS1")->Init(cS1, ONull, "NS1");

	cS2 = OMalloc(CString)->Init("CS2");
	cNS2 = ONMalloc(CTestNamedString, "NS2")->Init(cS2, cNS1, "NS2");

	pRoot->Add(cNS2);
	
	AssertPointer(cNS2->mpAnother.Object(), cNS1.Object());
	AssertLongLongInt(6, gcObjects.NumMemoryIndexes());
	pcNS2 = &cNS2;
	cNS2 = NULL;
	pRoot = NULL;
	cS1 = NULL;
	pcS2 = &cS2;
	cS2 = NULL;
	AssertLongLongInt(6, gcObjects.NumMemoryIndexes());

	cNS1->Kill();

	AssertNull(pcNS2->mpAnother.Object());
	AssertLongLongInt(4, gcObjects.NumMemoryIndexes());
	AssertPointer(pcNS2->mszString.Object(), pcS2);

	ObjectsKill();
}
void TestIndexTreeMemoryCountAllocatedNodes(void)
{
	CIndexTreeMemory	cIndex;
	CTestIndexTreeObject	cZebra;
	CTestIndexTreeObject	cAardvark;
	CTestIndexTreeObject	cAardvar;
	CTestIndexTreeObject	cAardvarc;
	CTestIndexTreeObject**	pvResult;

	cIndex.Init();

	AssertInt(1, cIndex.CountAllocatedNodes());

	cZebra.Init("Zebra");
	cAardvark.Init("Aardvark");
	cAardvar.Init("Aardvar");
	cAardvarc.Init("Aardvarc");

	cIndex.PutPtr(cZebra.GetName(), &cZebra);
	pvResult = (CTestIndexTreeObject**)cIndex.Get("Zebra");
	AssertPointer(&cZebra, *pvResult);
	AssertInt(6, cIndex.CountAllocatedNodes());

	cIndex.PutPtr(cAardvark.GetName(), &cAardvark);
	pvResult = (CTestIndexTreeObject**)cIndex.Get("Aardvark");
	AssertPointer(&cAardvark, *pvResult);
	AssertInt(14, cIndex.CountAllocatedNodes());

	cIndex.PutPtr(cAardvar.GetName(), &cAardvar);
	pvResult = (CTestIndexTreeObject**)cIndex.Get("Aardvar");
	AssertPointer(&cAardvar, *pvResult);
	AssertInt(14, cIndex.CountAllocatedNodes());

	cIndex.PutPtr(cAardvarc.GetName(), &cAardvarc);
	pvResult = (CTestIndexTreeObject**)cIndex.Get("Aardvarc");
	AssertPointer(&cAardvarc, *pvResult);
	AssertInt(15, cIndex.CountAllocatedNodes());

	cIndex.Kill();
}
void TestArrayTemplateEmbeddedRemove(void)
{
	CArrayTemplateEmbedded<int*, 2>	cArray;

	int						i1;
	int						i2;
	int						i3;

	int*					pi1;
	int*					pi2;
	int*					pi3;

	int**					ppi1;
	int**					ppi2;

	int						iIndex;

	i1 = 1;
	i2 = 2;
	i3 = 3;

	pi1 = &i1;
	pi2 = &i2;
	pi3 = &i3;

	cArray.Init();
	ppi1 = cArray.Add(&pi1);
	ppi2 = cArray.Add(&pi2);

	iIndex = cArray.GetIndex(&pi1);
	AssertInt(-1, iIndex);
	iIndex = cArray.GetIndex(ppi1);
	AssertInt(0, iIndex);
	iIndex = cArray.GetIndex(&pi2);
	AssertInt(-1, iIndex);
	iIndex = cArray.GetIndex(ppi2);
	AssertInt(1, iIndex);

	iIndex = cArray.Find(&pi1);
	AssertInt(0, iIndex);
	iIndex = cArray.Find(ppi1);
	AssertInt(0, iIndex);
	iIndex = cArray.Find(&pi2);
	AssertInt(1, iIndex);
	iIndex = cArray.Find(ppi2);
	AssertInt(1, iIndex);

	cArray.Remove(&pi1);
	iIndex = cArray.Find(&pi1);
	AssertInt(-1, iIndex);
	AssertPointer(pi2, *cArray.Get(0));
}
Пример #22
0
void TestTreeTemplateInsert(void)
{
	CTestTree				cTree;
	STestTreeTemplateItem*	pcNode0;
	STestTreeTemplateItem*	pcNode00;
	STestTreeTemplateItem*	pcNode01;
	STestTreeTemplateItem*	pcNode02;
	STestTreeTemplateItem*	pcNode000;
	STestTreeTemplateItem*	pcTest;

	cTree.Init();
	pcNode0 = cTree.InsertRoot();
	pcNode0->Init(672, 7645);

	pcNode00 = cTree.InsertOnRightOfChildren(pcNode0);
	pcNode00->Init(720, 6);

	pcNode000 = cTree.InsertOnRightOfChildren(pcNode00);
	pcNode000->Init(325, 28274);

	pcNode01 = cTree.InsertOnRightOfChildren(pcNode0);
	pcNode01->Init(8, 12);

	pcNode02 = cTree.InsertOnRightOfChildren(pcNode0);
	pcNode02->Init(99, 7);

	AssertInt(5, cTree.NumElements());
	pcTest = cTree.GetRoot();
	AssertPointer(pcNode0, pcTest);
	AssertTrue(pcTest->IsOkay(672, 7645));
	pcTest = cTree.GetUp(pcNode0);
	AssertPointer(pcNode00, pcTest);
	AssertTrue(pcTest->IsOkay(720, 6));
	pcTest = cTree.GetUp(pcNode00);
	AssertPointer(pcNode000, pcTest);
	pcTest = cTree.GetRight(pcNode00);
	AssertPointer(pcNode01, pcTest);
	pcTest = cTree.GetRight(pcNode01);
	AssertPointer(pcNode02, pcTest);
	pcTest = cTree.GetRight(pcNode02);
	AssertNull(pcTest);
	AssertNull(cTree.GetUp(pcNode01));
	AssertNull(cTree.GetUp(pcNode02));
	AssertPointer(pcNode0, cTree.GetDown(pcNode00));
	AssertPointer(pcNode0, cTree.GetDown(pcNode01));
	AssertPointer(pcNode0, cTree.GetDown(pcNode02));

	cTree.Kill();
}
Пример #23
0
void TestIndexTreeNodeFileRootMemory(void)
{
	CIndexTreeNodeFile*		pcNode;
	CIndexTreeBlockFile		cIndex;
	CIndexTreeNodeFile		cChildNode;
	CIndexTreeChildNode*	pcResult;

	cIndex.FakeInit();

	pcNode = (CIndexTreeNodeFile*)malloc(sizeof(CIndexTreeNodeFile) + sizeof(CIndexTreeChildNode));  //Node.  No object.  One child.
	pcNode->Init(&cIndex, NULL);

	AssertTrue(pcNode->IsEmpty());
	AssertFalse(pcNode->HasNodes());
	AssertFalse(pcNode->HasObject());
	AssertTrue(pcNode->ValidateNodesEmpty());

	pcNode->Contain(33);
	AssertFalse(pcNode->IsEmpty());
	AssertTrue(pcNode->HasNodes());
	AssertFalse(pcNode->HasObject());

	gcLogger.SetBreakOnError(FALSE);
	AssertFalse(pcNode->ValidateNodesEmpty());
	gcLogger.SetBreakOnError(TRUE);

	AssertInt(33, pcNode->GetFirstIndex());
	AssertInt(33, pcNode->GetLastIndex());

	pcNode->Set(33, &cChildNode);
	AssertFalse(pcNode->IsEmpty());
	AssertTrue(pcNode->HasNodes());
	AssertFalse(pcNode->HasObject());
	AssertInt(1, pcNode->NumInitialisedIndexes());
	AssertTrue(pcNode->ValidateNodesEmpty());

	pcResult = pcNode->Get(33);
	AssertTrue(pcResult->IsMemory());
	AssertPointer(&cChildNode, pcResult->u.mpcMemory);

	AssertFalse(pcNode->ContainsIndex(32));
	AssertTrue(pcNode->ContainsIndex(33));
	AssertFalse(pcNode->ContainsIndex(34));

	free(pcNode);
}
Пример #24
0
void TestEmbeddedGetEmbeddedObject(void)
{
	MemoryInit();
	ObjectsInit();

	CEmbeddedComplex	cComplex;
	CEmbeddedObject*	pcEmbedded;

	cComplex.Class();
	cComplex.Init();

	pcEmbedded = cComplex.GetEmbeddedObject(0);
	AssertPointer(&cComplex, pcEmbedded);
	pcEmbedded = cComplex.GetEmbeddedObject(1);
	AssertPointer(&cComplex.mcSimple, pcEmbedded);
	pcEmbedded = cComplex.GetEmbeddedObject(2);
	AssertPointer(&cComplex.ma, pcEmbedded);
	pcEmbedded = cComplex.GetEmbeddedObject(3);
	AssertPointer(&cComplex.mcContainer, pcEmbedded);
	pcEmbedded = cComplex.GetEmbeddedObject(4);
	AssertPointer(&cComplex.mcContainer.mcOne, pcEmbedded);
	pcEmbedded = cComplex.GetEmbeddedObject(5);
	AssertPointer(&cComplex.mcContainer.mcTwo, pcEmbedded);
	pcEmbedded = cComplex.GetEmbeddedObject(6);
	AssertNull(pcEmbedded);

	pcEmbedded = cComplex.mcSimple.GetEmbeddedObject(0);
	AssertPointer(&cComplex.mcSimple, pcEmbedded);
	pcEmbedded = cComplex.mcSimple.GetEmbeddedObject(1);
	AssertNull(pcEmbedded);

	pcEmbedded = cComplex.ma.GetEmbeddedObject(0);
	AssertPointer(&cComplex.ma, pcEmbedded);
	pcEmbedded = cComplex.ma.GetEmbeddedObject(1);
	AssertNull(pcEmbedded);

	ObjectsKill();
	MemoryKill();
}
Пример #25
0
void TestIndexesIteration(void)
{
	CIndexes			cIndexes;
	void*				pvMem;
	void*				pvTest;
	int					i;
	SIndexesIterator	sIter;

	i = 15;
	pvMem = &i;

	cIndexes.Init(512);
	cIndexes.Add(2, pvMem);
	pvTest = cIndexes.Get(2);
	AssertPointer(pvMem, pvTest);

	cIndexes.Add(255, pvMem);
	cIndexes.Add(256, pvMem);
	cIndexes.Add(260, pvMem);
	cIndexes.Add(0x0000708a9bcd5500LL, pvMem);
	cIndexes.Add(0x0000708a9bcd5501LL, pvMem);
	cIndexes.Add(0x0000708a9bcd55FFLL, pvMem);
	cIndexes.Add(0x0000720000000101LL, pvMem);
	cIndexes.Add(0x0000720000000102LL, pvMem);

	AssertLongLongInt(2, cIndexes.StartIteration(&sIter));
	AssertLongLongInt(255, cIndexes.Iterate(&sIter));

	AssertLongLongInt(256, cIndexes.Iterate(&sIter));
	AssertLongLongInt(260, cIndexes.Iterate(&sIter));

	AssertLongLongInt(0x0000708a9bcd5500LL, cIndexes.Iterate(&sIter));
	AssertLongLongInt(0x0000708a9bcd5501LL, cIndexes.Iterate(&sIter));
	AssertLongLongInt(0x0000708a9bcd55FFLL, cIndexes.Iterate(&sIter));
	AssertLongLongInt(0x0000720000000101LL, cIndexes.Iterate(&sIter));
	AssertLongLongInt(0x0000720000000102LL, cIndexes.Iterate(&sIter));

	AssertLongLongInt(INVALID_O_INDEX, cIndexes.Iterate(&sIter));

	cIndexes.Kill();
}
void TestDehollowficationFromDatabase(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();
	AssertLongLongInt(0, gcUnknowns.NumElements());
	AssertInt(0, gcObjects.GetStackPointers()->UsedPointers());

	AssertLongLongInt(0, gcObjects.NumMemoryIndexes());
	AssertLongLongInt(0, gcObjects.NumMemoryNames());
	AssertLongLongInt(11, gcObjects.NumDatabaseObjects());
	AssertLongLongInt(0, gcObjects.NumDatabaseObjectsCached());
	AssertLongLongInt(6, gcObjects.NumDatabaseNames());

	Ptr<CRoot> pRoot = ORoot();

	AssertTrue(pRoot->IsSetHollow());

	AssertLongLongInt(2, gcUnknowns.NumElements());
	AssertLongLongInt(2, gcObjects.NumMemoryIndexes());
	AssertLongLongInt(1, gcObjects.NumMemoryNames());
	AssertLongLongInt(1, gcObjects.NumDatabaseObjectsCached());
	AssertLongLongInt(6, gcObjects.NumDatabaseNames());
	AssertInt(1, gcObjects.GetStackPointers()->UsedPointers());

	Ptr<CTestDoubleNamedString> pTest = pRoot->Get<CTestDoubleNamedString>("Double Start");  //This will cause pRoot.Set to be dehollowed.
	AssertInt(2, gcObjects.GetStackPointers()->UsedPointers());
	AssertFalse(pRoot->IsSetHollow());
	AssertTrue(pTest.IsNotNull());
	AssertTrue(pTest.IsHollow());
	AssertLongLongInt(10, pTest.GetIndex());
	AssertLongLongInt(4, gcUnknowns.NumElements());
	AssertLongLongInt(4, gcObjects.NumMemoryIndexes());
	
	AssertString("12345", pTest->mpSplit1->mszEmbedded.Text()); //This will cause pTest and pTest.Split1 to be dehollowed.
	AssertLongLongInt(9, gcUnknowns.NumElements());
	AssertLongLongInt(9, gcObjects.NumMemoryIndexes());
	AssertFalse(pTest.IsHollow());
	AssertLongLongInt(10, pTest.GetIndex());
	AssertInt(2, gcObjects.GetStackPointers()->UsedPointers());
	AssertTrue(pTest->mpSplit1->mpAnother.IsHollow());
	AssertTrue(pTest->mpSplit2.IsHollow());
	AssertTrue(pTest->mpSplit1->mszString.IsHollow());
	AssertString("Diamond End", pTest->mpSplit1->mpAnother.GetName());
	AssertString("6789", pTest->mpSplit1->mszString->Text());
	AssertFalse(pTest->mpSplit1->mszString.IsHollow());

	AssertInt(2, gcObjects.GetStackPointers()->UsedPointers());

	Ptr<CTestNamedString> pDiamond = pTest->mpSplit1->mpAnother;
	AssertLongLongInt(9, gcUnknowns.NumElements());
	AssertLongLongInt(9, gcObjects.NumMemoryIndexes());
	AssertInt(3, gcObjects.GetStackPointers()->UsedPointers());
	AssertTrue(pTest->mpSplit1->mpAnother.IsHollow());
	AssertTrue(pDiamond.IsHollow());

	pDiamond->ClassName(); //This will cause pDiamond to be de-hollowed

	AssertFalse(pDiamond.IsHollow());
	AssertFalse(pTest->mpSplit1->mpAnother.IsHollow());

	AssertLongLongInt(10, gcUnknowns.NumElements());
	AssertLongLongInt(10, gcObjects.NumMemoryIndexes());
	AssertLongLongInt(6, gcObjects.NumMemoryNames());
	AssertLongLongInt(3, gcObjects.NumDatabaseObjectsCached());
	AssertLongLongInt(6, gcObjects.NumDatabaseNames());

	AssertTrue(pTest->mpSplit2.IsHollow());
	pTest->mpSplit2->ClassSize();
	AssertFalse(pTest->mpSplit2.IsHollow());
	AssertFalse(pTest->mpSplit2->mpAnother.IsHollow());
	AssertPointer(pDiamond.Object(), pTest->mpSplit2->mpAnother.Object());

	AssertLongLongInt(11, gcObjects.NumMemoryIndexes());
	AssertLongLongInt(6, gcObjects.NumMemoryNames());
	AssertLongLongInt(2, gcObjects.NumDatabaseObjectsCached());
	AssertLongLongInt(6, gcObjects.NumDatabaseNames());

	Ptr<CTestNamedString> pRandom = pRoot->Get<CTestNamedString>("NamedString 3");
	AssertTrue(pRandom.IsNotNull());
	AssertTrue(pRandom.IsHollow());

	AssertTrue(pRandom->mszString.IsHollow());
	AssertFalse(pRandom.IsHollow());
	AssertTrue(pTest->mpSplit2->mszString.IsHollow());

	AssertString("World", pRandom->mszString->Text());
	AssertFalse(pRandom->mszString.IsHollow());
	AssertFalse(pTest->mpSplit2->mszString.IsHollow());
	AssertPointer(pRandom->mszString.Object(), pTest->mpSplit2->mszString.Object());

	AssertLongLongInt(11, gcObjects.NumDatabaseObjects());

	ObjectsKill();

	AssertTrue(pRoot.IsNull());
	AssertTrue(pTest.IsNull());
	AssertTrue(pDiamond.IsNull());
	AssertTrue(pRandom.IsNull());

	pDiamond.UnsafeClearObject();

	MemoryKill();
}
void TestIndexTreeMemoryValidateInternalConsistency(void)
{
	CIndexTreeMemory		cIndex;
	CTestIndexTreeObject	cObject;
	CTestIndexTreeObject	cType;
	CArrayVoidPtr			avp;

	cIndex.Init();

	cObject.Init("");

	cIndex.PutPtr("tonic", &cObject);
	cIndex.PutPtr("topia", &cObject);
	cIndex.PutPtr("topic", &cObject);
	cIndex.PutPtr("totem", &cObject);
	cIndex.PutPtr("tower", &cObject);
	cIndex.PutPtr("tracter", &cObject);
	cIndex.PutPtr("traction", &cObject);
	cIndex.PutPtr("trahend", &cObject);
	cIndex.PutPtr("translucence", &cObject);
	cIndex.PutPtr("translucency", &cObject);
	cIndex.PutPtr("transparentness", &cObject);
	cIndex.PutPtr("tread", &cObject);
	cIndex.PutPtr("treasurer", &cObject);
	cIndex.PutPtr("treasurership", &cObject);
	cIndex.PutPtr("treasury", &cObject);
	cIndex.PutPtr("trench", &cObject);
	cIndex.PutPtr("triangularity", &cObject);
	cIndex.PutPtr("tribe", &cObject);
	cIndex.PutPtr("triplication", &cObject);
	cIndex.PutPtr("truncation", &cObject);
	cIndex.PutPtr("trunk", &cObject);
	cIndex.PutPtr("tunic", &cObject);
	cIndex.PutPtr("tunnel", &cObject);
	cIndex.PutPtr("tutor", &cObject);
	cIndex.PutPtr("tutorship", &cObject);

	AssertPointer(&cObject, *(CTestIndexTreeObject**)cIndex.Get("tonic"));
	AssertPointer(&cObject, *(CTestIndexTreeObject**)cIndex.Get("topia"));
	AssertPointer(&cObject, *(CTestIndexTreeObject**)cIndex.Get("topic"));
	AssertPointer(&cObject, *(CTestIndexTreeObject**)cIndex.Get("totem"));
	AssertPointer(&cObject, *(CTestIndexTreeObject**)cIndex.Get("tower"));
	AssertPointer(&cObject, *(CTestIndexTreeObject**)cIndex.Get("tracter"));
	AssertPointer(&cObject, *(CTestIndexTreeObject**)cIndex.Get("traction"));
	AssertPointer(&cObject, *(CTestIndexTreeObject**)cIndex.Get("trahend"));
	AssertPointer(&cObject, *(CTestIndexTreeObject**)cIndex.Get("translucence"));
	AssertPointer(&cObject, *(CTestIndexTreeObject**)cIndex.Get("translucency"));
	AssertPointer(&cObject, *(CTestIndexTreeObject**)cIndex.Get("transparentness"));
	AssertPointer(&cObject, *(CTestIndexTreeObject**)cIndex.Get("tread"));
	AssertPointer(&cObject, *(CTestIndexTreeObject**)cIndex.Get("treasurer"));
	AssertPointer(&cObject, *(CTestIndexTreeObject**)cIndex.Get("treasurership"));
	AssertPointer(&cObject, *(CTestIndexTreeObject**)cIndex.Get("treasury"));
	AssertPointer(&cObject, *(CTestIndexTreeObject**)cIndex.Get("trench"));
	AssertPointer(&cObject, *(CTestIndexTreeObject**)cIndex.Get("triangularity"));
	AssertPointer(&cObject, *(CTestIndexTreeObject**)cIndex.Get("tribe"));
	AssertPointer(&cObject, *(CTestIndexTreeObject**)cIndex.Get("triplication"));
	AssertPointer(&cObject, *(CTestIndexTreeObject**)cIndex.Get("truncation"));
	AssertPointer(&cObject, *(CTestIndexTreeObject**)cIndex.Get("trunk"));
	AssertPointer(&cObject, *(CTestIndexTreeObject**)cIndex.Get("tunic"));
	AssertPointer(&cObject, *(CTestIndexTreeObject**)cIndex.Get("tunnel"));
	AssertPointer(&cObject, *(CTestIndexTreeObject**)cIndex.Get("tutor"));
	AssertPointer(&cObject, *(CTestIndexTreeObject**)cIndex.Get("tutorship"));

	cType.Init("type");
	cIndex.PutPtr(cType.GetName(), &cType);

	AssertPointer(&cType, *(CTestIndexTreeObject**)cIndex.Get("type"));

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

	cIndex.Kill();
}
void TestArrayTemplateEmbeddedRemoveAt(void)
{
	CArrayTemplateEmbedded<int, 5>	cArray;
	int*					piEmbeddedData;
	int*					pi;
	int						i;

	cArray.Init();
	piEmbeddedData = cArray.GetData();
	cArray.AddNum(6);
	AssertFalse(piEmbeddedData == cArray.GetData());
	AssertInt(6, cArray.NumElements());

	*cArray.Get(0) = 7;
	*cArray.Get(1) = 6;
	*cArray.Get(2) = 5;
	*cArray.Get(3) = 4;
	*cArray.Get(4) = 22;
	*cArray.Get(5) = 20;

	AssertInt(7, *cArray.Get(0));
	AssertInt(6, *cArray.Get(1));
	AssertInt(5, *cArray.Get(2));
	AssertInt(4, *cArray.Get(3));
	AssertInt(22, *cArray.Get(4));
	AssertInt(20, *cArray.Get(5));
	
	cArray.Resize(5);
	AssertPointer(piEmbeddedData, cArray.GetData());
	AssertInt(5, cArray.NumElements());

	AssertInt(7, *cArray.Get(0));
	AssertInt(6, *cArray.Get(1));
	AssertInt(5, *cArray.Get(2));
	AssertInt(4, *cArray.Get(3));
	AssertInt(22, *cArray.Get(4));

	pi = cArray.Add();
	*pi = 20;
	AssertInt(6, cArray.NumElements());
	AssertFalse(piEmbeddedData == cArray.GetData());

	cArray.RemoveAt(2);
	AssertPointer(piEmbeddedData, cArray.GetData());
	AssertInt(5, cArray.NumElements());

	AssertInt(7, *cArray.Get(0));
	AssertInt(6, *cArray.Get(1));
	AssertInt(4, *cArray.Get(2));
	AssertInt(22, *cArray.Get(3));
	AssertInt(20, *cArray.Get(4));

	cArray.RemoveAt(3);
	AssertPointer(piEmbeddedData, cArray.GetData());
	AssertInt(4, cArray.NumElements());

	AssertInt(7, *cArray.Get(0));
	AssertInt(6, *cArray.Get(1));
	AssertInt(4, *cArray.Get(2));
	AssertInt(20, *cArray.Get(3));

	i = 8;
	cArray.InsertAt(&i, 4);
	AssertInt(5, cArray.NumElements());
	AssertInt(8, *cArray.Get(4));

	i = 9;
	cArray.InsertAt(&i, 5);
	AssertFalse(piEmbeddedData == cArray.GetData());
	AssertInt(6, cArray.NumElements());
	AssertInt(8, *cArray.Get(4));
	AssertInt(9, *cArray.Get(5));

	cArray.RemoveAt(5);
	AssertPointer(piEmbeddedData, cArray.GetData());
	AssertInt(5, cArray.NumElements());

	AssertInt(7, *cArray.Get(0));
	AssertInt(6, *cArray.Get(1));
	AssertInt(4, *cArray.Get(2));
	AssertInt(20, *cArray.Get(3));
	AssertInt(8, *cArray.Get(4));
}
void TestIndexTreeMemoryRemoveOnRoot(void)
{
	CIndexTreeMemory		cIndex;
	int						i;
	unsigned char			cKey;
	int						iData;
	CIndexTreeNodeMemory*	pcRoot;
	CIndexTreeNodeMemory*	pcOldRoot;
	CArrayVoidPtr			avp;

	cIndex.Init();
	pcOldRoot = cIndex.GetRoot();
	pcRoot = pcOldRoot;

	AssertInt(0, pcRoot->GetFirstIndex());
	AssertInt(255, pcRoot->GetLastIndex());
	AssertInt(256, pcRoot->NumIndexes());
	AssertInt(0, pcRoot->NumValidIndexes());
	AssertInt(0, cIndex.NumElements());
	AssertPointer(pcOldRoot, pcRoot);
	AssertInt(1, cIndex.CountAllocatedNodes());

	for (i = 0; i <= UCHAR_MAX; i++)
	{
		cKey = (unsigned char)i;
		memset(&iData, cKey, sizeof(int));
		cIndex.Put(&cKey, 1, &iData, sizeof(int));

		pcRoot = cIndex.GetRoot();
		AssertPointer(pcOldRoot, pcRoot);

		AssertInt(0, pcRoot->GetFirstIndex());
		AssertInt(255, pcRoot->GetLastIndex());
		AssertInt(256, pcRoot->NumIndexes());
		AssertInt(i + 1, pcRoot->NumValidIndexes());
		AssertInt(i + 1, cIndex.NumElements());
		AssertInt(i + 2, cIndex.CountAllocatedNodes());
	}
	AssertInt(256, cIndex.NumElements());

	for (i = 0; i <= UCHAR_MAX; i++)
	{
		cKey = (unsigned char)(i / 2);
		if (i % 2 == 1)
		{
			cKey = 255 - cKey;
		}
		cIndex.Remove(&cKey, 1);

		pcRoot = cIndex.GetRoot();
		AssertPointer(pcOldRoot, pcRoot);

		AssertInt(0, pcRoot->GetFirstIndex());
		AssertInt(255, pcRoot->GetLastIndex());
		AssertInt(256, pcRoot->NumIndexes());
		AssertInt(255 - i, pcRoot->NumValidIndexes());
		AssertInt(255 - i, cIndex.NumElements());
		AssertInt(256 - i, cIndex.CountAllocatedNodes());

		avp.Init();
		cIndex.FindAll(&avp);
		AssertInt(255 - i, avp.NumElements());
		avp.Kill();
	}

	cIndex.Kill();
}
void TestContiguousExternalChannels(void)
{
	CChannels			cChannels;
	CChannels			cExternalChannel;
	int					vSourse;
	int					iExpected0;
	int					iExpected1;
	int					iExpected2;
	int					iExpected3;

	TypeConverterInit();
	ClassStorageInit();
	UnknownsInit();

	//Rows      3 2 1 0
	vSourse = 0xFF00aa55;

	cExternalChannel.Init();
	cExternalChannel.BeginChange();
	cExternalChannel.AddChannel(3, PT_nybble);
	cExternalChannel.AddChannel(2, PT_bit);
	cExternalChannel.AddChannel(1, PT_bit);
	cExternalChannel.AddChannel(0, PT_crumb);
	cExternalChannel.SetData((char*)&vSourse);
	cExternalChannel.SetSize(4);
	cExternalChannel.EndChange();
	AssertInt(4, cExternalChannel.GetSize());

	cChannels.Init();
	cChannels.BeginChange();
	cChannels.AddChannel(3, PT_uchar);
	cChannels.AddChannel(2, PT_uchar);
	cChannels.AddChannel(1, PT_uchar);
	cChannels.AddChannel(0, PT_uchar);
	cChannels.SetSize(4);
	cChannels.EndChange();
	AssertInt(4, cChannels.GetSize());

	CChannelsCopier cCopy;

	cCopy.Init(&cExternalChannel, &cChannels);

	cCopy.Copy(0, 0, 4);

	iExpected0 = 0x5500ff55;
	iExpected1 = 0xaaff00aa;
	iExpected2 = 0x00000000;
	iExpected3 = 0xFFffffff;
	AssertPointer((void*)(size_t)iExpected0, (void*)(size_t)((int*)cChannels.GetData())[0]);
	AssertPointer((void*)(size_t)iExpected1, (void*)(size_t)((int*)cChannels.GetData())[1]);
	AssertPointer((void*)(size_t)iExpected2, (void*)(size_t)((int*)cChannels.GetData())[2]);
	AssertPointer((void*)(size_t)iExpected3, (void*)(size_t)((int*)cChannels.GetData())[3]);

	cCopy.Kill();
	cChannels.Kill();
	cExternalChannel.Kill();

	UnknownsKill();
	ClassStorageKill();
	TypeConverterKill();
}