test/test_physfs.c
changeset 538 8752e3c0dbf9
parent 528 4d84e1994edb
child 588 9f398d3d84a3
equal deleted inserted replaced
537:938e33391878 538:8752e3c0dbf9
   295     {
   295     {
   296         args++;
   296         args++;
   297         args[strlen(args) - 1] = '\0';
   297         args[strlen(args) - 1] = '\0';
   298     } /* if */
   298     } /* if */
   299 
   299 
   300     do_buffer_size = atoi(args);
   300     do_buffer_size = (unsigned int) atoi(args);
   301     if (do_buffer_size)
   301     if (do_buffer_size)
   302     {
   302     {
   303         printf("Further tests will set a (%lu) size buffer.\n",
   303         printf("Further tests will set a (%lu) size buffer.\n",
   304                 (unsigned long) do_buffer_size);
   304                 (unsigned long) do_buffer_size);
   305     } /* if */
   305     } /* if */
   348                 PHYSFS_delete("test.txt");
   348                 PHYSFS_delete("test.txt");
   349                 return(1);
   349                 return(1);
   350             } /* if */
   350             } /* if */
   351 
   351 
   352             strcpy(buf, "abcdefghijklmnopqrstuvwxyz0123456789");
   352             strcpy(buf, "abcdefghijklmnopqrstuvwxyz0123456789");
   353             srand(time(NULL));
   353             srand((unsigned int) time(NULL));
   354 
   354 
   355             for (i = 0; i < 10; i++)
   355             for (i = 0; i < 10; i++)
   356             {
   356             {
   357                 for (j = 0; j < 10000; j++)
   357                 for (j = 0; j < 10000; j++)
   358                 {
   358                 {
   359                     int right = 1 + (int) (35.0 * rand() / (RAND_MAX + 1.0));
   359                     PHYSFS_uint32 right = 1 + (PHYSFS_uint32) (35.0 * rand() / (RAND_MAX + 1.0));
   360                     int left = 36 - right;
   360                     PHYSFS_uint32 left = 36 - right;
   361                     if (PHYSFS_write(f, buf, left, 1) != 1)
   361                     if (PHYSFS_write(f, buf, left, 1) != 1)
   362                     {
   362                     {
   363                         printf("PHYSFS_write() failed: %s.\n", PHYSFS_getLastError());
   363                         printf("PHYSFS_write() failed: %s.\n", PHYSFS_getLastError());
   364                         PHYSFS_close(f);
   364                         PHYSFS_close(f);
   365                         return(1);
   365                         return(1);
   427 
   427 
   428             for (i = 0; i < 10; i++)
   428             for (i = 0; i < 10; i++)
   429             {
   429             {
   430                 for (j = 0; j < 10000; j++)
   430                 for (j = 0; j < 10000; j++)
   431                 {
   431                 {
   432                     int right = 1 + (int) (35.0 * rand() / (RAND_MAX + 1.0));
   432                     PHYSFS_uint32 right = 1 + (PHYSFS_uint32) (35.0 * rand() / (RAND_MAX + 1.0));
   433                     int left = 36 - right;
   433                     PHYSFS_uint32 left = 36 - right;
   434                     if (PHYSFS_read(f, buf2, left, 1) != 1)
   434                     if (PHYSFS_read(f, buf2, left, 1) != 1)
   435                     {
   435                     {
   436                         printf("PHYSFS_read() failed: %s.\n", PHYSFS_getLastError());
   436                         printf("PHYSFS_read() failed: %s.\n", PHYSFS_getLastError());
   437                         PHYSFS_close(f);
   437                         PHYSFS_close(f);
   438                         return(1);
   438                         return(1);