void StasisPod::freeze(std::shared_ptr<SimState> s){ Engine::out(Engine::SPAM) << "[StasisPod] Freeze" << std::endl; if(_pod.empty() || s->currentTick > peekTop()->currentTick){ _pod.push_front(std::shared_ptr<SimState>(new SimState(*s))); Engine::out() << "[StasisPod] Freezed - tick " << peekTop()->currentTick << std::endl; return; } auto it = _pod.begin(); for(; it != _pod.end() && (*it)->currentTick != s->currentTick ; ++it); *it = std::make_shared<SimState>(*s); Engine::out() << "[StasisPod] Freezed - tick " << peekTop()->currentTick << " overwritten" << std::endl; }
static void test_peekTop(void **state) { const int a = 1001; LinkedList *list = createList(); assert_non_null(list); for (int i = 0; i < a; i++) { int *c = malloc(sizeof(int)); *c = i; insertTop(list, c); assert_int_equal(*(int*)peekTop(list), i); } destroyList(list); }