Exemplo n.º 1
0
TEST(GTestMutable, TestSubstitution) {
    GTestMutable::Ptr p = GTestMutable::create();
    Mutable::Ptr p2 = p;
    Mutable::CPtr p3 = p;
    Object::CPtr p4 = p;
    Mutable::CPtr p5 = LIBJ_STATIC_CPTR_CAST(Mutable)(p4);
    GTestMutable::Ptr p6 = LIBJ_STATIC_PTR_CAST(GTestMutable)(p2);
    ASSERT_TRUE(p && p2 && p3 && p4 && p5 && p6);
}
Exemplo n.º 2
0
TEST(GTestImmutable, TestUseCount) {
    {
        GTestImmutable::CPtr p = GTestImmutable::create();
        ASSERT_EQ(1, p.use_count());
        ASSERT_EQ(1, GTestImmutable::count);

        GTestImmutable::CPtr p2 = GTestImmutable::create();
        ASSERT_EQ(1, p2.use_count());
        ASSERT_EQ(2, GTestImmutable::count);

        p = p2;
        ASSERT_EQ(2, p.use_count());
        ASSERT_EQ(2, p2.use_count());
        ASSERT_EQ(1, GTestImmutable::count);

        GTestImmutable::CPtr p3 =
            LIBJ_STATIC_CPTR_CAST(GTestImmutable)((&(*p))->self());
        ASSERT_EQ(3, p.use_count());
        ASSERT_EQ(3, p2.use_count());
        ASSERT_EQ(3, p3.use_count());
        ASSERT_EQ(1, GTestImmutable::count);
    }
    ASSERT_EQ(0, GTestImmutable::count);
}