giftcurs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[giFTcurs-commits] giFTcurs/src test_list.c


From: Göran Weinholt
Subject: [giFTcurs-commits] giFTcurs/src test_list.c
Date: Tue, 04 Nov 2003 18:01:33 -0500

CVSROOT:        /cvsroot/giftcurs
Module name:    giFTcurs
Branch:         
Changes by:     Göran Weinholt <address@hidden> 03/11/04 18:01:33

Modified files:
        src            : test_list.c 

Log message:
        Make test_list use glib's random routines.

Patches:
Index: giFTcurs/src/test_list.c
diff -u giFTcurs/src/test_list.c:1.4 giFTcurs/src/test_list.c:1.5
--- giFTcurs/src/test_list.c:1.4        Tue Jul 22 19:58:37 2003
+++ giFTcurs/src/test_list.c    Tue Nov  4 18:01:32 2003
@@ -18,14 +18,12 @@
  * along with giFTcurs; if not, write to the Free Software Foundation,
  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,  USA.
  *
- * $Id: test_list.c,v 1.4 2003/07/22 23:58:37 weinholt Exp $
+ * $Id: test_list.c,v 1.5 2003/11/04 23:01:32 weinholt Exp $
  */
 #include "giftcurs.h"
 
-#include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <math.h>
 #include <time.h>
 
 #include "list.h"
@@ -71,16 +69,15 @@
        clock_t date;
        int i;
        int ints[N];
+       GRand *rand = g_rand_new();
 
        printf("-----Test with all elements unique---------\n");
-       srand(time(NULL));
-       srandom(time(NULL));
 
        list_initialize(&l);
        printf("Generating %d random elements...", N);
        START;
        for (i = 0; i < N; i++)
-               ints[i] = random();
+               ints[i] = g_rand_int(rand);
        STOP;
 
        printf("Inserting %d elements in list...", N);
@@ -125,7 +122,7 @@
        printf("Changing and resorting %d elements...", M);
        START;
        for (i = 0; i < N; i += N / M) {
-               *(int *) list_index(&l, i) = random();
+               *(int *) list_index(&l, i) = g_rand_int(rand);
                list_resort(&l, i);
        }
        PAUSE;
@@ -138,12 +135,11 @@
        list_remove_all(&l);
        list_sort(&l, NULL);
        printf("-----Test with many equal elements---------\n");
-       srand(time(NULL));
 
        printf("Generating %d random elements...", N);
        START;
        for (i = 0; i < N; i++)
-               ints[i] = rand() % 16;
+               ints[i] = g_rand_int_range(rand, 0, 15);
        STOP;
 
        printf("Inserting %d elements in list...", N);
@@ -187,7 +183,7 @@
        printf("Changing and resorting %d elements...", M);
        START;
        for (i = 0; i < N; i += N / M) {
-               *(int *) list_index(&l, i) = rand() % 16;
+               *(int *) list_index(&l, i) = g_rand_int_range(rand, 0, 15);
                list_resort(&l, i);
        }
        PAUSE;
@@ -196,5 +192,7 @@
                return 1;
        }
        REPORT;
+       
+       g_rand_free(rand);
        return 0;
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]