Ejemplo n.º 1
0
TEST_F(DonutSlotTest, SeekTest)
{
	Handler<Object> obj100 = heap->createInt(100);
	Slot slot;
	clock->tick();
	slot.store(heap, obj100.get());

	ASSERT_TRUE(slot.have());
	ASSERT_NO_THROW(slot.load());
	ASSERT_EQ(obj100->toInt(heap), slot.load()->toInt(heap));

	clock->tick();
	slot.onForwardNotify(heap);//FIXME: シークの通知はヒープにぶら下がったオブジェクトのスロットにしか、来ない
	Handler<Object> obj200 = heap->createInt(200);
	slot.store(heap, obj200.get());

	ASSERT_TRUE(slot.have());
	ASSERT_NO_THROW(slot.load());
	ASSERT_EQ(obj200->toInt(heap), slot.load()->toInt(heap));

	clock->seek(clock->now()-1);
	slot.onBackNotify(heap);//FIXME: シークの通知はヒープにぶら下がったオブジェクトのスロットにしか、来ない

	ASSERT_TRUE(slot.have());
	ASSERT_NO_THROW(slot.load());
	ASSERT_EQ(obj100->toInt(heap), slot.load()->toInt(heap));

	clock->seek(clock->firstTime());
	slot.onBackNotify(heap);//FIXME: シークの通知はヒープにぶら下がったオブジェクトのスロットにしか、来ない
	ASSERT_FALSE(slot.have());
	ASSERT_ANY_THROW(slot.load());
}
Ejemplo n.º 2
0
TEST_F(DonutSlotTest, SaveTest)
{
	XValue v;
	timestamp_t t1,t2,t3;
	{
		Slot slot;
		t1 = clock->now();
		clock->tick();
		t2 = clock->now();
		Handler<Object> obj100 = heap->createInt(100);
		slot.store(heap, obj100.get());

		clock->tick();
		t3 = clock->now();
		slot.onForwardNotify(heap);
		Handler<Object> obj200 = heap->createInt(200);
		slot.store(heap, obj200.get());

		clock->seek(t2);
		slot.onBackNotify(heap);
		v = slot.save();
	}
	{
		Slot slot(heap, v);
		ASSERT_EQ(100, slot.load()->toInt(heap));

		clock->seek(t1);
		slot.onBackNotify(heap);

		ASSERT_FALSE(slot.have());
		ASSERT_ANY_THROW(slot.load());

		clock->seek(t2);
		slot.onForwardNotify(heap);
		ASSERT_TRUE(slot.have());
		ASSERT_NO_THROW(slot.load());
		ASSERT_EQ(100, slot.load()->toInt(heap));

		clock->seek(t3);
		slot.onForwardNotify(heap);
		ASSERT_TRUE(slot.have());
		ASSERT_NO_THROW(slot.load());
		ASSERT_EQ(200, slot.load()->toInt(heap));
	}
}