apicompatanamdw/bcdrivers/os/ossrv/glib/tests/queue-test.c
author shrivatsa
Fri, 27 Aug 2010 14:37:16 +0530
changeset 8 d8ef7a232001
parent 2 0cb2248d0edc
permissions -rw-r--r--
Added Classic UI test cases. Fixes to other existing test cases.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
     1
/*
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
     3
* All rights reserved.
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
     4
* This component and the accompanying materials are made available
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
     6
* which accompanies this distribution, and is available
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
     8
*
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
     9
* Initial Contributors:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    11
*
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    12
* Contributors:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    13
*
8
d8ef7a232001 Added Classic UI test cases. Fixes to other existing test cases.
shrivatsa
parents: 2
diff changeset
    14
* Description: 
2
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    15
*
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    16
*/
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    17
#undef G_DISABLE_ASSERT
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    18
#undef G_LOG_DOMAIN
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    19
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    20
#ifdef HAVE_CONFIG_H
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    21
#  include <config.h>
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    22
#endif
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    23
#include <glib.h>
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    24
#include <time.h>
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    25
#include <stdlib.h>
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    26
#include <stdio.h>
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    27
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    28
#ifdef SYMBIAN
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    29
#include "mrt2_glib2_test.h"
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    30
#endif /*SYMBIAN*/
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    31
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    32
#include <glib.h>
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    33
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    34
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    35
static gboolean verbose = FALSE;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    36
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    37
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    38
static void
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    39
check_integrity (GQueue *queue)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    40
{
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    41
  GList *list;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    42
  GList *last;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    43
  GList *links;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    44
  GList *link;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    45
  gint n;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    46
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    47
  g_assert (queue->length < 4000000000u);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    48
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    49
  g_assert (g_queue_get_length (queue) == queue->length);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    50
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    51
  if (!queue->head)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    52
    g_assert (!queue->tail);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    53
  if (!queue->tail)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    54
    g_assert (!queue->head);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    55
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    56
  n = 0;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    57
  last = NULL;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    58
  for (list = queue->head; list != NULL; list = list->next)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    59
    {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    60
      if (!list->next)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    61
	last = list;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    62
      ++n;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    63
    }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    64
  g_assert (n == queue->length); 
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    65
  g_assert (last == queue->tail);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    66
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    67
  n = 0;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    68
  last = NULL;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    69
  for (list = queue->tail; list != NULL; list = list->prev)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    70
    {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    71
      if (!list->prev)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    72
	last = list;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    73
      ++n;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    74
    }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    75
  g_assert (n == queue->length);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    76
  g_assert (last == queue->head);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    77
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    78
  links = NULL;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    79
  for (list = queue->head; list != NULL; list = list->next)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    80
    links = g_list_prepend (links, list);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    81
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    82
  link = links;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    83
  for (list = queue->tail; list != NULL; list = list->prev)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    84
    {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    85
      g_assert (list == link->data);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    86
      link = link->next;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    87
    }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    88
  g_list_free (links);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    89
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    90
  links = NULL;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    91
  for (list = queue->tail; list != NULL; list = list->prev)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    92
    links = g_list_prepend (links, list);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    93
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    94
  link = links;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    95
  for (list = queue->head; list != NULL; list = list->next)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    96
    {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    97
      g_assert (list == link->data);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    98
      link = link->next;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    99
    }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   100
  g_list_free (links);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   101
}
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   102
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   103
static gboolean
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   104
rnd_bool (void)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   105
{
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   106
  return g_random_int_range (0, 2);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   107
}
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   108
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   109
static void
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   110
check_max (gpointer elm, gpointer user_data)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   111
{
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   112
  gint *best = user_data;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   113
  gint element = GPOINTER_TO_INT (elm);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   114
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   115
  if (element > *best)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   116
    *best = element;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   117
}
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   118
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   119
static void
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   120
check_min (gpointer elm, gpointer user_data)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   121
{
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   122
  gint *best = user_data;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   123
  gint element = GPOINTER_TO_INT (elm);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   124
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   125
  if (element < *best)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   126
    *best = element;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   127
}
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   128
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   129
static gint
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   130
find_min (GQueue *queue)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   131
{
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   132
  gint min = G_MAXINT;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   133
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   134
  g_queue_foreach (queue, check_min, &min);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   135
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   136
  return min;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   137
}
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   138
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   139
static gint
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   140
find_max (GQueue *queue)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   141
{
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   142
  gint max = G_MININT;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   143
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   144
  g_queue_foreach (queue, check_max, &max);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   145
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   146
  return max;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   147
}
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   148
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   149
static void
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   150
delete_elm (gpointer elm, gpointer user_data)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   151
{
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   152
  g_queue_remove ((GQueue *)user_data, elm);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   153
  check_integrity ((GQueue *)user_data);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   154
}
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   155
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   156
static void
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   157
delete_all (GQueue *queue)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   158
{
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   159
  g_queue_foreach (queue, delete_elm, queue);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   160
}
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   161
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   162
static int
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   163
compare_int (gconstpointer a, gconstpointer b, gpointer data)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   164
{
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   165
  int ai = GPOINTER_TO_INT (a);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   166
  int bi = GPOINTER_TO_INT (b);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   167
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   168
  if (ai > bi)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   169
    return 1;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   170
  else if (ai == bi)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   171
    return 0;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   172
  else
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   173
    return -1;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   174
}
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   175
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   176
static gint
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   177
get_random_position (GQueue *queue, gboolean allow_offlist)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   178
{
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   179
  int n;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   180
  enum { OFF_QUEUE, HEAD, TAIL, MIDDLE, LAST } where;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   181
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   182
  if (allow_offlist)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   183
    where = g_random_int_range (OFF_QUEUE, LAST);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   184
  else
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   185
    where = g_random_int_range (HEAD, LAST);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   186
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   187
  switch (where)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   188
    {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   189
    case OFF_QUEUE:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   190
      n = g_random_int ();
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   191
      break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   192
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   193
    case HEAD:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   194
      n = 0;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   195
      break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   196
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   197
    case TAIL:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   198
      if (allow_offlist)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   199
	n = queue->length;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   200
      else
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   201
	n = queue->length - 1;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   202
      break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   203
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   204
    case MIDDLE:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   205
      if (queue->length == 0)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   206
	n = 0;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   207
      else
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   208
	n = g_random_int_range (0, queue->length);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   209
      break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   210
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   211
    default:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   212
      g_assert_not_reached();
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   213
      n = 100;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   214
      break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   215
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   216
    }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   217
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   218
  return n;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   219
}
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   220
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   221
static void
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   222
random_test (int seed)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   223
{
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   224
  typedef enum {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   225
    IS_EMPTY, GET_LENGTH, REVERSE, COPY,
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   226
    FOREACH, FIND, FIND_CUSTOM, SORT,
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   227
    PUSH_HEAD, PUSH_TAIL, PUSH_NTH, POP_HEAD,
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   228
    POP_TAIL, POP_NTH, PEEK_HEAD, PEEK_TAIL,
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   229
    PEEK_NTH, INDEX, REMOVE, REMOVE_ALL,
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   230
    INSERT_BEFORE, INSERT_AFTER, INSERT_SORTED, PUSH_HEAD_LINK,
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   231
    PUSH_TAIL_LINK, PUSH_NTH_LINK, POP_HEAD_LINK, POP_TAIL_LINK,
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   232
    POP_NTH_LINK, PEEK_HEAD_LINK, PEEK_TAIL_LINK, PEEK_NTH_LINK,
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   233
    LINK_INDEX, UNLINK, DELETE_LINK, LAST_OP
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   234
  } QueueOp;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   235
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   236
#define N_ITERATIONS 500
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   237
#define N_QUEUES 3
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   238
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   239
#define RANDOM_QUEUE() &(queues[g_random_int_range(0, N_QUEUES)])
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   240
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   241
  typedef struct QueueInfo QueueInfo;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   242
  struct QueueInfo
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   243
  {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   244
    GQueue *queue;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   245
    GList *tail;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   246
    GList *head;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   247
    guint length;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   248
  };
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   249
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   250
  gint i;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   251
  QueueOp op;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   252
  QueueInfo queues[N_QUEUES];
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   253
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   254
  if (verbose)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   255
    g_print ("seed: %d\n", seed);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   256
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   257
  g_random_set_seed (seed);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   258
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   259
  for (i = 0; i < N_QUEUES; ++i)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   260
    {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   261
      queues[i].queue = g_queue_new ();
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   262
      queues[i].head = NULL;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   263
      queues[i].tail = NULL;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   264
      queues[i].length = 0;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   265
    }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   266
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   267
  for (i = 0; i < N_ITERATIONS; ++i)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   268
    {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   269
      int j;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   270
      QueueInfo *qinf = RANDOM_QUEUE();
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   271
      GQueue *q = qinf->queue;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   272
      op = g_random_int_range (IS_EMPTY, LAST_OP);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   273
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   274
      g_assert (qinf->head == q->head);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   275
      g_assert (qinf->tail == q->tail);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   276
      g_assert (qinf->length == q->length);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   277
      
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   278
      switch (op)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   279
	{
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   280
	case IS_EMPTY:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   281
	  {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   282
	    if (g_queue_is_empty (qinf->queue))
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   283
	      {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   284
		g_assert (q->head == NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   285
		g_assert (q->tail == NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   286
		g_assert (q->length == 0);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   287
	      }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   288
	    else
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   289
	      {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   290
		g_assert (q->head);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   291
		g_assert (q->tail);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   292
		g_assert (q->length > 0);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   293
	      }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   294
	  }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   295
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   296
	case GET_LENGTH:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   297
	  {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   298
	    int l;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   299
	    
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   300
	    l = g_queue_get_length (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   301
	    
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   302
	    g_assert (qinf->length == q->length);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   303
	    g_assert (qinf->length == l);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   304
	  }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   305
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   306
	case REVERSE:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   307
	  g_queue_reverse (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   308
	  g_assert (qinf->tail == q->head);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   309
	  g_assert (qinf->head == q->tail);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   310
	  g_assert (qinf->length == q->length);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   311
	  qinf->tail = q->tail;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   312
	  qinf->head = q->head;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   313
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   314
	case COPY:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   315
	  {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   316
	    QueueInfo *random_queue = RANDOM_QUEUE();
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   317
	    GQueue *new_queue = g_queue_copy (random_queue->queue);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   318
	    
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   319
	    g_queue_free (qinf->queue);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   320
	    q = qinf->queue = new_queue;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   321
	    qinf->head = new_queue->head;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   322
	    qinf->tail = g_list_last (new_queue->head);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   323
	    qinf->length = new_queue->length;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   324
	  }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   325
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   326
	case FOREACH:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   327
	  delete_all (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   328
	  qinf->head = NULL;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   329
	  qinf->tail = NULL;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   330
	  qinf->length = 0;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   331
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   332
	case FIND:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   333
	  {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   334
	    gboolean find_existing = rnd_bool ();
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   335
	    int first = find_max (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   336
	    int second = find_min (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   337
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   338
	    if (q->length == 0)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   339
	      find_existing = FALSE;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   340
	    
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   341
	    if (!find_existing)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   342
	      first++;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   343
	    if (!find_existing)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   344
	      second--;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   345
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   346
	    if (find_existing)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   347
	      {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   348
		g_assert (g_queue_find (q, GINT_TO_POINTER (first)));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   349
		g_assert (g_queue_find (q, GINT_TO_POINTER (second)));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   350
	      }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   351
	    else
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   352
	      {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   353
		g_assert (!g_queue_find (q, GINT_TO_POINTER (first)));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   354
		g_assert (!g_queue_find (q, GINT_TO_POINTER (second)));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   355
	      }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   356
	  }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   357
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   358
	case FIND_CUSTOM:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   359
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   360
	case SORT:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   361
	  {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   362
	    if (!g_queue_is_empty (q))
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   363
	      {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   364
		int max = find_max (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   365
		int min = find_min (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   366
		g_queue_remove_all (q, GINT_TO_POINTER (max));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   367
		check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   368
		g_queue_remove_all (q, GINT_TO_POINTER (min));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   369
		check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   370
		g_queue_push_head (q, GINT_TO_POINTER (max));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   371
		if (max != min)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   372
		  g_queue_push_head (q, GINT_TO_POINTER (min));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   373
		qinf->length = q->length;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   374
	      }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   375
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   376
	    check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   377
	    
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   378
	    g_queue_sort (q, compare_int, NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   379
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   380
	    check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   381
	    
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   382
	    qinf->head = g_queue_find (q, GINT_TO_POINTER (find_min(q)));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   383
	    qinf->tail = g_queue_find (q, GINT_TO_POINTER (find_max(q)));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   384
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   385
	    g_assert (qinf->tail == q->tail);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   386
	  }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   387
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   388
	case PUSH_HEAD:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   389
	  {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   390
	    int x = g_random_int_range (0, 435435);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   391
	    g_queue_push_head (q, GINT_TO_POINTER (x));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   392
	    if (!qinf->head)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   393
	      qinf->tail = qinf->head = q->head;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   394
	    else
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   395
	      qinf->head = qinf->head->prev;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   396
	    qinf->length++;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   397
	  }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   398
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   399
	case PUSH_TAIL:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   400
	  {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   401
	    int x = g_random_int_range (0, 236546);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   402
	    g_queue_push_tail (q, GINT_TO_POINTER (x));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   403
	    if (!qinf->tail)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   404
	      qinf->tail = qinf->head = q->head;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   405
	    else
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   406
	      qinf->tail = qinf->tail->next;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   407
	    qinf->length++;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   408
	  }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   409
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   410
	case PUSH_NTH:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   411
	  {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   412
	    int pos = get_random_position (q, TRUE);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   413
	    int x = g_random_int_range (0, 236546);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   414
	    g_queue_push_nth (q, GINT_TO_POINTER (x), pos);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   415
	    if (qinf->head && qinf->head->prev)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   416
	      qinf->head = qinf->head->prev;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   417
	    else
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   418
	      qinf->head = q->head;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   419
	    if (qinf->tail && qinf->tail->next)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   420
	      qinf->tail = qinf->tail->next;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   421
	    else
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   422
	      qinf->tail = g_list_last (qinf->head);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   423
	    qinf->length++;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   424
	  }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   425
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   426
	case POP_HEAD:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   427
	  if (qinf->head)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   428
	    qinf->head = qinf->head->next;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   429
	  if (!qinf->head)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   430
	    qinf->tail = NULL;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   431
	  qinf->length = (qinf->length == 0)? 0 : qinf->length - 1;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   432
	  g_queue_pop_head (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   433
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   434
	case POP_TAIL:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   435
	  if (qinf->tail)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   436
	    qinf->tail = qinf->tail->prev;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   437
	  if (!qinf->tail)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   438
	    qinf->head = NULL;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   439
	  qinf->length = (qinf->length == 0)? 0 : qinf->length - 1;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   440
	  g_queue_pop_tail (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   441
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   442
	case POP_NTH:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   443
	  if (!g_queue_is_empty (q))
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   444
	    {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   445
	      int n = get_random_position (q, TRUE);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   446
	      gpointer elm = g_queue_peek_nth (q, n);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   447
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   448
	      if (n == q->length - 1)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   449
		qinf->tail = qinf->tail->prev;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   450
	      
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   451
	      if (n == 0)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   452
		qinf->head = qinf->head->next;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   453
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   454
	      if (n >= 0 && n < q->length)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   455
		qinf->length--;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   456
	      
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   457
	      g_assert (elm == g_queue_pop_nth (q, n));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   458
	    }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   459
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   460
	case PEEK_HEAD:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   461
	  if (qinf->head)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   462
	    g_assert (qinf->head->data == g_queue_peek_head (q));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   463
	  else
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   464
	    g_assert (g_queue_peek_head (q) == NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   465
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   466
	case PEEK_TAIL:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   467
	  if (qinf->head)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   468
	    g_assert (qinf->tail->data == g_queue_peek_tail (q));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   469
	  else
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   470
	    g_assert (g_queue_peek_tail (q) == NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   471
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   472
	case PEEK_NTH:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   473
	  if (g_queue_is_empty (q))
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   474
	    {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   475
	      for (j = -10; j < 10; ++j)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   476
		g_assert (g_queue_peek_nth (q, j) == NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   477
	    }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   478
	  else
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   479
	    {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   480
	      GList *list;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   481
	      int n = get_random_position (q, TRUE);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   482
	      if (n < 0 || n >= q->length)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   483
		{
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   484
		  g_assert (g_queue_peek_nth (q, n) == NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   485
		}
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   486
	      else
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   487
		{
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   488
		  list = qinf->head;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   489
		  for (j = 0; j < n; ++j)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   490
		    list = list->next;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   491
		  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   492
		  g_assert (list->data == g_queue_peek_nth (q, n));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   493
		}
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   494
	    }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   495
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   496
	case INDEX:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   497
	case LINK_INDEX:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   498
	  {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   499
	    int x = g_random_int_range (0, 386538);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   500
	    int n;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   501
	    GList *list;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   502
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   503
	    g_queue_remove_all (q, GINT_TO_POINTER (x));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   504
 	    check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   505
	    g_queue_push_tail (q, GINT_TO_POINTER (x));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   506
 	    check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   507
	    g_queue_sort (q, compare_int, NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   508
 	    check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   509
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   510
	    n = 0;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   511
	    for (list = q->head; list != NULL; list = list->next)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   512
	      {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   513
		if (list->data == GINT_TO_POINTER (x))
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   514
		  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   515
		n++;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   516
	      }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   517
	    g_assert (list);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   518
	    g_assert (g_queue_index (q, GINT_TO_POINTER (x)) ==
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   519
		      g_queue_link_index (q, list));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   520
	    g_assert (g_queue_link_index (q, list) == n);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   521
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   522
	    qinf->head = q->head;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   523
	    qinf->tail = q->tail;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   524
	    qinf->length = q->length;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   525
	  }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   526
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   527
	case REMOVE:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   528
	  if (!g_queue_is_empty (q))
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   529
	    g_queue_remove (q, qinf->tail->data);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   530
	  if (!g_queue_is_empty (q))
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   531
	    g_queue_remove (q, qinf->head->data);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   532
	  if (!g_queue_is_empty (q))
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   533
	    g_queue_remove (q, g_queue_peek_nth (q, get_random_position (q, TRUE)));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   534
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   535
	  qinf->head = q->head;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   536
	  qinf->tail = q->tail;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   537
	  qinf->length = q->length;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   538
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   539
	case REMOVE_ALL:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   540
	  if (!g_queue_is_empty (q))
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   541
	    g_queue_remove_all (q, qinf->tail->data);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   542
	  if (!g_queue_is_empty (q))
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   543
	    g_queue_remove_all (q, qinf->head->data);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   544
	  if (!g_queue_is_empty (q))
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   545
	    g_queue_remove_all (q, g_queue_peek_nth (q, get_random_position (q, TRUE)));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   546
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   547
	  qinf->head = q->head;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   548
	  qinf->tail = q->tail;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   549
	  qinf->length = q->length;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   550
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   551
	case INSERT_BEFORE:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   552
	  if (!g_queue_is_empty (q))
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   553
	    {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   554
	      gpointer x = GINT_TO_POINTER (g_random_int_range (0, 386538));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   555
	      
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   556
	      g_queue_insert_before (q, qinf->tail, x);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   557
	      g_queue_insert_before (q, qinf->head, x);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   558
	      g_queue_insert_before (q, g_queue_find (q, x), x);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   559
	    }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   560
	  qinf->head = q->head;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   561
	  qinf->tail = q->tail;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   562
	  qinf->length = q->length;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   563
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   564
	case INSERT_AFTER:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   565
	  if (!g_queue_is_empty (q))
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   566
	    {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   567
	      gpointer x = GINT_TO_POINTER (g_random_int_range (0, 386538));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   568
	      
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   569
	      g_queue_insert_after (q, qinf->tail, x);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   570
	      g_queue_insert_after (q, qinf->head, x);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   571
	      g_queue_insert_after (q, g_queue_find (q, x), x);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   572
	    }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   573
	  qinf->head = q->head;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   574
	  qinf->tail = q->tail;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   575
	  qinf->length = q->length;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   576
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   577
	case INSERT_SORTED:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   578
	  {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   579
	    int max = find_max (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   580
	    int min = find_min (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   581
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   582
	    if (g_queue_is_empty (q))
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   583
	      {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   584
		max = 345;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   585
		min = -12;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   586
	      }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   587
	    
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   588
	    g_queue_sort (q, compare_int, NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   589
 	    check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   590
	    g_queue_insert_sorted (q, GINT_TO_POINTER (max + 1), compare_int, NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   591
 	    check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   592
	    g_assert (GPOINTER_TO_INT (q->tail->data) == max + 1);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   593
	    g_queue_insert_sorted (q, GINT_TO_POINTER (min - 1), compare_int, NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   594
 	    check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   595
	    g_assert (GPOINTER_TO_INT (q->head->data) == min - 1);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   596
	    qinf->head = q->head;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   597
	    qinf->tail = q->tail;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   598
	    qinf->length = q->length;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   599
	  }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   600
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   601
	case PUSH_HEAD_LINK:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   602
	  {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   603
	    GList *link = g_list_prepend (NULL, GINT_TO_POINTER (i));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   604
	    g_queue_push_head_link (q, link);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   605
	    if (!qinf->tail)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   606
	      qinf->tail = link;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   607
	    qinf->head = link;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   608
	    qinf->length++;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   609
	  }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   610
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   611
	case PUSH_TAIL_LINK:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   612
	  {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   613
	    GList *link = g_list_prepend (NULL, GINT_TO_POINTER (i));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   614
	    g_queue_push_tail_link (q, link);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   615
	    if (!qinf->head)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   616
	      qinf->head = link;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   617
	    qinf->tail = link;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   618
	    qinf->length++;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   619
	  }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   620
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   621
	case PUSH_NTH_LINK:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   622
	  {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   623
	    GList *link = g_list_prepend (NULL, GINT_TO_POINTER (i));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   624
	    gint n = get_random_position (q, TRUE);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   625
	    g_queue_push_nth_link (q, n, link);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   626
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   627
	    if (qinf->head && qinf->head->prev)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   628
	      qinf->head = qinf->head->prev;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   629
	    else
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   630
	      qinf->head = q->head;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   631
	    if (qinf->tail && qinf->tail->next)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   632
	      qinf->tail = qinf->tail->next;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   633
	    else
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   634
	      qinf->tail = g_list_last (qinf->head);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   635
	    qinf->length++;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   636
	  }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   637
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   638
	case POP_HEAD_LINK:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   639
	  if (!g_queue_is_empty (q))
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   640
	    {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   641
	      qinf->head = qinf->head->next;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   642
	      if (!qinf->head)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   643
		qinf->tail = NULL;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   644
	      qinf->length--;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   645
	      g_list_free (g_queue_pop_head_link (q));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   646
	    }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   647
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   648
	case POP_TAIL_LINK:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   649
	  if (!g_queue_is_empty (q))
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   650
	    {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   651
	      qinf->tail = qinf->tail->prev;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   652
	      if (!qinf->tail)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   653
		qinf->head = NULL;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   654
	      qinf->length--;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   655
	      g_list_free (g_queue_pop_tail_link (q));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   656
	    }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   657
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   658
	case POP_NTH_LINK:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   659
	  if (g_queue_is_empty (q))
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   660
	    g_assert (g_queue_pop_nth_link (q, 200) == NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   661
	  else
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   662
	    {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   663
	      int n = get_random_position (q, FALSE);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   664
	      
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   665
	      if (n == g_queue_get_length (q) - 1)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   666
		qinf->tail = qinf->tail->prev;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   667
	      
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   668
	      if (n == 0)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   669
		qinf->head = qinf->head->next;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   670
	      
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   671
	      qinf->length--;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   672
	      
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   673
	      g_list_free (g_queue_pop_nth_link (q, n));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   674
	    }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   675
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   676
	case PEEK_HEAD_LINK:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   677
	  if (g_queue_is_empty (q))
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   678
	    g_assert (g_queue_peek_head_link (q) == NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   679
	  else
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   680
	    g_assert (g_queue_peek_head_link (q) == qinf->head);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   681
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   682
	case PEEK_TAIL_LINK:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   683
	  if (g_queue_is_empty (q))
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   684
	    g_assert (g_queue_peek_tail_link (q) == NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   685
	  else
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   686
	    g_assert (g_queue_peek_tail_link (q) == qinf->tail);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   687
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   688
	case PEEK_NTH_LINK:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   689
	  if (g_queue_is_empty(q))
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   690
	    g_assert (g_queue_peek_nth_link (q, 1000) == NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   691
	  else
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   692
	    {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   693
	      gint n = get_random_position (q, FALSE);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   694
	      GList *link;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   695
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   696
	      link = q->head;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   697
	      for (j = 0; j < n; ++j)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   698
		link = link->next;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   699
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   700
	      g_assert (g_queue_peek_nth_link (q, n) == link);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   701
	    }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   702
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   703
	case UNLINK:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   704
	  if (!g_queue_is_empty (q))
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   705
	    {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   706
	      gint n = g_random_int_range (0, g_queue_get_length (q));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   707
	      GList *link;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   708
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   709
	      link = q->head;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   710
	      for (j = 0; j < n; ++j)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   711
		link = link->next;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   712
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   713
	      g_queue_unlink (q, link);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   714
	      check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   715
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   716
	      g_list_free (link);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   717
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   718
	      qinf->head = q->head;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   719
	      qinf->tail = q->tail;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   720
	      qinf->length--;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   721
	    }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   722
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   723
	case DELETE_LINK:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   724
	  if (!g_queue_is_empty (q))
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   725
	    {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   726
	      gint n = g_random_int_range (0, g_queue_get_length (q));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   727
	      GList *link;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   728
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   729
	      link = q->head;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   730
	      for (j = 0; j < n; ++j)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   731
		link = link->next;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   732
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   733
	      g_queue_delete_link (q, link);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   734
	      check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   735
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   736
	      qinf->head = q->head;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   737
	      qinf->tail = q->tail;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   738
	      qinf->length--;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   739
	    }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   740
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   741
	case LAST_OP:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   742
	default:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   743
	  g_assert_not_reached();
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   744
	  break;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   745
	}
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   746
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   747
      if (qinf->head != q->head ||
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   748
	  qinf->tail != q->tail ||
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   749
	  qinf->length != q->length)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   750
	g_print ("op: %d\n", op);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   751
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   752
      g_assert (qinf->head == q->head);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   753
      g_assert (qinf->tail == q->tail);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   754
      g_assert (qinf->length == q->length);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   755
      
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   756
      for (j = 0; j < N_QUEUES; ++j)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   757
	check_integrity (queues[j].queue);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   758
    }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   759
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   760
  for (i = 0; i < N_QUEUES; ++i)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   761
    g_queue_free (queues[i].queue);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   762
}
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   763
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   764
static void
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   765
remove_item (gpointer data, gpointer q)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   766
{
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   767
  GQueue *queue = q;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   768
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   769
  g_queue_remove (queue, data);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   770
}
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   771
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   772
int main(int argc, gchar *args[])
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   773
{
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   774
  GQueue *q, *q2;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   775
  GList *node;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   776
  gpointer data;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   777
  int i;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   778
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   779
  #ifdef SYMBIAN
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   780
  g_log_set_handler (NULL,  G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, &mrtLogHandler, NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   781
  g_set_print_handler(mrtPrintHandler);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   782
  #endif /*SYMBIAN*/
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   783
	  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   784
  if (argc > 1 && args[1][0] == '-' && args[1][1] == 'v')
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   785
    verbose = TRUE;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   786
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   787
  q = g_queue_new ();
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   788
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   789
  g_assert (g_queue_is_empty (q) == TRUE);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   790
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   791
  g_queue_push_head (q, GINT_TO_POINTER (2));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   792
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   793
  g_assert (g_queue_peek_head (q) == GINT_TO_POINTER (2));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   794
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   795
  g_assert (g_queue_is_empty (q) == FALSE);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   796
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   797
  g_assert (g_list_length (q->head) == 1);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   798
  g_assert (q->head == q->tail);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   799
  g_queue_push_head (q, GINT_TO_POINTER (1));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   800
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   801
  g_assert (q->head->next == q->tail);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   802
  g_assert (q->tail->prev == q->head);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   803
  g_assert (g_list_length (q->head) == 2);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   804
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   805
  g_assert (q->tail->data == GINT_TO_POINTER (2));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   806
  g_assert (q->head->data == GINT_TO_POINTER (1));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   807
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   808
  g_queue_push_tail (q, GINT_TO_POINTER (3));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   809
  g_assert (g_list_length (q->head) == 3);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   810
  g_assert (q->head->data == GINT_TO_POINTER (1));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   811
  g_assert (q->head->next->data == GINT_TO_POINTER (2));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   812
  g_assert (q->head->next->next == q->tail);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   813
  g_assert (q->head->next == q->tail->prev);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   814
  g_assert (q->tail->data == GINT_TO_POINTER (3));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   815
  g_queue_push_tail (q, GINT_TO_POINTER (4));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   816
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   817
  g_assert (g_list_length (q->head) == 4);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   818
  g_assert (q->head->data == GINT_TO_POINTER (1));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   819
  g_assert (g_queue_peek_tail (q) == GINT_TO_POINTER (4));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   820
  g_queue_push_tail (q, GINT_TO_POINTER (5));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   821
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   822
  g_assert (g_list_length (q->head) == 5);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   823
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   824
  g_assert (g_queue_is_empty (q) == FALSE);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   825
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   826
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   827
  g_assert (q->length == 5);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   828
  g_assert (q->head->prev == NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   829
  g_assert (q->head->data == GINT_TO_POINTER (1));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   830
  g_assert (q->head->next->data == GINT_TO_POINTER (2));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   831
  g_assert (q->head->next->next->data == GINT_TO_POINTER (3));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   832
  g_assert (q->head->next->next->next->data == GINT_TO_POINTER (4));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   833
  g_assert (q->head->next->next->next->next->data == GINT_TO_POINTER (5));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   834
  g_assert (q->head->next->next->next->next->next == NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   835
  g_assert (q->head->next->next->next->next == q->tail);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   836
  g_assert (q->tail->data == GINT_TO_POINTER (5));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   837
  g_assert (q->tail->prev->data == GINT_TO_POINTER (4));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   838
  g_assert (q->tail->prev->prev->data == GINT_TO_POINTER (3));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   839
  g_assert (q->tail->prev->prev->prev->data == GINT_TO_POINTER (2));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   840
  g_assert (q->tail->prev->prev->prev->prev->data == GINT_TO_POINTER (1));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   841
  g_assert (q->tail->prev->prev->prev->prev->prev == NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   842
  g_assert (q->tail->prev->prev->prev->prev == q->head);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   843
  g_assert (g_queue_peek_tail (q) == GINT_TO_POINTER (5));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   844
  g_assert (g_queue_peek_head (q) == GINT_TO_POINTER (1));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   845
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   846
  g_assert (g_queue_pop_head (q) == GINT_TO_POINTER (1));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   847
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   848
  g_assert (g_list_length (q->head) == 4 && q->length == 4);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   849
  g_assert (g_queue_pop_tail (q) == GINT_TO_POINTER (5));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   850
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   851
  g_assert (g_list_length (q->head) == 3);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   852
  g_assert (g_queue_pop_head_link (q)->data == GINT_TO_POINTER (2));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   853
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   854
  g_assert (g_list_length (q->head) == 2);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   855
  g_assert (g_queue_pop_tail (q) == GINT_TO_POINTER (4));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   856
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   857
  g_assert (g_list_length (q->head) == 1);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   858
  g_assert (g_queue_pop_head_link (q)->data == GINT_TO_POINTER (3));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   859
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   860
  g_assert (g_list_length (q->head) == 0);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   861
  g_assert (g_queue_pop_tail (q) == NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   862
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   863
  g_assert (g_list_length (q->head) == 0);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   864
  g_assert (g_queue_pop_head (q) == NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   865
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   866
  g_assert (g_list_length (q->head) == 0);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   867
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   868
  g_assert (g_queue_is_empty (q) == TRUE);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   869
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   870
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   871
  /************************/
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   872
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   873
  g_queue_push_head (q, GINT_TO_POINTER (1));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   874
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   875
  g_assert (g_list_length (q->head) == 1 && 1 == q->length);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   876
  g_queue_push_head (q, GINT_TO_POINTER (2));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   877
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   878
  g_assert (g_list_length (q->head) == 2 && 2 == q->length);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   879
  g_queue_push_head (q, GINT_TO_POINTER (3));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   880
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   881
  g_assert (g_list_length (q->head) == 3 && 3 == q->length);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   882
  g_queue_push_head (q, GINT_TO_POINTER (4));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   883
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   884
  g_assert (g_list_length (q->head) == 4 && 4 == q->length);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   885
  g_queue_push_head (q, GINT_TO_POINTER (5));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   886
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   887
  g_assert (g_list_length (q->head) == 5 && 5 == q->length);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   888
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   889
  g_assert (g_queue_pop_head (q) == GINT_TO_POINTER (5));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   890
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   891
  g_assert (g_list_length (q->head) == 4);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   892
  node = q->tail;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   893
  g_assert (node == g_queue_pop_tail_link (q));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   894
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   895
  g_assert (g_list_length (q->head) == 3);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   896
  data = q->head->data;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   897
  g_assert (data == g_queue_pop_head (q));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   898
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   899
  g_assert (g_list_length (q->head) == 2);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   900
  g_assert (g_queue_pop_tail (q) == GINT_TO_POINTER (2));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   901
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   902
  g_assert (g_list_length (q->head) == 1);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   903
  g_assert (q->head == q->tail);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   904
  g_assert (g_queue_pop_tail (q) == GINT_TO_POINTER (3));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   905
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   906
  g_assert (g_list_length (q->head) == 0);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   907
  g_assert (g_queue_pop_head (q) == NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   908
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   909
  g_assert (g_queue_pop_head_link (q) == NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   910
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   911
  g_assert (g_list_length (q->head) == 0);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   912
  g_assert (g_queue_pop_tail_link (q) == NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   913
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   914
  g_assert (g_list_length (q->head) == 0);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   915
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   916
  /* */
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   917
  g_queue_reverse (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   918
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   919
  g_assert (g_list_length (q->head) == 0);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   920
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   921
  q2 = g_queue_copy (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   922
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   923
  check_integrity (q2);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   924
  g_assert (g_list_length (q->head) == 0);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   925
  g_assert (g_list_length (q2->head) == 0);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   926
  g_queue_sort (q, compare_int, NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   927
  check_integrity (q2);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   928
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   929
  g_queue_sort (q2, compare_int, NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   930
  check_integrity (q2);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   931
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   932
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   933
  for (i = 0; i < 200; ++i)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   934
    {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   935
      g_queue_push_nth (q, GINT_TO_POINTER (i), i);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   936
      g_assert (g_queue_find (q, GINT_TO_POINTER (i)));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   937
      check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   938
      check_integrity (q2);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   939
    }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   940
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   941
  for (i = 0; i < 200; ++i)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   942
    {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   943
      g_queue_remove (q, GINT_TO_POINTER (i));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   944
      check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   945
      check_integrity (q2);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   946
    }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   947
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   948
  for (i = 0; i < 200; ++i)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   949
    {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   950
      GList *l = g_list_prepend (NULL, GINT_TO_POINTER (i));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   951
      
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   952
      g_queue_push_nth_link (q, i, l);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   953
      check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   954
      check_integrity (q2);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   955
      g_queue_reverse (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   956
      check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   957
      check_integrity (q2);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   958
    }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   959
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   960
  g_queue_free (q2);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   961
  q2 = g_queue_copy (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   962
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   963
  g_queue_foreach (q2, remove_item, q2);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   964
  check_integrity (q2);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   965
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   966
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   967
  /* some checks for off by one errors */  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   968
  g_queue_push_tail (q, GINT_TO_POINTER (1234));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   969
  check_integrity (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   970
  node = g_queue_peek_tail_link (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   971
  g_assert (node != NULL && node->data == GINT_TO_POINTER (1234));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   972
  node = g_queue_peek_nth_link (q, g_queue_get_length (q));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   973
  g_assert (node == NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   974
  node = g_queue_peek_nth_link (q, g_queue_get_length (q) - 1);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   975
  g_assert (node->data == GINT_TO_POINTER (1234));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   976
  node = g_queue_pop_nth_link (q, g_queue_get_length (q));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   977
  g_assert (node == NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   978
  node = g_queue_pop_nth_link (q, g_queue_get_length (q) - 1);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   979
  g_assert (node != NULL && node->data == GINT_TO_POINTER (1234));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   980
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   981
  g_queue_free (q);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   982
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   983
  if (argc > 2 && args[1][0] == '-' && args[1][1] == 'v')
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   984
    random_test (strtol (args[2], NULL, 0));    
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   985
  if (argc > 1)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   986
    random_test (strtol (args[1], NULL, 0));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   987
  else
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   988
    random_test (time (0));  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   989
#ifdef SYMBIAN
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   990
  testResultXml("queue-test");
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   991
#endif /* EMULATOR */
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   992
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   993
  return 0;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   994
}
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   995