genericopenlibs/liboil/tsrc/testsuite/clamp1/src/clamp1.c
changeset 59 09fa7c3c5079
equal deleted inserted replaced
52:bf6a71c50e42 59:09fa7c3c5079
       
     1 // Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 #include <liboil/liboil.h>
       
    18 #include <liboil/liboilfunction.h>
       
    19 #include <stdio.h>
       
    20 #include <stdlib.h>
       
    21 #include <liboil/globals.h>
       
    22 
       
    23 #define SIZE 5
       
    24 
       
    25 #define LOG_FILE "c:\\logs\\testsuite_clamp1_log.txt"
       
    26 #include "std_log_result.h"
       
    27 #define LOG_FILENAME_LINE __FILE__, __LINE__
       
    28 
       
    29 int i;
       
    30 void test_clamp_s8()
       
    31     {
       
    32     int8_t dest[SIZE]={0,0,0,0,0};
       
    33     const int8_t src[SIZE]={2,2,2,2,2},s2_1[SIZE]={14,14,14,14,14},s3_1[SIZE]={1,1,1,1,1};
       
    34     int8_t linux_result[SIZE]={1,1,1,1,1};
       
    35     oil_clamp_s8 (dest,src,SIZE,s2_1,s3_1);
       
    36       for(i=0;i<SIZE;i++)
       
    37           {
       
    38           if(dest[i]!= linux_result[i])
       
    39               {
       
    40               std_log(LOG_FILENAME_LINE,"oil_clamp_s8 Fails \n");
       
    41               assert_failed = 1;
       
    42               break;
       
    43               }
       
    44            }
       
    45     }
       
    46 
       
    47 void test_clamp_u8()
       
    48     {
       
    49     uint8_t dest[SIZE];
       
    50     const uint8_t  src[SIZE]={128,0,20,30,127}, s2_1[SIZE]={1,2,3,4,5}, s3_1[SIZE]={1,2,3,4,5};
       
    51     int8_t linux_result[SIZE]={1,1,1,1,1};
       
    52     oil_clamp_u8 (dest,src,SIZE,s2_1,s3_1);
       
    53       for(i=0;i<SIZE;i++)
       
    54           {
       
    55           if(dest[i]!= linux_result[i])
       
    56               {
       
    57               std_log(LOG_FILENAME_LINE,"oil_clamp_u8 Fails \n");
       
    58               assert_failed = 1;
       
    59               break;
       
    60               }
       
    61            }
       
    62     }
       
    63 
       
    64 void test_clamp_s16()
       
    65     {
       
    66     int16_t dest[SIZE];
       
    67     const int16_t src[SIZE]={2,2,2,2,2},s2_1[SIZE]={14,14,14,14,14},s3_1[SIZE]={10,10,10,10,10};
       
    68     int16_t linux_result[SIZE]={10,10,10,10,10};
       
    69     oil_clamp_s16 (dest,src,SIZE,s2_1,s3_1);
       
    70       for(i=0;i<SIZE;i++)
       
    71           {
       
    72           if(dest[i]!= linux_result[i])
       
    73               {
       
    74               std_log(LOG_FILENAME_LINE,"oil_clamp_s16 Fails \n");
       
    75               assert_failed = 1;
       
    76               break;
       
    77               }
       
    78            }
       
    79     }
       
    80 
       
    81 void test_clamp_u16()
       
    82     {
       
    83     uint16_t dest[SIZE];
       
    84     const uint16_t src[SIZE]={2,2,2,2,2},s2_1[SIZE]={14,14,14,14,14},s3_1[SIZE]={10,10,10,10,10};
       
    85     uint16_t linux_result[SIZE]={10,10,10,10,10};
       
    86     oil_clamp_u16 (dest,src,SIZE,s2_1,s3_1);
       
    87       for(i=0;i<SIZE;i++)
       
    88           {
       
    89           if(dest[i]!= linux_result[i])
       
    90               {
       
    91               std_log(LOG_FILENAME_LINE,"oil_clamp_u16 Fails \n");
       
    92               assert_failed = 1;
       
    93               break;
       
    94               }
       
    95            }
       
    96     }
       
    97 
       
    98 void test_clamp_s32()
       
    99     {
       
   100     int32_t dest[SIZE];
       
   101     const int32_t src[SIZE]={2,2,2,2,2},s2_1[SIZE]={14,14,14,14,14},s3_1[SIZE]={10,10,10,10,10};
       
   102     int32_t linux_result[SIZE]={10,10,10,10,10};
       
   103     oil_clamp_s32 (dest,src,SIZE,s2_1,s3_1);
       
   104       for(i=0;i<SIZE;i++)
       
   105           {
       
   106           if(dest[i]!= linux_result[i])
       
   107               {
       
   108               std_log(LOG_FILENAME_LINE,"oil_clamp_s32 Fails \n");
       
   109               assert_failed = 1;
       
   110               break;
       
   111               }
       
   112            }
       
   113     }
       
   114 
       
   115 void test_clamp_u32()
       
   116     {
       
   117     uint32_t dest[SIZE];
       
   118     const uint32_t  src[SIZE]={128,0,20,30,127}, s2_1[SIZE]={1,2,3,4,5}, s3_1[SIZE]={1,2,3,4,5};
       
   119     uint32_t linux_result[SIZE]={1,1,1,1,1};
       
   120     oil_clamp_u32 (dest,src,SIZE,s2_1,s3_1);
       
   121       for(i=0;i<SIZE;i++)
       
   122           {
       
   123           if(dest[i]!= linux_result[i])
       
   124               {
       
   125               std_log(LOG_FILENAME_LINE,"oil_clamp_u32 Fails \n");
       
   126               assert_failed = 1;
       
   127               break;
       
   128               }
       
   129            }
       
   130     }
       
   131 
       
   132 void test_clamp_f32()
       
   133     {
       
   134     float  dest[5];
       
   135     const float src[SIZE]={2.1,2.1,2.1,2.1,2.1},s2_1[SIZE]={14.1,14.1,14.1,14.1,14.1},s3_1[SIZE]={10.1,10.1,10.1,10.1,10};
       
   136     float linux_result[SIZE]={10.1,10.1,10.1,10.1,10.1};
       
   137     oil_clamp_f32 (dest,src,SIZE,s2_1,s3_1);
       
   138     for(i=0;i<SIZE;i++)
       
   139           {
       
   140           if(dest[i]!= linux_result[i])
       
   141             {
       
   142             std_log(LOG_FILENAME_LINE,"oil_clamp_f32 Fails \n");
       
   143             assert_failed = 1;
       
   144             break;
       
   145             }
       
   146           }
       
   147     }
       
   148 
       
   149 void test_clamp_f64()
       
   150     {
       
   151     double dest[5];
       
   152     const double src[SIZE]={2.1,2.1,2.1,2.1,2.1},s2_1[SIZE]={14.1,14.1,14.1,14.1,14.1},s3_1[SIZE]={10.1,10.1,10.1,10.1,10};
       
   153     double linux_result[SIZE]={10.1,10.1,10.1,10.1,10.1};
       
   154     oil_clamp_f64(dest,src,SIZE,s2_1,s3_1);
       
   155     for(i=0;i<SIZE;i++)
       
   156            {
       
   157           if(dest[i]!= linux_result[i])
       
   158             {
       
   159             std_log(LOG_FILENAME_LINE,"oil_clamp_f64 Fails \n");
       
   160             assert_failed = 1;
       
   161             break;
       
   162             }
       
   163            }
       
   164     }
       
   165 
       
   166 void create_xml(int result)
       
   167 {
       
   168     if(result)
       
   169         assert_failed = 1;
       
   170     
       
   171     testResultXml("testsuite_clamp1");
       
   172     close_log_file();
       
   173 }
       
   174 
       
   175 int main (int argc, char *argv[])
       
   176 {
       
   177   std_log(LOG_FILENAME_LINE, "Test Started testsuite_clamp1");
       
   178   oil_init ();
       
   179   
       
   180   test_clamp_s8();
       
   181   test_clamp_u8();
       
   182   test_clamp_s16();
       
   183   test_clamp_u16();
       
   184   test_clamp_s32();
       
   185   test_clamp_u32();
       
   186   test_clamp_f32();
       
   187   test_clamp_f64();
       
   188   if(assert_failed)
       
   189       std_log(LOG_FILENAME_LINE,"Test Fail");
       
   190   else
       
   191       std_log(LOG_FILENAME_LINE,"Test Successful");
       
   192   create_xml(0);
       
   193   return 0;
       
   194 }
       
   195