1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/liboil/tsrc/testsuite/clamp1/src/clamp1.c Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,195 @@
1.4 +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +
1.20 +#include <liboil/liboil.h>
1.21 +#include <liboil/liboilfunction.h>
1.22 +#include <stdio.h>
1.23 +#include <stdlib.h>
1.24 +#include <liboil/globals.h>
1.25 +
1.26 +#define SIZE 5
1.27 +
1.28 +#define LOG_FILE "c:\\logs\\testsuite_clamp1_log.txt"
1.29 +#include "std_log_result.h"
1.30 +#define LOG_FILENAME_LINE __FILE__, __LINE__
1.31 +
1.32 +int i;
1.33 +void test_clamp_s8()
1.34 + {
1.35 + int8_t dest[SIZE]={0,0,0,0,0};
1.36 + 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};
1.37 + int8_t linux_result[SIZE]={1,1,1,1,1};
1.38 + oil_clamp_s8 (dest,src,SIZE,s2_1,s3_1);
1.39 + for(i=0;i<SIZE;i++)
1.40 + {
1.41 + if(dest[i]!= linux_result[i])
1.42 + {
1.43 + std_log(LOG_FILENAME_LINE,"oil_clamp_s8 Fails \n");
1.44 + assert_failed = 1;
1.45 + break;
1.46 + }
1.47 + }
1.48 + }
1.49 +
1.50 +void test_clamp_u8()
1.51 + {
1.52 + uint8_t dest[SIZE];
1.53 + 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};
1.54 + int8_t linux_result[SIZE]={1,1,1,1,1};
1.55 + oil_clamp_u8 (dest,src,SIZE,s2_1,s3_1);
1.56 + for(i=0;i<SIZE;i++)
1.57 + {
1.58 + if(dest[i]!= linux_result[i])
1.59 + {
1.60 + std_log(LOG_FILENAME_LINE,"oil_clamp_u8 Fails \n");
1.61 + assert_failed = 1;
1.62 + break;
1.63 + }
1.64 + }
1.65 + }
1.66 +
1.67 +void test_clamp_s16()
1.68 + {
1.69 + int16_t dest[SIZE];
1.70 + 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};
1.71 + int16_t linux_result[SIZE]={10,10,10,10,10};
1.72 + oil_clamp_s16 (dest,src,SIZE,s2_1,s3_1);
1.73 + for(i=0;i<SIZE;i++)
1.74 + {
1.75 + if(dest[i]!= linux_result[i])
1.76 + {
1.77 + std_log(LOG_FILENAME_LINE,"oil_clamp_s16 Fails \n");
1.78 + assert_failed = 1;
1.79 + break;
1.80 + }
1.81 + }
1.82 + }
1.83 +
1.84 +void test_clamp_u16()
1.85 + {
1.86 + uint16_t dest[SIZE];
1.87 + 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};
1.88 + uint16_t linux_result[SIZE]={10,10,10,10,10};
1.89 + oil_clamp_u16 (dest,src,SIZE,s2_1,s3_1);
1.90 + for(i=0;i<SIZE;i++)
1.91 + {
1.92 + if(dest[i]!= linux_result[i])
1.93 + {
1.94 + std_log(LOG_FILENAME_LINE,"oil_clamp_u16 Fails \n");
1.95 + assert_failed = 1;
1.96 + break;
1.97 + }
1.98 + }
1.99 + }
1.100 +
1.101 +void test_clamp_s32()
1.102 + {
1.103 + int32_t dest[SIZE];
1.104 + 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};
1.105 + int32_t linux_result[SIZE]={10,10,10,10,10};
1.106 + oil_clamp_s32 (dest,src,SIZE,s2_1,s3_1);
1.107 + for(i=0;i<SIZE;i++)
1.108 + {
1.109 + if(dest[i]!= linux_result[i])
1.110 + {
1.111 + std_log(LOG_FILENAME_LINE,"oil_clamp_s32 Fails \n");
1.112 + assert_failed = 1;
1.113 + break;
1.114 + }
1.115 + }
1.116 + }
1.117 +
1.118 +void test_clamp_u32()
1.119 + {
1.120 + uint32_t dest[SIZE];
1.121 + 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};
1.122 + uint32_t linux_result[SIZE]={1,1,1,1,1};
1.123 + oil_clamp_u32 (dest,src,SIZE,s2_1,s3_1);
1.124 + for(i=0;i<SIZE;i++)
1.125 + {
1.126 + if(dest[i]!= linux_result[i])
1.127 + {
1.128 + std_log(LOG_FILENAME_LINE,"oil_clamp_u32 Fails \n");
1.129 + assert_failed = 1;
1.130 + break;
1.131 + }
1.132 + }
1.133 + }
1.134 +
1.135 +void test_clamp_f32()
1.136 + {
1.137 + float dest[5];
1.138 + 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};
1.139 + float linux_result[SIZE]={10.1,10.1,10.1,10.1,10.1};
1.140 + oil_clamp_f32 (dest,src,SIZE,s2_1,s3_1);
1.141 + for(i=0;i<SIZE;i++)
1.142 + {
1.143 + if(dest[i]!= linux_result[i])
1.144 + {
1.145 + std_log(LOG_FILENAME_LINE,"oil_clamp_f32 Fails \n");
1.146 + assert_failed = 1;
1.147 + break;
1.148 + }
1.149 + }
1.150 + }
1.151 +
1.152 +void test_clamp_f64()
1.153 + {
1.154 + double dest[5];
1.155 + 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};
1.156 + double linux_result[SIZE]={10.1,10.1,10.1,10.1,10.1};
1.157 + oil_clamp_f64(dest,src,SIZE,s2_1,s3_1);
1.158 + for(i=0;i<SIZE;i++)
1.159 + {
1.160 + if(dest[i]!= linux_result[i])
1.161 + {
1.162 + std_log(LOG_FILENAME_LINE,"oil_clamp_f64 Fails \n");
1.163 + assert_failed = 1;
1.164 + break;
1.165 + }
1.166 + }
1.167 + }
1.168 +
1.169 +void create_xml(int result)
1.170 +{
1.171 + if(result)
1.172 + assert_failed = 1;
1.173 +
1.174 + testResultXml("testsuite_clamp1");
1.175 + close_log_file();
1.176 +}
1.177 +
1.178 +int main (int argc, char *argv[])
1.179 +{
1.180 + std_log(LOG_FILENAME_LINE, "Test Started testsuite_clamp1");
1.181 + oil_init ();
1.182 +
1.183 + test_clamp_s8();
1.184 + test_clamp_u8();
1.185 + test_clamp_s16();
1.186 + test_clamp_u16();
1.187 + test_clamp_s32();
1.188 + test_clamp_u32();
1.189 + test_clamp_f32();
1.190 + test_clamp_f64();
1.191 + if(assert_failed)
1.192 + std_log(LOG_FILENAME_LINE,"Test Fail");
1.193 + else
1.194 + std_log(LOG_FILENAME_LINE,"Test Successful");
1.195 + create_xml(0);
1.196 + return 0;
1.197 +}
1.198 +