genericopenlibs/liboil/tsrc/testsuite/random/src/random.c
changeset 59 09fa7c3c5079
child 72 403e7f6ed6c5
equal deleted inserted replaced
52:bf6a71c50e42 59:09fa7c3c5079
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <liboil/liboil.h>
       
    20 #include <liboil/liboilfunction.h>
       
    21 #include <stdio.h>
       
    22 #include <stdlib.h>
       
    23 
       
    24 #include <liboil/globals.h>
       
    25 
       
    26 #define LOG_FILE "c:\\logs\\testsuite_random_log.txt"
       
    27 #include "std_log_result.h"
       
    28 #define LOG_FILENAME_LINE __FILE__, __LINE__
       
    29 
       
    30 #define SIZE    20
       
    31 
       
    32 void create_xml(int result)
       
    33 {
       
    34     if(result)
       
    35         assert_failed = 1;
       
    36     
       
    37     testResultXml("testsuite_random");
       
    38     close_log_file();
       
    39 }
       
    40 
       
    41 void test_oil_random_s64()
       
    42     {
       
    43     int i = 0;
       
    44     int pos = SIZE;
       
    45     
       
    46     oil_type_s64 output1[SIZE];
       
    47     oil_type_s64 output2[SIZE];
       
    48     
       
    49     oil_random_s64(output1, SIZE);
       
    50     oil_random_s64(output2, SIZE);
       
    51     
       
    52     for(i=0; i<SIZE; i++)
       
    53         {
       
    54         if(output1[i] != output2[i])
       
    55             pos = i;
       
    56         }
       
    57     
       
    58     if(pos == SIZE)
       
    59         {
       
    60         std_log(LOG_FILENAME_LINE,"oil_random_s64 returns same array everytime");
       
    61         assert_failed = 1;
       
    62         }
       
    63     }
       
    64 
       
    65 void test_oil_random_u64()
       
    66     {
       
    67     int i = 0;
       
    68     int pos = SIZE;
       
    69     
       
    70     oil_type_u64 output1[SIZE];
       
    71     oil_type_u64 output2[SIZE];
       
    72     
       
    73     oil_random_u64(output1, SIZE);
       
    74     oil_random_u64(output2, SIZE);
       
    75     
       
    76     for(i=0; i<SIZE; i++)
       
    77         {
       
    78         if(output1[i] != output2[i])
       
    79             pos = i;
       
    80         }
       
    81     
       
    82     if(pos == SIZE)
       
    83         {
       
    84         std_log(LOG_FILENAME_LINE,"oil_random_s64 returns same array everytime");
       
    85         assert_failed = 1;
       
    86         }
       
    87     }
       
    88 
       
    89 int main (int argc, char *argv[])
       
    90 {
       
    91   oil_init ();
       
    92 
       
    93   test_oil_random_s64();
       
    94   test_oil_random_u64();
       
    95   
       
    96   if(assert_failed)
       
    97       std_log(LOG_FILENAME_LINE,"Test Failed");
       
    98   else
       
    99       std_log(LOG_FILENAME_LINE,"Test Successful");
       
   100 
       
   101   create_xml(0);
       
   102   return 0;
       
   103 }
       
   104