summaryrefslogtreecommitdiff
path: root/tests/qsort-test.c
blob: 4e119436074f0e3729759c25b7c7a42f6bda7d66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <glib.h>

#define SIZE 100000

guint32 array[SIZE];

static gint
sort (gconstpointer a, gconstpointer b, gpointer user_data)
{
  return *(guint32*)a < *(guint32*)b ? -1 : 1;
}

int
main ()
{
  int i;

  for (i = 0; i < SIZE; i++)
    array[i] = g_random_int ();

  g_qsort_with_data (array, SIZE, sizeof (guint32), sort, NULL);

  for (i = 0; i < SIZE - 1; i++)
    g_assert (array[i] <= array[i+1]);

  return 0;
}