コード例 #1
0
TEST_F(BitSet64Test, BitWiseOr) {
    b1.markBit(20);
    b2.markBit(40);

    BitSet64 tmp = b1 | b2;
    EXPECT_EQ(tmp.count(), 2u);
    EXPECT_TRUE(tmp.hasBit(20) && tmp.hasBit(40));
    // Check that the operator is symmetric
    EXPECT_TRUE((b2 | b1) == (b1 | b2));

    b1 |= b2;
    EXPECT_EQ(b1.count(), 2u);
    EXPECT_TRUE(b1.hasBit(20) && b1.hasBit(40));
    EXPECT_TRUE(b2.hasBit(40) && b2.count() == 1u);
}
コード例 #2
0
TEST_F(BitSet64Test, BitWiseAnd_NonDisjoint) {
    b1.markBit(20);
    b1.markBit(40);
    b1.markBit(60);
    b2.markBit(30);
    b2.markBit(60);
    b2.markBit(63);

    BitSet64 tmp = b1 & b2;
    EXPECT_EQ(tmp.count(), 1u);
    EXPECT_TRUE(tmp.hasBit(60));
    // Check that the operator is symmetric
    EXPECT_TRUE((b2 & b1) == (b1 & b2));

    b1 &= b2;
    EXPECT_EQ(b1.count(), 1u);
    EXPECT_EQ(b2.count(), 3u);
    EXPECT_TRUE(b2.hasBit(30) && b2.hasBit(60) && b2.hasBit(63));
}