void main ()
{
  int n = abs(__VERIFIER_nondet_int());
  node_t* x = new_ll(n + 1);
  node_t* y = append(x, x); // y is a circular linked list
  int y_length = length(y);
}
Esempio n. 2
0
Ensure(ll_nth, returns_null_if_the_linkedlist_is_empty)
{
  ll *linkedlist = new_ll(LL_INT);

  llnode *node = ll_nth(linkedlist, 1);
  assert_that(node, is_null);

  dispose_ll(&linkedlist);
}
// Create a new linked list with length n when n >= 0
// or non-terminating when n < 0 
node_t* new_ll(int n)
{
  if (n == 0)
    return NULL;
  node_t* head = alloca(sizeof(node_t));
  head->val = n;
  head->next = new_ll(n-1);
  return head;
}
Esempio n. 4
0
Ensure(ll_traverse, adds_new_nodes_in_front_of_the_ll_properly)
{
  ll *linkedlist = new_ll(LL_INT);

  int i;
  for(i = 0; i < NUM_OF_NODES; i++)
    ll_addfront(linkedlist, &i, NULL);

  int counter = 0;
  ll_traverse(linkedlist, increment, &counter);

  assert_that(counter, is_equal_to(linkedlist->len));
  dispose_ll(&linkedlist);
}
Esempio n. 5
0
Ensure(ll_nth, works_with_negative_n)
{
  ll *linkedlist = new_ll(LL_INT);

  int i;
  for(i = 0; i < NUM_OF_NODES; i++)
    ll_addback(linkedlist, &i, NULL);

  llnode *node = NULL;
  for(i = -1; i >= -NUM_OF_NODES; i--){
    node = ll_nth(linkedlist, i);
    assert_that(node->ikey, is_equal_to(i + NUM_OF_NODES));
  }

  dispose_ll(&linkedlist);
}
Esempio n. 6
0
Ensure(ll_nth, retunrs_the_right_node)
{
  ll *linkedlist = new_ll(LL_INT);

  int i;
  for(i = 0; i < NUM_OF_NODES; i++)
    ll_addback(linkedlist, &i, NULL);

  llnode *node = NULL;

  for(i = 0; i < NUM_OF_NODES; i++){
    node = ll_nth(linkedlist, i);
    assert_that(node->ikey, is_equal_to(i));
  }

  dispose_ll(&linkedlist);
}
Esempio n. 7
0
Ensure(ll_nth, returns_null_if_the_n_is_out_of_the_boundary)
{
  ll *linkedlist = new_ll(LL_INT);

  int i;
  for(i = 0; i < NUM_OF_NODES; i++)
    ll_addback(linkedlist, &i, NULL);

  llnode *node = NULL;
  node = ll_nth(linkedlist, NUM_OF_NODES);
  assert_that(node, is_null);

  node = ll_nth(linkedlist, -NUM_OF_NODES - 1);
  assert_that(node, is_null);

  dispose_ll(&linkedlist);
}
void main ()
{
  int n = __VERIFIER_nondet_int();
  node_t* head = new_ll(abs(n));
}