Esempio n. 1
0
TEST_F(TestField, CreateNoCopy)
{
    char s[100];
    Field f = Field::create_no_copy_null_string(m_pool, "foo", 3, s);
    std::string v("Hello World");
    std::copy(v.begin(), v.end(), s);
    EXPECT_EQ(std::string(s), f.value_as_null_string());

    ByteString b = ByteString::create(m_pool, "Test2");
    Field f2 = Field::create_no_copy_byte_string(m_pool, "foo", 3, b);
    b.set("Test4");
    EXPECT_EQ(b.to_s(), f2.value_as_byte_string().to_s());

    List<int*> l = List<int*>::create(m_pool);
    Field f3 = Field::create_no_copy_list(m_pool, "foo", 3, l);
    EXPECT_EQ(l.ib(), f3.value_as_list<int*>().ib());
}
Esempio n. 2
0
TEST_F(TestField, set_no_copy)
{
    {
        Field f = Field::create_null_string(m_pool, "foo", 3, "ABC");
        char s[] = "Hello";
        f.set_no_copy_null_string(s);
        s[0] = 'g';
        EXPECT_EQ(string("gello"), f.value_as_null_string());
    }
    {
        Field f = Field::create_byte_string(m_pool, "foo", 3,
            ByteString::create(m_pool, "Hello"));
        ByteString b = ByteString::create(m_pool, "Foo");
        f.set_no_copy_byte_string(b);
        b.set("ABC");
        EXPECT_EQ("ABC", f.value_as_byte_string().to_s());
    }
}