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