TEST(StringPieceTest, CompareNonNullTerminatedPiece) {
    StringPiece a("hello world", 5);
    StringPiece b("hello moon", 5);
    EXPECT_EQ(a, b);

    StringPiece16 a16(u"hello world", 5);
    StringPiece16 b16(u"hello moon", 5);
    EXPECT_EQ(a16, b16);
}
Exemplo n.º 2
0
void test2()
{
	BigData b1("");
	BigData b2("-123");
	BigData b3("-");
	BigData b4("+");
	BigData b5("+aa123");
	BigData b6("-aa123");
	BigData b7("aa123");
	BigData b8("123");
	BigData b9("+12aa3");
	BigData b10("-12aa3");
	BigData b11("12aa3");
	BigData b13("-000123");
	BigData b14("+000123");
	BigData b15("9999999999999999999999999999999999999999999999999999999");
	BigData b16(123);
	BigData b17(1234);
	cout<<b15;
	cin>>b1;

}
Exemplo n.º 3
0
/*!
	\todo more optimisation is possible (render the Block head and don't copy the buffer in memory, care should be taken with the allocation of Data)
	\todo the actual timecode to write should be retrieved from the Cluster from here
*/
filepos_t KaxInternalBlock::RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault)
{
	if (myBuffers.size() == 0) {
		return 0;
	} else {
		assert(TrackNumber < 0x4000);
		binary BlockHead[5], *cursor = BlockHead;
		unsigned int i;

		if (myBuffers.size() == 1) {
			SetSize_(4);
			mLacing = LACING_NONE;
		} else {
			if (mLacing == LACING_NONE)
				mLacing = LACING_EBML; // supposedly the best of all
			SetSize_(4 + 1); // 1 for the lacing head (number of laced elements)
		}
		if (TrackNumber > 0x80)
			SetSize_(GetSize() + 1);

		// write Block Head
		if (TrackNumber < 0x80) {
			*cursor++ = TrackNumber | 0x80; // set the first bit to 1 
		} else {
			*cursor++ = (TrackNumber >> 8) | 0x40; // set the second bit to 1
			*cursor++ = TrackNumber & 0xFF;
		}

		assert(ParentCluster != NULL);
		int16 ActualTimecode = ParentCluster->GetBlockLocalTimecode(Timecode);
		big_int16 b16(ActualTimecode);
		b16.Fill(cursor);
		cursor += 2;

		*cursor = 0; // flags

		if (mLacing == LACING_AUTO) {
			mLacing = GetBestLacingType();
		}

		// invisible flag
		if (mInvisible)
			*cursor = 0x08;

		if (bIsSimple) {
			if (bIsKeyframe)
				*cursor |= 0x80;
			if (bIsDiscardable)
				*cursor |= 0x01;
		}
		
		// lacing flag
		switch (mLacing)
		{
		case LACING_XIPH:
			*cursor++ |= 0x02;
			break;
		case LACING_EBML:
			*cursor++ |= 0x06;
			break;
		case LACING_FIXED:
			*cursor++ |= 0x04;
			break;
		case LACING_NONE:
			break;
	    default:
			assert(0);
		}

		output.writeFully(BlockHead, 4 + ((TrackNumber > 0x80) ? 1 : 0));

		binary tmpValue;
		switch (mLacing)
		{
		case LACING_XIPH:
			// number of laces
			tmpValue = myBuffers.size()-1;
			output.writeFully(&tmpValue, 1);

			// set the size of each member in the lace
			for (i=0; i<myBuffers.size()-1; i++) {
				tmpValue = 0xFF;
				uint16 tmpSize = myBuffers[i]->Size();
				while (tmpSize >= 0xFF) {
					output.writeFully(&tmpValue, 1);
					SetSize_(GetSize() + 1);
					tmpSize -= 0xFF;
				}
				tmpValue = binary(tmpSize);
				output.writeFully(&tmpValue, 1);
				SetSize_(GetSize() + 1);
			}
			break;
		case LACING_EBML:
			// number of laces
			tmpValue = myBuffers.size()-1;
			output.writeFully(&tmpValue, 1);

			{
				int64 _Size;
				int _CodedSize;
				binary _FinalHead[8]; // 64 bits max coded size

				_Size = myBuffers[0]->Size();

				_CodedSize = CodedSizeLength(_Size, 0, IsFiniteSize());

				// first size in the lace is not a signed
				CodedValueLength(_Size, _CodedSize, _FinalHead);
				output.writeFully(_FinalHead, _CodedSize);
				SetSize_(GetSize() + _CodedSize);

				// set the size of each member in the lace
				for (i=1; i<myBuffers.size()-1; i++) {
					_Size = int64(myBuffers[i]->Size()) - int64(myBuffers[i-1]->Size());
					_CodedSize = CodedSizeLengthSigned(_Size, 0);
					CodedValueLengthSigned(_Size, _CodedSize, _FinalHead);
					output.writeFully(_FinalHead, _CodedSize);
					SetSize_(GetSize() + _CodedSize);
				}
			}
			break;
		case LACING_FIXED:
			// number of laces
			tmpValue = myBuffers.size()-1;
			output.writeFully(&tmpValue, 1);
			break;
		case LACING_NONE:
			break;
	    default:
			assert(0);
		}

		// put the data of each frame
		for (i=0; i<myBuffers.size(); i++) {
			output.writeFully(myBuffers[i]->Buffer(), myBuffers[i]->Size());
			SetSize_(GetSize() + myBuffers[i]->Size());
		}
	}

	return GetSize();
}
Exemplo n.º 4
0
void level_two()
{
		vector<DPipe> DPIPES(44);
	vector<DoublePipe> DOUBPIPES(18);
	vector<CrossPipe> CROSSPIPES(3);

	DPipe background(600,400,1200,800);

	DPipe a0(50,750,100,40);
	DPipe a1(150,650,100,40);
	DPipe a2(150,550,100,40);
	DPipe a3(650,450,100,40);
	DPipe a4(550,550,100,40);
	DPipe a5(450,350,100,40);
	DPipe a6(550,250,100,40);
	DPipe a7(650,250,100,40);
	DPipe a8(750,350,100,40);
	DPipe a9(750,450,100,40);
	DPipe a10(750,550,100,40);
	DPipe a11(650,650,100,40);
	DPipe a12(550,650,100,40);
	DPipe a13(450,650,100,40);
	DPipe a14(350,550,100,40);
	DPipe a15(350,350,100,40);
	DPipe a16(350,250,100,40);
	DPipe a17(450,150,100,40);
	DPipe a18(550,150,100,40);
	DPipe a19(650,150,100,40);
	DPipe a20(750,150,100,40);
	DPipe a21(850,250,100,40);
	DPipe a22(850,350,100,40);
	DPipe a23(850,450,100,40);
	DPipe a24(850,550,100,40);
	DPipe a25(850,650,100,40);
	DPipe a26(750,750,100,40);
	DPipe a27(650,750,100,40);
	DPipe a28(550,750,100,40);
	DPipe a29(450,750,100,40);
	DPipe a30(350,750,100,40);
	DPipe a31(250,650,100,40);
	DPipe a32(250,550,100,40);
	DPipe a33(250,350,100,40);
	DPipe a34(250,250,100,40);
	DPipe a35(250,150,100,40);
	DPipe a36(350,50,100,40);
	DPipe a37(450,50,100,40);
	DPipe a38(550,50,100,40);
	DPipe a39(650,50,100,40);
	DPipe a40(750,50,100,40);
	DPipe a41(850,50,100,40);
	DPipe a42(950,150,100,40);
	DPipe a43(950,250,100,40);

	DoublePipe b0(150,750,70,40);
	DoublePipe b1(150,450,70,40);
	DoublePipe b2(550,450,70,40);
	DoublePipe b3(550,350,70,40);
	DoublePipe b4(650,350,70,40);
	DoublePipe b5(650,550,70,40);
	DoublePipe b6(450,550,70,40);
	DoublePipe b7(450,250,70,40);
	DoublePipe b8(750,250,70,40);
	DoublePipe b9(750,650,70,40);
	DoublePipe b10(350,650,70,40);
	DoublePipe b11(350,150,70,40);
	DoublePipe b12(850,150,70,40);
	DoublePipe b13(850,750,70,40);
	DoublePipe b14(250,750,70,40);
	DoublePipe b15(250,50,70,40);
	DoublePipe b16(950,50,70,40);
	DoublePipe b17(950,350,70,40);

	CrossPipe c0(250,450,100,40);
	CrossPipe c1(350,450,100,40);
	CrossPipe c2(450,450,100,40);

	DPIPES[0]=a0;
	DPIPES[1]=a1;
	DPIPES[2]=a2;
	DPIPES[3]=a3;
	DPIPES[4]=a4;
	DPIPES[5]=a5;
	DPIPES[6]=a6;
	DPIPES[7]=a7;
	DPIPES[8]=a8;
	DPIPES[9]=a9;
	DPIPES[10]=a10;
	DPIPES[11]=a11;
	DPIPES[12]=a12;
	DPIPES[13]=a13;
	DPIPES[14]=a14;
	DPIPES[15]=a15;
	DPIPES[16]=a16;
	DPIPES[17]=a17;
	DPIPES[18]=a18;
	DPIPES[19]=a19;
	DPIPES[20]=a20;
	DPIPES[21]=a21;
	DPIPES[22]=a22;
	DPIPES[23]=a23;
	DPIPES[24]=a24;
	DPIPES[25]=a25;
	DPIPES[26]=a26;
	DPIPES[27]=a27;
	DPIPES[28]=a28;
	DPIPES[29]=a29;
	DPIPES[30]=a30;
	DPIPES[31]=a31;
	DPIPES[32]=a32;
	DPIPES[33]=a33;
	DPIPES[34]=a34;
	DPIPES[35]=a35;
	DPIPES[36]=a36;
	DPIPES[37]=a37;
	DPIPES[38]=a38;
	DPIPES[39]=a39;
	DPIPES[40]=a40;
	DPIPES[41]=a41;
	DPIPES[42]=a42;
	DPIPES[43]=a43;

	DOUBPIPES[0]=b0;
	DOUBPIPES[1]=b1;
	DOUBPIPES[2]=b2;
	DOUBPIPES[3]=b3;
	DOUBPIPES[4]=b4;
	DOUBPIPES[5]=b5;
	DOUBPIPES[6]=b6;
	DOUBPIPES[7]=b7;
	DOUBPIPES[8]=b8;
	DOUBPIPES[9]=b9;
	DOUBPIPES[10]=b10;
	DOUBPIPES[11]=b11;
	DOUBPIPES[12]=b12;
	DOUBPIPES[13]=b13;
	DOUBPIPES[14]=b14;
	DOUBPIPES[15]=b15;
	DOUBPIPES[16]=b16;
	DOUBPIPES[17]=b17;

	CROSSPIPES[0]=c0;
	CROSSPIPES[1]=c1;
	CROSSPIPES[2]=c2;
}