コード例 #1
0
ファイル: classification_test.cpp プロジェクト: AdriCS/libLAS
    void to::test<18>()
    {
        liblas::Classification c;

        c.SetKeyPoint(true);
        c.SetClass(1);
        c.SetSynthetic(true);
        c.SetWithheld(true);
        ensure(c.IsWithheld());
        ensure(c.IsKeyPoint());
        ensure(c.IsSynthetic());
        ensure_equals(c.GetClass(), 1);
        ensure_not(c == m_default);
        
        c.SetKeyPoint(false);
        c.SetSynthetic(false);
        c.SetClass(0);
        c.SetWithheld(false);
        ensure_not(c.IsWithheld());
        ensure_not(c.IsKeyPoint());
        ensure_not(c.IsSynthetic());
        ensure_equals(c.GetClass(), 0);

        liblas::Classification::bitset_type bits1(c);
        liblas::Classification::bitset_type bits2(m_default);
        ensure_equals(c, m_default);
    }
コード例 #2
0
  TEST(Serialization, WriteBitsHard)
  {
    QByteArray msg1(2, 'a');
    QBitArray bits1(12, true);

    Serialization::WriteBitArray(bits1, msg1, 0);
    EXPECT_EQ((char)0xFF, (char)msg1[0]);
    EXPECT_EQ((char)0x0F, (char)msg1[1]);

    bits1.setBit(0, false);
    Serialization::WriteBitArray(bits1, msg1, 0);
    EXPECT_EQ((char)0x7F, (char)msg1[0]);
    EXPECT_EQ((char)0x0F, (char)msg1[1]);

    bits1.setBit(11, false);
    Serialization::WriteBitArray(bits1, msg1, 0);
    EXPECT_EQ((char)0x7F, (char)msg1[0]);
    EXPECT_EQ((char)0x0E, (char)msg1[1]);

    QByteArray msg2(3, 'b');
    Serialization::WriteBitArray(bits1, msg2, 1);
    EXPECT_EQ((char)'b', (char)msg2[0]);
    EXPECT_EQ((char)0x7F, (char)msg2[1]);
    EXPECT_EQ((char)0x0E, (char)msg2[2]);
  }
コード例 #3
0
  TEST(Serialization, WriteBitsEasy)
  {
    QByteArray msg(1, 'a');
    QBitArray bits(1, false);

    Serialization::WriteBitArray(bits, msg, 0);
    EXPECT_EQ((char)0x00, (char)msg[0]);

    QByteArray msg1(1, 'a');
    QBitArray bits1(0, false);

    Serialization::WriteBitArray(bits1, msg1, 0);
    EXPECT_EQ((char)0x00, (char)msg1[0]);

    QByteArray msg2(1, 'a');
    QBitArray bits2(1, true);

    Serialization::WriteBitArray(bits2, msg2, 0);
    EXPECT_EQ((char)0x01, (char)msg2[0]);

    QByteArray msg3(2, 'a');
    QBitArray bits3(8, true);

    Serialization::WriteBitArray(bits3, msg3, 0);
    EXPECT_EQ((char)0xFF, (char)msg3[0]);
    EXPECT_EQ((char)'a', (char)msg3[1]);

    QByteArray msg4(2, 'a');
    QBitArray bits4(8, true);

    Serialization::WriteBitArray(bits4, msg4, 1);
    EXPECT_EQ((char)'a', (char)msg4[0]);
    EXPECT_EQ((char)0xFF, (char)msg4[1]);

    QByteArray msg5(2, 'a');
    QBitArray bits5(9, true);

    Serialization::WriteBitArray(bits5, msg5, 0);
    EXPECT_EQ((char)0xFF, (char)msg5[0]);
    EXPECT_EQ((char)0x01, (char)msg5[1]);

    QByteArray msg6(2, 'a');
    QBitArray bits6(10, true);

    Serialization::WriteBitArray(bits6, msg6, 0);
    EXPECT_EQ((char)0xFF, (char)msg6[0]);
    EXPECT_EQ((char)0x03, (char)msg6[1]);
  }
コード例 #4
0
    void select(TUint &bits0) {
	TRequestStatus rs;
	io.Wait();
	int newbits = 0;
	TUint bits = bits0;
	if ((bits & KSockSelectRead) != 0) {
	    ++select_reqs[0];
	    if (select_reqs[0] == 1) {
		newbits = 1;
	    }
	}
	if ((bits & KSockSelectWrite) != 0) {
	    ++select_reqs[1];
	    if (select_reqs[1] == 1) {
 		newbits = 1;
	    }
	}
	if ((bits & KSockSelectExcept) != 0) {
	    ++select_reqs[2];
	    if (select_reqs[2] == 1) {
		newbits = 1;
	    }
	}
	if (in_wait && newbits) {
	    CancelIoctl();
	}
	io.Signal();
	do {
	    int done = 0;
	    TUint nbits = 0;
	    io.Wait();
	    if (select_reqs[0]) {
		nbits  |= KSockSelectRead;
	    }
	    if (select_reqs[1]) {
		nbits  |= KSockSelectWrite;
	    }
	    if (select_reqs[2]) {
		nbits  |= KSockSelectExcept;
	    }

	    TPckg<TUint> bits1(nbits);
	    Ioctl(KIOctlSelect, rs, &bits1, KSOLSocket);
//	    Ioctl(KIOctlSelect, rs, (TDes8 *)&x, KSOLSocket);
	    in_wait = 1;
	    io.Signal();

	    User::WaitForRequest(rs);
	    if (rs == KErrNone) {
		assert(nbits == bits1());
		if ((nbits & bits) != 0) {
		    bits0 = nbits;
		    done = 1;
		}
	    }
	    io.Wait();
	    in_wait = 0;
	    io.Signal();
	} while (rs == KErrCancel);

	io.Wait();
	newbits = 0;
	if ((bits & KSockSelectRead) != 0) {
	    --select_reqs[0];
	    if (select_reqs[0] == 0) {
		newbits = 1;
	    }
	}
	if ((bits & KSockSelectWrite) != 0) {
	    --select_reqs[1];
	    if (select_reqs[1] == 0) {
		newbits = 1;
	    }
	}
	if ((bits & KSockSelectExcept) != 0) {
	    --select_reqs[2];
	    if (select_reqs[2] == 0) {
		newbits = 1;
	    }
	}
	if (in_wait && newbits) {
	    CancelIoctl();
	}
	io.Signal();
    }