stefan pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=11d695cfcd8b76357d16d21c5ddf4a9d1e8c0e84

commit 11d695cfcd8b76357d16d21c5ddf4a9d1e8c0e84
Author: Mike Blumenkrantz <zm...@osg.samsung.com>
Date:   Thu Mar 29 18:14:53 2018 -0400

    tests: improve eina_test_list_shuffle
    
    reduce iteratons by a hundredfold, remove verifying of rand() seed,
    check whether shuffle actually shuffles
    
    fix T6833
    
    Reviewed-by: Stefan Schmidt <ste...@osg.samsung.com>
---
 src/tests/eina/eina_test_list.c | 41 ++++++++---------------------------------
 1 file changed, 8 insertions(+), 33 deletions(-)

diff --git a/src/tests/eina/eina_test_list.c b/src/tests/eina/eina_test_list.c
index 9fbb3d11f2..e571255f0b 100644
--- a/src/tests/eina/eina_test_list.c
+++ b/src/tests/eina/eina_test_list.c
@@ -389,61 +389,36 @@ EFL_START_TEST(eina_test_list_split)
 }
 EFL_END_TEST
 
-static int uicmp(const void *d1, const void *d2)
-{
-   const unsigned int *a = d1;
-   const unsigned int *b = d2;
-
-   if(*a == *b) return 0;
-   if(*a >  *b) return 1;
-
-   return -1;
-}
-
 #define SHUFFLE_SZ 100
-#define SHUFFLE_N 100000
+#define SHUFFLE_N 5
 EFL_START_TEST(eina_test_list_shuffle)
 {
-   double d;
    unsigned int *p;
-   unsigned int i, j;
+   unsigned int i;
    unsigned int n[SHUFFLE_SZ];
-   unsigned int rand_count[SHUFFLE_SZ];
    Eina_List *list = NULL;
    Eina_List *item = NULL;
+   Eina_List *copy, *cl;
 
 
    for(i = 0; i < SHUFFLE_SZ; i++)
      {
         n[i] = i;
-        rand_count[i] = 0;
         list = eina_list_append(list, &n[i]);
      }
+   copy = eina_list_clone(list);
 
    for(i = 0; i < SHUFFLE_N; i++)
      {
         list = eina_list_shuffle(list, NULL);
-        p = eina_list_nth(list, SHUFFLE_SZ/2);
-        rand_count[*p]++;
-
-        j = 0;
-        list = eina_list_sort(list, 0, (Eina_Compare_Cb)&uicmp);
+        cl = eina_list_data_get(copy);
         EINA_LIST_FOREACH(list, item, p)
           {
-             if (*p != j++)
-               fail_if(*p != j++);
+             if (eina_list_data_get(cl) != p) break;
+             cl = eina_list_next(cl);
           }
-        if (j != SHUFFLE_SZ)
-          fail_if(j != SHUFFLE_SZ);
-     }
-
-   d = SHUFFLE_SZ/(float)(SHUFFLE_N);
-   for(i = 0; i < SHUFFLE_SZ; i++)
-     {
-        fail_if(rand_count[i]*d > 1.20f);
-        fail_if(rand_count[i]*d < 0.80f);
+        ck_assert_ptr_nonnull(item);
      }
-
 }
 EFL_END_TEST
 

-- 


Reply via email to