void TestChannelsAccessorByteAligned(void)
{
	CChannels*					pcChannels;
	CChannelsAccessor*			pcAccessor;
	CChannelsAccessorCreator	cCreator;
	short*						psData;
	short						sData[3];
	int							iData;

	pcChannels = UMalloc(CChannels);
	pcChannels->Init();
	pcChannels->BeginChange();
	pcChannels->SetSize(2);
	pcChannels->AddChannel(CHANNEL_NAME_JACK, PT_short);
	pcChannels->AddChannel(CHANNEL_NAME_BOB, PT_int);
	pcChannels->AddChannel(CHANNEL_NAME_ALICE, PT_short);
	pcChannels->EndChange();

	cCreator.Init(pcChannels);
	cCreator.AddAccess(CHANNEL_NAME_JACK, PT_Undefined);
	cCreator.AddAccess(CHANNEL_NAME_ALICE, PT_Undefined);
	pcAccessor = cCreator.CreateAndKill();
	AssertString("CChannelsAccessorByteAligned", pcAccessor->ClassName());
	sData[0] = 784;
	sData[1] = 602;
	pcAccessor->Set(1, &sData);
	AssertShort(784, *(short*)RemapSinglePointer(pcChannels->GetData(), 8 + 0));
	AssertShort(602, *(short*)RemapSinglePointer(pcChannels->GetData(), 8 + 6));
	psData = (short*)pcAccessor->Get(1);
	AssertShort(784, psData[0]);
	AssertShort(602, psData[1]);
	pcAccessor->Kill();

	cCreator.Init(pcChannels);
	cCreator.AddAccess(CHANNEL_NAME_BOB, PT_Undefined);
	pcAccessor = cCreator.CreateAndKill();
	iData = 999999;
	pcAccessor->Set(1, &iData);
	pcAccessor->Kill();

	cCreator.Init(pcChannels);
	cCreator.AddAccess(CHANNEL_NAME_ALICE, PT_Undefined);
	cCreator.AddAccess(CHANNEL_NAME_BOB, PT_Undefined);
	pcAccessor = cCreator.CreateAndKill();
	AssertString("CChannelsAccessorByteAligned", pcAccessor->ClassName());
	psData = (short*)pcAccessor->Get(1);
	AssertShort(602, psData[0]);
	AssertInt(999999, *(int*)&psData[1]);
	sData[0] = 22172;
	sData[1] = 18432;
	sData[2] = 30812;
	pcAccessor->Set(0, sData);
	AssertInt(2019313664, *(int*)RemapSinglePointer(pcChannels->GetData(), 2));
	AssertShort(22172, *(short*)RemapSinglePointer(pcChannels->GetData(), 6));
	pcAccessor->Kill();
}
void TestChannelsAccessorTypeConvert(void)
{
	CChannels*					pcChannels;
	CChannelsAccessor*			pcAccessor;
	CChannelsAccessorCreator	cCreator;
	float*						pfData;
	float						afData[3];

	pcChannels = UMalloc(CChannels);
	pcChannels->Init();
	pcChannels->BeginChange();
	pcChannels->SetSize(2);
	pcChannels->AddChannel(CHANNEL_NAME_JACK, PT_ushort);
	pcChannels->AddChannel(CHANNEL_NAME_BOB, PT_uint);
	pcChannels->AddChannel(CHANNEL_NAME_ALICE, PT_ushort);
	pcChannels->EndChange();
	pcChannels->Clear();

	cCreator.Init(pcChannels);
	cCreator.AddAccess(CHANNEL_NAME_JACK, PT_float);
	cCreator.AddAccess(CHANNEL_NAME_ALICE, PT_float);
	pcAccessor = cCreator.CreateAndKill();
	AssertString("CChannelsAccessorTypeConvert", pcAccessor->ClassName());
	afData[0] = 1.0f;
	afData[1] = 0.34f;
	pcAccessor->Set(1, afData);
	AssertShortHex((short)0xffff, *(unsigned short*)RemapSinglePointer(pcChannels->GetData(), 8 + 0));
	AssertShortHex(0x5709, *(unsigned short*)RemapSinglePointer(pcChannels->GetData(), 8 + 6));
	pfData = (float*)pcAccessor->Get(1);
	AssertFloat(1.0f, pfData[0], 2);
	AssertFloat(0.34f, pfData[1], 2);
	pcAccessor->Kill();

	cCreator.Init(pcChannels);
	cCreator.AddAccess(CHANNEL_NAME_BOB, PT_float);
	pcAccessor = cCreator.CreateAndKill();
	AssertString("CChannelsAccessorTypeConvert", pcAccessor->ClassName());
	afData[0] = 0.8f;
	pcAccessor->Set(1, afData);
	AssertIntHex(0xcccccd00, *(int*)RemapSinglePointer(pcChannels->GetData(), 8 + 2));
	pcAccessor->Kill();

	cCreator.Init(pcChannels);
	cCreator.AddAccess(CHANNEL_NAME_ALICE, PT_float);
	cCreator.AddAccess(CHANNEL_NAME_BOB, PT_float);
	pcAccessor = cCreator.CreateAndKill();
	AssertString("CChannelsAccessorTypeConvert", pcAccessor->ClassName());
	pfData = (float*)pcAccessor->Get(1);
	AssertFloat(0.34f, pfData[0], 2);
	AssertFloat(0.80f, pfData[1], 2);
	pcAccessor->Kill();
}
void CChannelsCopier::Init(CChannels* pcSource, CChannels* pcDest)
{
	CChannelsAccessorCreator	cCreator;

	//Now we have an accessor that takes what's in the source and converts it to the destinations format.
	//Although it may have gaps if the destination has channels the source does not.
	cCreator.Init(pcSource);
	cCreator.AddAccess(pcDest);
	mpcSourceAccessor = cCreator.CreateAndKill();

	//This looks a bit retarded but it creates an accessor capable of reading the source accesses output.
	cCreator.Init(pcDest);
	cCreator.AddAccess(mpcSourceAccessor);
	mpcDestAccessor = cCreator.CreateAndKill();
}
void CMeshConverter::PopulateColours(SD3DVertexType* psVertexType, void* pvFirstNewVert, CVertexArray* pcVertexArray)
{
	int							j;
	void*						pvVert;
	int							iNumVerts;
	int*						piColour;
	CChannelsAccessorCreator	cCreator;
	CChannelsAccessor*			pcAccessor;

	if (psVertexType->iColourOffest != -1)
	{
		cCreator.Init(pcVertexArray);
		cCreator.AddAccess(VERTEX_DIFFUSE_RED, VERTEX_DIFFUSE_GREEN, VERTEX_DIFFUSE_BLUE, VERTEX_OPACITY, PT_uchar);
		pcAccessor = cCreator.CreateAndKill();

		iNumVerts = pcVertexArray->GetSize();
		pvVert = RemapSinglePointer(pvFirstNewVert, psVertexType->iColourOffest);
		for (j = 0; j < iNumVerts; j++)
		{
			piColour = (int*)pcAccessor->Get(j);
			*((int*)pvVert) = *piColour;
			pvVert = RemapSinglePointer(pvVert, psVertexType->iD3DVertexSize);
		}
		pcAccessor->Kill();
	}
}
void CMeshConverter::PopulateNormals(SD3DVertexType* psVertexType, void* pvFirstNewVert, CVertexArray* pcVertexArray)
{
	int							j;
	void*						pvVert;
	int							iNumVerts;
	SFloat3*					psNormal;
	CChannelsAccessorCreator	cCreator;
	CChannelsAccessor*			pcAccessor;

	if (psVertexType->iNormalOffest != -1)
	{
		cCreator.Init(pcVertexArray);
		cCreator.AddAccess(VERTEX_NORMAL_X, VERTEX_NORMAL_Y, VERTEX_NORMAL_Z, PT_float);
		pcAccessor = cCreator.CreateAndKill();

		iNumVerts = pcVertexArray->GetSize();
		pvVert = RemapSinglePointer(pvFirstNewVert, psVertexType->iNormalOffest);
		for (j = 0; j < iNumVerts; j++)
		{
			psNormal = (SFloat3*)pcAccessor->Get(j);
			((SFloat3*)pvVert)->Copy(psNormal);
			((SFloat3*)pvVert)->Normalize();
			pvVert = RemapSinglePointer(pvVert, psVertexType->iD3DVertexSize);
		}

		pcAccessor->Kill();
	}
}
void CMeshConverter::PopulateUVs(SD3DVertexType* psVertexType, void* pvFirstNewVert, CVertexArray* pcVertexArray)
{
	int							j;
	void*						pvVert;
	int							iNumVerts;
	int							iNumTextures;
	int							k;
	CMeshUVLayer*				pcUVLayer;
	SFloat2*					psUV;
	CChannelsAccessorCreator	cCreator;
	CChannelsAccessor*			pcAccessor;

	if (psVertexType->iUVOffest != -1)
	{
		iNumVerts = pcVertexArray->GetSize();
		iNumTextures = gcD3D.GetVertetFormatTextures(psVertexType->iD3DVertexFormat);

		for (k = 0; k < iNumTextures; k++)
		{
			cCreator.Init(pcVertexArray);
			cCreator.AddAccess(CHANNEL(VP_UVCoord_(k), CT_U), CHANNEL(VP_UVCoord_(k), CT_V), PT_float);
			pcAccessor = cCreator.CreateAndKill();

			pvVert = RemapSinglePointer(pvFirstNewVert, psVertexType->iUVOffest + (k * sizeof(SFloat2)));
			for (j = 0; j < iNumVerts; j++)
			{
				pcUVLayer = mpcMesh->mcUVs.mcLayers.Get(k);
				psUV = (SFloat2*)pcAccessor->Get(j);
				((SFloat2*)pvVert)->Init(psUV->x, psUV->y);

				pvVert = RemapSinglePointer(pvVert, psVertexType->iD3DVertexSize);
			}

			pcAccessor->Kill();
		}
	}
}
void TestChannelsAccessorAccessBitty(void)
{
	CChannels*					pcChannels;
	CChannelsAccessor*			pcAccessor;
	CChannelsAccessorCreator	cCreator;
	unsigned char*				pucData;
	unsigned char				aucData[2];

	pcChannels = UMalloc(CChannels);
	pcChannels->Init();
	pcChannels->BeginChange();
	pcChannels->SetSize(1);
	pcChannels->AddChannel(CHANNEL_NAME_JACK, PT_ushort);
	pcChannels->AddChannel(CHANNEL_NAME_BOB, PT_ushort);
	pcChannels->AddChannel(CHANNEL_NAME_ALICE, PT_ushort);
	pcChannels->EndChange();
	pcChannels->Clear();

	cCreator.Init(pcChannels);
	cCreator.AddAccess(CHANNEL_NAME_JACK, PT_sixbits);
	cCreator.AddAccess(CHANNEL_NAME_BOB, PT_sixbits);
	cCreator.AddAccess(CHANNEL_NAME_ALICE, PT_nybble);
	pcAccessor = cCreator.CreateAndKill();
	AssertString("CChannelsAccessorAccessBitty", pcAccessor->ClassName());

	//XX10110010100011
	aucData[0] = 0xa3;
	aucData[1] = 0x2c;
	pcAccessor->Set(0, aucData);
	AssertShortHex((unsigned short)0x8e38, *(unsigned short*)RemapSinglePointer(pcChannels->GetData(), 0 + 0));
	AssertShortHex((unsigned short)0xcb2b, *(unsigned short*)RemapSinglePointer(pcChannels->GetData(), 0 + 2));
	AssertShortHex((unsigned short)0x2222, *(unsigned short*)RemapSinglePointer(pcChannels->GetData(), 0 + 4));
	pucData = (unsigned char*)pcAccessor->Get(0);
	AssertShortHex((unsigned short)0x2ca3, *(unsigned short*)pucData);
	pcAccessor->Kill();
}
void CMeshConverter::PopulatePositions(SD3DVertexType* psVertexType, void* pvFirstNewVert, CVertexArray* pcVertexArray)
{
	int							j;
	void*						pvVert;
	int							iNumVerts;
	SFloat3*					psPosition;
	CChannelsAccessorCreator	cCreator;
	CChannelsAccessor*			pcAccessor;

	cCreator.Init(pcVertexArray);
	cCreator.AddAccess(VERTEX_POSITION_X, VERTEX_POSITION_Y, VERTEX_POSITION_Z, PT_float);
	pcAccessor = cCreator.CreateAndKill();

	pvVert = pvFirstNewVert;
	iNumVerts = pcVertexArray->GetSize();
	for (j = 0; j < iNumVerts; j++)
	{
		psPosition = (SFloat3*)pcAccessor->Get(j);
		((SFloat3*)pvVert)->Copy(psPosition);
		pvVert = RemapSinglePointer(pvVert, psVertexType->iD3DVertexSize);
	}

	pcAccessor->Kill();
}
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 TestChannelsAccessorWorstCase(void)
{
	CChannels*					pcChannels;
	CChannelsAccessor*			pcAccessor;
	CChannelsAccessorCreator	cCreator;
	unsigned char*				pucData;
	unsigned char				aucData[5];


	pcChannels = UMalloc(CChannels);
	pcChannels->Init();
	pcChannels->BeginChange();
	pcChannels->SetSize(2);
	pcChannels->AddChannel(CHANNEL_NAME_JACK, PT_bit);
	pcChannels->AddChannel(CHANNEL_NAME_BOB, PT_uint);
	pcChannels->AddChannel(CHANNEL_NAME_ALICE, PT_uchar);
	pcChannels->EndChange();
	pcChannels->Clear();
	AssertInt(2, pcChannels->GetSize());
	AssertInt(11, pcChannels->GetByteSize());
	AssertInt(41, pcChannels->GetBitStride());
	AssertInt(-1, pcChannels->GetByteStride());
	AssertInt(FALSE, pcChannels->IsOnlyBasicTypes());

	memset(aucData, 0, 5);

	cCreator.Init(pcChannels);
	cCreator.AddAccess(CHANNEL_NAME_JACK, PT_uint);
	cCreator.AddAccess(CHANNEL_NAME_BOB, PT_bit);
	cCreator.AddAccess(CHANNEL_NAME_ALICE, PT_nybble);
	pcAccessor = cCreator.CreateAndKill();
	AssertString("CChannelsAccessorWorstCase", pcAccessor->ClassName());
	AssertInt(-1, pcAccessor->GetByteSize());
	AssertInt(37, pcAccessor->GetBitSize());
	AssertInt(5, pcAccessor->GetBufferSize());
	aucData[0] = 0xff;
	aucData[1] = 0xff;
	aucData[2] = 0xff;
	aucData[3] = 0xff;
	aucData[4] = 0xff;
	pcAccessor->Set(0, aucData);
	AssertChar((unsigned char)0xff, pcChannels->GetData()[0]);
	AssertChar((unsigned char)0xff, pcChannels->GetData()[1]);
	AssertChar((unsigned char)0xff, pcChannels->GetData()[2]);
	AssertChar((unsigned char)0xff, pcChannels->GetData()[3]);
	AssertChar((unsigned char)0xff, pcChannels->GetData()[4]);
	AssertChar((unsigned char)0x01, pcChannels->GetData()[5]);  //01 because the next 'pixel' is all zeros.  The 1 is the high bit of the char in ALICE.
	pucData = (unsigned char*)pcAccessor->Get(0);
	AssertChar((unsigned char)0xff, pucData[0]);
	AssertChar((unsigned char)0xff, pucData[1]);
	AssertChar((unsigned char)0xff, pucData[2]);
	AssertChar((unsigned char)0xff, pucData[3]);
	AssertChar((unsigned char)0x1f, pucData[4]);

	aucData[0] = 0xff;
	aucData[1] = 0xff;
	aucData[2] = 0xff;
	aucData[3] = 0xff;
	aucData[4] = 0xfe;
	pcAccessor->Set(1, aucData);
	AssertChar((unsigned char)0x03, pcChannels->GetData()[5]); //01 from 'pixel' 0 and 02 from the bit in JACK in 'pixel' 1.
	AssertChar((unsigned char)0x00, pcChannels->GetData()[6]);
	AssertChar((unsigned char)0x00, pcChannels->GetData()[7]);
	AssertChar((unsigned char)0x00, pcChannels->GetData()[8]);
	AssertChar((unsigned char)0xfc, pcChannels->GetData()[9]);  //fc it the six low bits of the char
	AssertChar((unsigned char)0x03, pcChannels->GetData()[10] & 0x03);  //03 is the two high bits.
	pucData = (unsigned char*)pcAccessor->Get(1);
	AssertChar((unsigned char)0xff, pucData[0]);
	AssertChar((unsigned char)0xff, pucData[1]);
	AssertChar((unsigned char)0xff, pucData[2]);
	AssertChar((unsigned char)0xff, pucData[3]);
	AssertChar((unsigned char)0x1e, pucData[4]);
}
void TestChannelsAccessorChannelBitty(void)
{
	CChannels*					pcChannels;
	CChannelsAccessor*			pcAccessor;
	CChannelsAccessorCreator	cCreator;
	unsigned char*				pucData;
	unsigned char				aucData[3];
	float*						pfData;

	pcChannels = UMalloc(CChannels);
	pcChannels->Init();
	pcChannels->BeginChange();
	pcChannels->SetSize(1);
	pcChannels->AddChannel(CHANNEL_NAME_JACK, PT_bit);
	pcChannels->AddChannel(CHANNEL_NAME_BOB, PT_crumb);
	pcChannels->AddChannel(CHANNEL_NAME_ALICE, PT_bit);
	pcChannels->EndChange();
	pcChannels->Clear();
	AssertInt(1, pcChannels->GetByteSize());
	AssertInt(1, pcChannels->GetSize());

	cCreator.Init(pcChannels);
	cCreator.AddAccess(CHANNEL_NAME_JACK, PT_uchar);
	cCreator.AddAccess(CHANNEL_NAME_BOB, PT_uchar);
	cCreator.AddAccess(CHANNEL_NAME_ALICE, PT_uchar);
	pcAccessor = cCreator.CreateAndKill();
	AssertString("CChannelsAccessorChannelBitty", pcAccessor->ClassName());
	aucData[0] = 0xff;
	aucData[1] = 0x55;
	aucData[2] = 0xff;
	pcAccessor->Set(0, aucData);
	AssertChar(0xb, *pcChannels->GetData());  //Or maybe 0xd.  I'm not sure of the ordering
	pucData = (unsigned char*)pcAccessor->Get(0);
	AssertChar((char)0xff, pucData[0]);
	AssertChar((char)0x55, pucData[1]);
	AssertChar((char)0xff, pucData[2]);
	pcAccessor->Kill();

	pcChannels->BeginChange();
	pcChannels->SetSize(2);
	pcChannels->EndChange();
	AssertInt(1, pcChannels->GetByteSize());
	AssertInt(2, pcChannels->GetSize());

	cCreator.Init(pcChannels);
	cCreator.AddAccess(CHANNEL_NAME_JACK, PT_uchar);
	cCreator.AddAccess(CHANNEL_NAME_BOB, PT_uchar);
	cCreator.AddAccess(CHANNEL_NAME_ALICE, PT_uchar);
	pcAccessor = cCreator.CreateAndKill();
	AssertString("CChannelsAccessorChannelBitty", pcAccessor->ClassName());
	pucData = (unsigned char*)pcAccessor->Get(0);
	AssertChar((char)0xff, pucData[0]);
	AssertChar((char)0x55, pucData[1]);
	AssertChar((char)0xff, pucData[2]);

	aucData[0] = 0x00;
	aucData[1] = 0xaa;
	aucData[2] = 0xff;
	pcAccessor->Set(1, aucData);
	AssertChar(0xc, ((unsigned char)*pcChannels->GetData()) >> 4);  //Or maybe 0xd.  I'm not sure of the ordering
	pucData = (unsigned char*)pcAccessor->Get(1);
	AssertChar((char)0x00, pucData[0]);
	AssertChar((char)0xaa, pucData[1]);
	AssertChar((char)0xff, pucData[2]);
	pcAccessor->Kill();

	cCreator.Init(pcChannels);
	cCreator.AddAccess(CHANNEL_NAME_ALICE, PT_float);
	cCreator.AddAccess(CHANNEL_NAME_BOB, PT_float);
	pcAccessor = cCreator.CreateAndKill();
	AssertString("CChannelsAccessorChannelBitty", pcAccessor->ClassName());
	pfData = (float*)pcAccessor->Get(0);
	AssertFloat(1.0f, pfData[0], 2);
	AssertFloat(0.33f, pfData[1], 2);
	pfData = (float*)pcAccessor->Get(1);
	AssertFloat(1.0f, pfData[0], 2);
	AssertFloat(0.67f, pfData[1], 2);
	pcAccessor->Kill();
}
void TestChannelsAccessorContiguous(void)
{
	CChannels*					pcChannels;
	CChannelsAccessor*			pcAccessor;
	CChannelsAccessorCreator	cCreator;
	void*						pvData;
	int							iData;
	short						sData;

	pcChannels = UMalloc(CChannels);
	pcChannels->Init();
	pcChannels->BeginChange();
	pcChannels->SetSize(2);
	pcChannels->AddChannel(CHANNEL_NAME_BOB, PT_int);
	pcChannels->EndChange();

	cCreator.Init(pcChannels);
	cCreator.AddAccess(CHANNEL_NAME_BOB, PT_Undefined);
	pcAccessor = cCreator.CreateAndKill();
	AssertString("CChannelsAccessorContiguous", pcAccessor->ClassName());
	pvData = pcAccessor->Get(0);
	AssertPointer(pcChannels->GetData(), pvData);
	iData = 784;
	pcAccessor->Set(1, &iData);
	pvData = pcAccessor->Get(1);
	AssertInt(784, *(int*)pvData);
	pcAccessor->Kill();

	pcChannels->BeginChange();
	pcChannels->AddChannel(CHANNEL_NAME_ALICE, PT_short);
	pcChannels->EndChange();

	cCreator.Init(pcChannels);
	cCreator.AddAccess(CHANNEL_NAME_BOB, PT_Undefined);
	pcAccessor = cCreator.CreateAndKill();
	AssertString("CChannelsAccessorContiguous", pcAccessor->ClassName());
	pvData = pcAccessor->Get(1);
	AssertInt(784, *(int*)pvData);
	pcAccessor->Kill();

	cCreator.Init(pcChannels);
	cCreator.AddAccess(CHANNEL_NAME_ALICE, PT_Undefined);
	pcAccessor = cCreator.CreateAndKill();
	AssertString("CChannelsAccessorContiguous", pcAccessor->ClassName());
	pvData = pcAccessor->Get(0);
	AssertPointer(RemapSinglePointer(pcChannels->GetData(), 4), pvData);
	sData = 602;
	pcAccessor->Set(1, &sData);
	pvData = pcAccessor->Get(1);
	AssertShort(602, *(short*)pvData);
	pcAccessor->Kill();

	cCreator.Init(pcChannels);
	cCreator.AddAccess(CHANNEL_NAME_BOB, CHANNEL_NAME_ALICE, PT_Undefined);
	pcAccessor = cCreator.CreateAndKill();
	AssertString("CChannelsAccessorContiguous", pcAccessor->ClassName());
	AssertInt(6, pcAccessor->GetByteSize());
	pvData = pcAccessor->Get(1);
	AssertInt(784, *(int*)pvData);
	pvData = RemapSinglePointer(pvData, 4);
	AssertInt(602, *(short*)pvData);
	pcAccessor->Kill();
}