TEST(APC, SetOverwrite) { auto store = new_store(); store->set(s_key, Variant(s_value1), 1500); Variant got; EXPECT_EQ(store->get(s_key, got), true); EXPECT_TRUE(cellSame(*got.asCell(), make_tv<KindOfStaticString>(s_value1.get()))); store->set(s_key, Variant(s_value2), 1500); EXPECT_EQ(store->get(s_key, got), true); EXPECT_TRUE(cellSame(*got.asCell(), make_tv<KindOfStaticString>(s_value2.get()))); }
TEST(APC, Basic) { auto store = new_store(); EXPECT_EQ(store->add(s_key, Variant(s_value1), 1500), true); EXPECT_EQ(store->exists(s_key), true); Variant got; EXPECT_EQ(store->get(s_key, got), true); EXPECT_TRUE(cellSame(*got.asCell(), make_tv<KindOfStaticString>(s_value1.get()))); EXPECT_EQ(store->erase(s_key), true); EXPECT_EQ(store->get(s_key, got), false); }
TEST(APC, BasicPrimeStuff) { auto store = new_primed_store(); Variant val; EXPECT_TRUE(store->get("int_2", val)); EXPECT_TRUE(cellSame(*val.asCell(), make_tv<KindOfInt64>(2))); bool found = false; EXPECT_EQ(store->inc("int_3", 1, found), 4); EXPECT_TRUE(found); EXPECT_FALSE(store->get("int_200", val)); EXPECT_EQ(store->cas("obj_1", 1, 2), true); // stdclass converts to 1 EXPECT_EQ(store->cas("obj_2", 4, 5), false); EXPECT_EQ(store->cas("int_4", 4, 5), true); EXPECT_EQ(store->cas("int_5", 4, 5), false); }
bool tvSame(TypedValue tv1, TypedValue tv2) { assert(tvIsPlausible(tv1)); assert(tvIsPlausible(tv2)); return cellSame(*tvToCell(&tv1), *tvToCell(&tv2)); }
bool tvSame(const TypedValue* tv1, const TypedValue* tv2) { assert(tvIsPlausible(tv1)); assert(tvIsPlausible(tv2)); return cellSame(tvToCell(tv1), tvToCell(tv2)); }