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 TestDurableSet(void) { FastFunctionsInit(); TypeConverterInit(); BeginTests(); TestDurableSetAdd(); TestStatistics(); FastFunctionsKill(); TypeConverterKill(); }
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 TestPreprocessorReplacement(void) { ClassStorageInit(); FastFunctionsInit(); TypeConverterInit(); OperatorsInit(); InitTokenMemory(); CChars szDest; CPreprocessor::Preprocess("\ #define D3(X) #X\n\ #define D7(P,Q) D3(P) D3(Q)\n\ #define D4() " "\n\ #define D6(P,Q) D3(P)##D4()##D3(Q)\n\ #define D8(P,Q) D3(P) " " D3(Q)\n\ #define D5(X) X\n\ #define D9(P,Q) D5(P) D4() D5(Q)\n\ #define D2(P,Q) D9(#P, #Q)\n\ #define D1(P,Q) #P#Q\n\ \n\ void DoStuff()\n\ {\n\ //You can only legally have hashes in the replacement text. Bizzare things happen otherwise.\n\ //You can only have a single hash preceding a replacement argument.\n\ //Tokens after the hash are not expanded before hashing.\n\ char sz6[]=D9(\"Hello\", \"World\");\n\ char sz1[] = D7(Hello, World);\n\ char sz3[] = D8(Hello, World);\n\ char sz5[] = D1(Hello, World);\n\ char sz4[] = D2(Hello, World);\n\ char sz2[] = D6(Hello, World);\n\ }\n\ ", &szDest); //Actually I don't know what this is supposed to look like. Just make the test pass for now. AssertString("\ void DoStuff()\n\ {\n\ char sz6[]=\"Hello\" \"World\";\n\ char sz1[] = \"Hello\" \"World\";\n\ char sz3[] = \"Hello\" \"World\";\n\ char sz5[] = \"Hello\"\"World\";\n\ char sz4[] = \"Hello\" \"World\";\n\ char sz2[] = \"Hello\"\"World\";\n\ }\n\
void TestFiles(void) { BeginTests(); FastFunctionsInit(); TypeConverterInit(); MemoryInit(); TestFilesSimple(); TestFileSystemIteration(); TestFilesIteration(); TestGetFileNames(); TestFilesWholeDirectory(); MemoryKill(); FastFunctionsKill(); TypeConverterKill(); TestStatistics(); }
void TestLogFile(void) { BeginTests(); FastFunctionsInit(); TypeConverterInit(); TestLogFileOpen(); TestLogFileRead(); TestLogFileWrite(); TestLogFileFindHoles(); TestLogFileCommandsSimple(); TestLogFileCommandsComplex(); TestLogFileDelete(); TestLogFileMultipleReadsAfterOpens(); FastFunctionsKill(); TypeConverterKill(); TestStatistics(); }
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(); }