void TestMapStringUnknownPut(void)
{
    MemoryInit();
    UnknownsInit();

    CMapStringUnknown	cMap;
    CTestUnknownJobbie*	pcTest;

    cMap.Init();

    AssertInt(0, cMap.NumElements());

    pcTest = cMap.Put<CTestUnknownJobbie>("Hello");
    pcTest->Init(7, "1st");
    AssertInt(1, cMap.NumElements());

    pcTest = cMap.Put<CTestUnknownJobbie>("World");
    pcTest->Init(19, "A pony");
    AssertInt(2, cMap.NumElements());

    pcTest = cMap.Put<CTestUnknownJobbie>("Aardvark");
    pcTest->Init(4, "Restore");
    AssertInt(3, cMap.NumElements());

    pcTest = cMap.Put<CTestUnknownJobbie>(NULL);
    AssertNull(pcTest);
    AssertInt(3, cMap.NumElements());

    cMap.Kill();

    UnknownsKill();
    MemoryKill();
}
void TestMapStringUnknownNoOverwrite(void)
{
    MemoryInit();
    UnknownsInit();

    CMapStringUnknown	cMap;
    CTestUnknownJobbie*	pcTest;

    cMap.Init(TRUE, FALSE);

    AssertInt(0, gcUnknowns.NumElements());

    pcTest = cMap.Put<CTestUnknownJobbie>("One");
    pcTest->Init(2, "");
    AssertNotNull(pcTest);
    AssertInt(1, gcUnknowns.NumElements());

    pcTest = cMap.Put<CTestUnknownJobbie>("One");
    AssertNull(pcTest);
    AssertInt(1, gcUnknowns.NumElements());

    cMap.Kill();

    AssertInt(0, gcUnknowns.NumElements());

    UnknownsKill();
    MemoryKill();
}
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 ObjectsKill(void)
{
	gcObjects.Kill();
	gcStackPointers.ClearAllPointers();
	gcStackPointers.Kill();
	UnknownsKill();
}
void TestSingleChannelAccessor(void)
{
	BeginTests();
	ClassStorageInit();
	TypeConverterInit();
	UnknownsInit();

	
	CChannels					cChannels;
	unsigned char				cData[9] = "ti@YA,\n#";
	CSingleChannelAccessor		cSingle;
	char						c;
	unsigned					s;

	cChannels.Init();
	cChannels.BeginChange();
	cChannels.SetData(cData);
	cChannels.AddChannel(16, 15, 14, 13, PT_nybble);
	cChannels.AddChannel(12, 11, PT_uchar);
	cChannels.AddChannel(10, PT_ushort);
	cChannels.AddChannel(9, 8, 7, 6, PT_bit);
	cChannels.AddChannel(5, 4, PT_crumb);
	cChannels.AddChannel(3, PT_uchar);
	cChannels.SetSize(1);
	cChannels.EndChange();
	cSingle.Init(&cChannels);
	AssertFloat(0.27f, cSingle.GetConvertToFloat(16), 2);
	AssertFloat(0.47f, cSingle.GetConvertToFloat(15), 2);
	AssertFloat(0.60f, cSingle.GetConvertToFloat(14), 2);
	AssertFloat(0.40f, cSingle.GetConvertToFloat(13), 2);
	cSingle.GetNative(16, &c); AssertChar(4, c);
	cSingle.GetNative(15, &c); AssertChar(7, c);
	cSingle.GetNative(14, &c); AssertChar(9, c);
	cSingle.GetNative(13, &c); AssertChar(6, c);

	AssertFloat(0.25f, cSingle.GetConvertToFloat(12), 2);
	AssertFloat(0.35f, cSingle.GetConvertToFloat(11), 2);
	cSingle.GetNative(12, &c); AssertChar('@', c);
	cSingle.GetNative(11, &c); AssertChar('Y', c);

	cSingle.GetNative(10, &s); AssertShortHex(0x2c41, s);

	AssertFloat(0.0f, cSingle.GetConvertToFloat(9), 1);
	AssertFloat(1.0f, cSingle.GetConvertToFloat(8), 1);
	AssertFloat(0.0f, cSingle.GetConvertToFloat(7), 1);
	AssertFloat(1.0f, cSingle.GetConvertToFloat(6), 1);

	AssertFloat(0.14f, cSingle.GetConvertToFloat(3), 2);
	cSingle.GetNative(3, &c); AssertChar('#', c);

	cChannels.Kill();


	UnknownsKill();
	TypeConverterKill();
	ClassStorageKill();
	TestStatistics();
}
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();
}
Exemple #7
0
int main(int argc, _TCHAR* argv[])
{
	CFileUtil		cFileUtil;

	InitTotalStatistics();

	FastFunctionsInit();
	TypesInit();
	TypeConverterInit();
	UnknownsInit();

	cFileUtil.MakeDir("Output");

	TestImage();
	TestImageColour();
	TestImageImport();
	TestImageReader();
	TestImageWriter();
	TestImageGreyToRGB();
	TestImageRGBToGrey();
	TestImageDivider();
	TestBumpMapper();
	TestPlainTextEditor();
	TestImageCel();
	TestRectangleBestPacker();
	TestRectanglePow2Packer();
	TestImageModifierStack();
	TestImageDrawBox();
	TestImageRecolour();
	TestImageSwizzle();
	TestImageCombiner();
	//TestWinText();
	//TestImageCelsSource();
	//TestHalfSpace();
	//TestPolygon();
	//TestSphereShape();
	//TestTriangleShape();
	//TestMeshFaceReturn();
	//TestMeshPolygons();
	//TestMeshShapes();
	//TestMeshConnectivity();
	//TestNormalGeneration();
	//TestMeshOBJReader();

	cFileUtil.RemoveDir("Output");

	UnknownsKill();
	TypeConverterKill();
	TypesKill();
	FastFunctionsKill();
	return TestTotalStatistics();
}
void TestChannelsAccessor(void)
{
	BeginTests();
	MemoryInit();
	TypesInit();
	TypeConverterInit();
	UnknownsInit();

	TestChannelsAccessorContiguous();
	TestChannelsAccessorByteAligned();
	TestChannelsAccessorTypeConvert();
	TestChannelsAccessorChannelBitty();
	TestChannelsAccessorAccessBitty();
	TestChannelsAccessorWorstCase();

	UnknownsKill();
	TypeConverterKill();
	TypesKill();
	MemoryKill();
	TestStatistics();
}
void TestExternalChannelsSubBytePositions(void)
{
	CChannelsAccessor*			pcChannel0;
	CChannelsAccessor*			pcChannel1;
	CChannelsAccessorCreator	cCreator;
	CChannels					cSourceChannels;
	unsigned char				uc[11] = {0x29, 0x33, 0xBE, 0x84, 0xE1, 0x6C, 0xD6, 0xAE, 0x52, 0xE8, 0x01};
	unsigned char*				pucData;
//   MSb                                                                                           LSb
// X 1 11101000 0 10100101 0 10111011 0 10110011 0 11001110 0 00110000 1 00101111 1 00011001 1 00101001
// ^         ^          ^          ^          ^          ^          ^          ^          ^          ^
// 8 8 77777777 7 76666666 6 66555555 5 55544444 4 44443333 3 33333222 2 22222211 1 11111110 0 00000000
// 1 0 98765432 1 09876543 2 10987654 3 21098765 4 32109876 5 43210987 6 54321098 7 65432109 8 76543210

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

	cSourceChannels.Init();
	cSourceChannels.BeginChange();
	cSourceChannels.AddChannel(0, PT_uchar);
	cSourceChannels.AddChannel(1, PT_bit);
	cSourceChannels.SetData((char*)uc);
	cSourceChannels.SetSize(9);
	cSourceChannels.EndChange();

	cCreator.Init(&cSourceChannels);
	cCreator.AddAccess(0, PT_uchar);
	pcChannel0 = cCreator.CreateAndKill();
	AssertString("CChannelsAccessorChannelBitty", pcChannel0->ClassName());

	cCreator.Init(&cSourceChannels);
	cCreator.AddAccess(1, PT_uchar);
	pcChannel1 = cCreator.CreateAndKill();
	AssertString("CChannelsAccessorChannelBitty", pcChannel1->ClassName());

	pucData = (unsigned char*)pcChannel0->Get(0);
	AssertInt(0x29, *pucData);

	
	pucData = (unsigned char*)pcChannel1->Get(0);
	AssertInt(0xFF, *pucData);  //LSb of the right hand 3 in 0x33 scaled up to a byte from a bit.

	pucData = (unsigned char*)pcChannel0->Get(1);
	AssertInt(0x19, *pucData);
	pucData = (unsigned char*)pcChannel1->Get(1);
	AssertInt(0xFF, *pucData);

	pucData = (unsigned char*)pcChannel0->Get(2);
	AssertInt(0x2F, *pucData);
	pucData = (unsigned char*)pcChannel1->Get(2);
	AssertInt(0xFF, *pucData);

	pucData = (unsigned char*)pcChannel0->Get(3);
	AssertInt(0x30, *pucData);
	
	pucData = (unsigned char*)pcChannel1->Get(3);
	AssertInt(0x00, *pucData);

	pucData = (unsigned char*)pcChannel0->Get(4);
	AssertInt(0xCE, *pucData);
	pucData = (unsigned char*)pcChannel1->Get(4);
	AssertInt(0x00, *pucData);

	pucData = (unsigned char*)pcChannel0->Get(5);
	AssertInt(0xB3, *pucData);
	pucData = (unsigned char*)pcChannel1->Get(5);
	AssertInt(0x00, *pucData);

	pucData = (unsigned char*)pcChannel0->Get(6);
	AssertInt(0xBB, *pucData);
	pucData = (unsigned char*)pcChannel1->Get(6);
	AssertInt(0x00, *pucData);

	pucData = (unsigned char*)pcChannel0->Get(7);
	AssertInt(0xA5, *pucData);
	pucData = (unsigned char*)pcChannel1->Get(7);
	AssertInt(0x00, *pucData);

	pucData = (unsigned char*)pcChannel0->Get(8);
	AssertInt(0xE8, *pucData);
	pucData = (unsigned char*)pcChannel1->Get(8);
	AssertInt(0xFF, *pucData);

	cSourceChannels.Kill();

	UnknownsKill();
	ClassStorageKill();
	TypeConverterKill();
}
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();
}
Exemple #11
0
void TestSetRemoval(void)
{
	MemoryInit();
	UnknownsInit();

	CSetUnknown								cSet;
	CTestNamedUnknown*						pcTest1;
	CTestNamedUnknown*						pcTest2;
	CTestNamedUnknown*						pcTest3;
	int										iNum;
	CTestNamedUnknown*						pcTest;
	SIteratorTemplate<CTestNamedUnknown>	sIter;
	SSetIterator							sSetIter;

	cSet.Init();

	pcTest1 = cSet.Add<CTestNamedUnknown>();
	pcTest1->Init("The One");

	pcTest2 = cSet.Add<CTestNamedUnknown>();
	pcTest2->Init("Two");

	pcTest3 = UMalloc(CTestNamedUnknown);
	pcTest3->Init("There can be only three");
	cSet.Add(pcTest3);

	iNum = cSet.NumElements();
	AssertInt(3, iNum);

	cSet.StartIteration(&sSetIter);
	cSet.RemoveDuringIteration(&sSetIter);
	cSet.RemoveDuringIteration(&sSetIter);
	cSet.RemoveDuringIteration(&sSetIter);

	iNum = cSet.NumElements();
	AssertInt(0, iNum);

	cSet.RemoveDuringIteration(&sSetIter);

	pcTest = gcUnknowns.StartIteration(&sIter);
	AssertNull(pcTest);

	cSet.Kill();

	cSet.Init();

	pcTest1 = cSet.Add<CTestNamedUnknown>();
	pcTest1->Init("The One");

	pcTest2 = cSet.Add<CTestNamedUnknown>();
	pcTest2->Init("Two");

	pcTest3 = UMalloc(CTestNamedUnknown);
	pcTest3->Init("There can be only three");
	cSet.Add(pcTest3);

	iNum = cSet.NumElements();
	AssertInt(3, iNum);

	pcTest = (CTestNamedUnknown*)cSet.StartIteration(&sSetIter);
	AssertString("The One", pcTest->GetName());

	cSet.RemoveDuringIteration(&sSetIter);
	pcTest = (CTestNamedUnknown*)cSet.Iterate(&sSetIter);
	AssertString("Two", pcTest->GetName());

	cSet.RemoveDuringIteration(&sSetIter);
	iNum = cSet.NumElements();
	AssertInt(1, iNum);
	pcTest = (CTestNamedUnknown*)cSet.Iterate(&sSetIter);
	AssertString("There can be only three", pcTest->GetName());

	cSet.RemoveDuringIteration(&sSetIter);
	iNum = cSet.NumElements();
	AssertInt(0, iNum);

	cSet.RemoveDuringIteration(&sSetIter);
	cSet.Kill();

	UnknownsKill();
	MemoryKill();
}
Exemple #12
0
void TestCleanNulls(void)
{
	MemoryInit();
	UnknownsInit();

	CSetUnknown			cSet;
	CTestNamedUnknown*	apUnknowns[32];
	CChars				sz;
	int					i;
	SSetIterator		sSetIter;
	BOOL				bResult;

	cSet.Init(4);

	for (int i = 0; i < 32; i++)
	{
		apUnknowns[i] = cSet.Add<CTestNamedUnknown>();
		sz.Init();
		sz.Append(i);
		apUnknowns[i]->Init(sz.Text());
		sz.Kill();
	}

	AssertInt(32, cSet.NumElements());
	AssertInt(32, cSet.UnsafeNumElements());

	cSet.Remove(apUnknowns[0]);
	cSet.Remove(apUnknowns[2]);
	cSet.Remove(apUnknowns[3]);
	cSet.Remove(apUnknowns[7]);

	cSet.Remove(apUnknowns[17]);
	cSet.Remove(apUnknowns[18]);
	cSet.Remove(apUnknowns[19]);
	cSet.Remove(apUnknowns[23]);

	cSet.Remove(apUnknowns[26]);
	cSet.Remove(apUnknowns[27]);
	cSet.Remove(apUnknowns[28]);

	AssertInt(21, cSet.NumElements());
	AssertInt(32, cSet.UnsafeNumElements());
	
	AssertPointer(NULL,          cSet.UnsafeGet(0));
	AssertPointer(apUnknowns[1], cSet.UnsafeGet(1));
	AssertPointer(NULL,          cSet.UnsafeGet(2));
	AssertPointer(NULL,          cSet.UnsafeGet(3));
	AssertPointer(apUnknowns[4], cSet.UnsafeGet(4));
	AssertPointer(apUnknowns[5], cSet.UnsafeGet(5));
	AssertPointer(apUnknowns[6], cSet.UnsafeGet(6));
	AssertPointer(NULL,          cSet.UnsafeGet(7));
	AssertPointer(apUnknowns[8], cSet.UnsafeGet(8));
	AssertPointer(apUnknowns[9], cSet.UnsafeGet(9));
	AssertPointer(apUnknowns[10], cSet.UnsafeGet(10));
	AssertPointer(apUnknowns[11], cSet.UnsafeGet(11));
	AssertPointer(apUnknowns[12], cSet.UnsafeGet(12));
	AssertPointer(apUnknowns[13], cSet.UnsafeGet(13));
	AssertPointer(apUnknowns[14], cSet.UnsafeGet(14));
	AssertPointer(apUnknowns[15], cSet.UnsafeGet(15));
	AssertPointer(apUnknowns[16], cSet.UnsafeGet(16));
	AssertPointer(NULL,           cSet.UnsafeGet(17));
	AssertPointer(NULL,           cSet.UnsafeGet(18));
	AssertPointer(NULL,           cSet.UnsafeGet(19));
	AssertPointer(apUnknowns[20], cSet.UnsafeGet(20));
	AssertPointer(apUnknowns[21], cSet.UnsafeGet(21));
	AssertPointer(apUnknowns[22], cSet.UnsafeGet(22));
	AssertPointer(NULL,           cSet.UnsafeGet(23));
	AssertPointer(apUnknowns[24], cSet.UnsafeGet(24));
	AssertPointer(apUnknowns[25], cSet.UnsafeGet(25));
	AssertPointer(NULL,           cSet.UnsafeGet(26));
	AssertPointer(NULL,           cSet.UnsafeGet(27));
	AssertPointer(NULL,           cSet.UnsafeGet(28));
	AssertPointer(apUnknowns[29], cSet.UnsafeGet(29));
	AssertPointer(apUnknowns[30], cSet.UnsafeGet(30));
	AssertPointer(apUnknowns[31], cSet.UnsafeGet(31));

	//CleanNullsIfNecessary happens here.
	cSet.Remove(apUnknowns[29]);
	AssertInt(20, cSet.NumElements());
	AssertInt(20, cSet.UnsafeNumElements());

	AssertPointer(apUnknowns[1], cSet.UnsafeGet(0));
	AssertPointer(apUnknowns[4], cSet.UnsafeGet(1));
	AssertPointer(apUnknowns[5], cSet.UnsafeGet(2));
	AssertPointer(apUnknowns[6], cSet.UnsafeGet(3));
	AssertPointer(apUnknowns[8], cSet.UnsafeGet(4));
	AssertPointer(apUnknowns[9], cSet.UnsafeGet(5));
	AssertPointer(apUnknowns[10], cSet.UnsafeGet(6));
	AssertPointer(apUnknowns[11], cSet.UnsafeGet(7));
	AssertPointer(apUnknowns[12], cSet.UnsafeGet(8));
	AssertPointer(apUnknowns[13], cSet.UnsafeGet(9));
	AssertPointer(apUnknowns[14], cSet.UnsafeGet(10));
	AssertPointer(apUnknowns[15], cSet.UnsafeGet(11));
	AssertPointer(apUnknowns[16], cSet.UnsafeGet(12));
	AssertPointer(apUnknowns[20], cSet.UnsafeGet(13));
	AssertPointer(apUnknowns[21], cSet.UnsafeGet(14));
	AssertPointer(apUnknowns[22], cSet.UnsafeGet(15));
	AssertPointer(apUnknowns[24], cSet.UnsafeGet(16));
	AssertPointer(apUnknowns[25], cSet.UnsafeGet(17));
	AssertPointer(apUnknowns[30], cSet.UnsafeGet(18));
	AssertPointer(apUnknowns[31], cSet.UnsafeGet(19));

	cSet.StartIteration(&sSetIter);
	for (i = 0; i < 19; i++)
	{
		cSet.RemoveDuringIteration(&sSetIter);
	}

	AssertInt(1, cSet.NumElements());

	bResult = cSet.Remove(apUnknowns[31]);
	AssertTrue(bResult);

	AssertInt(0, cSet.NumElements());

	cSet.Kill();

	UnknownsKill();
	MemoryKill();
}
void TestMapStringUnknownGet(void)
{
    MemoryInit();
    UnknownsInit();

    CMapStringUnknown	cMap;
    CTestUnknownJobbie*	pcTest;
    CTestUnknownJobbie*	pcA1;
    CTestUnknownJobbie*	pcA2;
    CTestUnknownJobbie*	pcA3;

    cMap.Init();

    pcTest = cMap.Put<CTestUnknownJobbie>("Hello");
    pcTest->Init(7, "1st");
    pcTest = cMap.Put<CTestUnknownJobbie>("World");
    pcTest->Init(19, "A pony");
    pcTest = cMap.Put<CTestUnknownJobbie>("Aardvark");
    pcTest->Init(4, "Restore");
    AssertInt(3, cMap.NumElements());

    pcTest = (CTestUnknownJobbie*)cMap.Get("World");
    AssertInt(19, pcTest->miANumber);
    AssertString("A pony", pcTest->mszText.Text());

    pcA1 = UMalloc(CTestUnknownJobbie);
    pcA1->Init(999, "Grand");
    cMap.Put("Thesaurus", pcA1);
    pcA2 = UMalloc(CTestUnknownJobbie);
    pcA2->Init(17, "Replaced!");
    cMap.Put("World", pcA2);
    pcA3 = UMalloc(CTestUnknownJobbie);
    pcA3->Init(32, "Another");
    cMap.Put("Jump", pcA3);

    AssertInt(5, cMap.NumElements());
    AssertInt(5, gcUnknowns.NumElements());

    pcTest = (CTestUnknownJobbie*)cMap.Get("World");
    AssertPointer(pcA2, pcTest);
    AssertString("Replaced!", pcTest->mszText.Text());

    pcTest = (CTestUnknownJobbie*)cMap.Get("world");
    AssertPointer(NULL, pcTest);
    pcTest = (CTestUnknownJobbie*)cMap.Get(NULL);
    AssertPointer(NULL, pcTest);
    pcTest = (CTestUnknownJobbie*)cMap.Get("");
    AssertPointer(NULL, pcTest);

    pcTest = cMap.Put<CTestUnknownJobbie>("");
    pcTest->Init(0, "Empty");
    pcTest = (CTestUnknownJobbie*)cMap.Get("");
    AssertString("Empty", pcTest->mszText.Text());

    cMap.Kill();

    AssertInt(0, gcUnknowns.NumElements());

    UnknownsKill();
    MemoryKill();
}
void TestMapStringUnknownLoad(void)
{
    MemoryInit();
    UnknownsInit();

    CMapStringUnknown	cMap;
    CTestUnknownJobbie*	pcTest;
    CChunkFile			cFile;
    CFileUtil			cFileUtil;
    BOOL				bResult;

    gcUnknowns.AddConstructor<CTestUnknownJobbie>();
    AssertInt(0, gcUnknowns.NumElements());

    cFileUtil.RemoveDir("MapStringUnknown");
    cFileUtil.MakeDir("MapStringUnknown");

    cMap.Init();

    pcTest = cMap.Put<CTestUnknownJobbie>("Hello");
    pcTest->Init(7, "1st");
    pcTest = cMap.Put<CTestUnknownJobbie>("World");
    pcTest->Init(19, "A pony");
    pcTest = cMap.Put<CTestUnknownJobbie>("Aardvark");
    pcTest->Init(4, "Restore");
    pcTest = cMap.Put<CTestUnknownJobbie>("Yurk");
    pcTest->Init(8, "Yurk");

    cFile.Init(DiskFile("MapStringUnknown/Map.dat"));
    bResult = cFile.WriteOpen();
    AssertTrue(bResult);

    bResult = cMap.Save(&cFile);
    AssertTrue(bResult);

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

    cFile.Kill();
    cMap.Kill();

    AssertInt(0, gcUnknowns.NumElements());

    cFile.Init(DiskFile("MapStringUnknown/Map.dat"));
    bResult = cFile.ReadOpen();
    AssertTrue(bResult);

    bResult = cMap.Load(&cFile);
    AssertTrue(bResult);

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

    cFile.Kill();

    AssertInt(4, cMap.NumElements());
    AssertInt(4, gcUnknowns.NumElements());

    pcTest = (CTestUnknownJobbie*)cMap.Get("Hello");
    AssertInt(7, pcTest->miANumber);
    AssertString("1st", pcTest->mszText.Text());

    pcTest = (CTestUnknownJobbie*)cMap.Get("World");
    AssertInt(19, pcTest->miANumber);
    AssertString("A pony", pcTest->mszText.Text());

    pcTest = (CTestUnknownJobbie*)cMap.Get("Aardvark");
    AssertInt(4, pcTest->miANumber);
    AssertString("Restore", pcTest->mszText.Text());

    pcTest = (CTestUnknownJobbie*)cMap.Get("Yurk");
    AssertInt(8, pcTest->miANumber);
    AssertString("Yurk", pcTest->mszText.Text());

    cMap.Kill();

    AssertInt(0, gcUnknowns.NumElements());

    cFileUtil.RemoveDir("MapStringUnknown");

    UnknownsKill();
    MemoryKill();
}
void TestSetTypeAddAll(void)
{
	UnknownsInit();

	CSetType<CTestNamedUnknown>	cSet;
	int							i;
	CTestNamedUnknown*			pcTest;
	CSetType<CTestNamedUnknown>	cDest;
	CChars						sz;
	CTestNamedUnknown*			pcTest25;

	cSet.Init();
	pcTest25 = NULL;
	for (i = 0; i < 50; i++)
	{
		pcTest = UMalloc(CTestNamedUnknown);

		sz.Init(":");
		sz.Append(i);
		pcTest->Init(sz.Text());
		sz.Kill();
		cSet.Add(pcTest);
		if (i == 25)
		{
			pcTest25 = pcTest;
		}
	}

	cSet.Remove(pcTest25);

	cDest.Init();
	cDest.AddAll(&cSet);
	cSet.KillElements(FALSE);
	cSet.Kill();

	AssertInt(49, cDest.NumElements());

	for (i = 0; i < 25; i++)
	{
		pcTest = (CTestNamedUnknown*)cDest.UnsafeGet(i);
		sz.Init(":");
		sz.Append(i);
		AssertString(sz.Text(), pcTest->mszName.Text());
		sz.Kill();
	}

	pcTest = (CTestNamedUnknown*)cDest.UnsafeGet(i);
	AssertNull(pcTest);

	for (i = 26; i < 50; i++)
	{
		pcTest = (CTestNamedUnknown*)cDest.UnsafeGet(i);
		sz.Init(":");
		sz.Append(i);
		AssertString(sz.Text(), pcTest->mszName.Text());
		sz.Kill();
	}

	cDest.Kill();
	UnknownsKill();
}