os/ossrv/utilitylibraries/libutils/tsrc/src/integration_test_scenario29.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2009 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 #include <stdio.h>
    19 #include<e32std.h>
    20 #include "libutils.h"
    21 #include"std_log_result.h"
    22 #define LOG_FILENAME_LINE __FILE__, __LINE__
    23 #pragma diag_suppress 550
    24 int main()
    25 {
    26     bool assert_failed = false;
    27     __UHEAP_MARK;
    28     {
    29     string src1="testing";
    30     char tempChar[20];
    31     TPtr8 des1((unsigned char*)tempChar,20);
    32     int ret,size1=30,size2=42;
    33     int retval[50];
    34     retval[0] = StringToTptr8(src1, des1);
    35 
    36     TPtr8 src2 = des1;
    37     char *des2= new char[20];
    38     retval[1]= Tptr8ToChar(src2,des2,size1);
    39 
    40     char *src3=des2;
    41     wchar_t *aPtr= new wchar_t[20];
    42     wchar_t temp[30];
    43     TPtrC16 des3((unsigned short *)temp,30);
    44     retval[2]= CharpToTptrc16(src3,aPtr,des3);
    45 
    46     TPtrC16 src4= des3;
    47     string des4="";
    48     retval[3]=Tptrc16ToString(src4,des4);
    49 
    50     string src5=des4;
    51     HBufC16 *des5=HBufC16::NewMaxL(20);
    52     retval[4]= StringToHbufc16(src5,des5);
    53 
    54     HBufC16 *src6=des5;
    55     string des6("");
    56     retval[5]= Hbufc16ToString(src6,des6,size1);
    57 
    58     string src7=des4;
    59     HBufC8 *des7=HBufC8::NewMaxL(20);
    60     retval[6]= StringToHbufc8(src7,des7);
    61 
    62     HBufC8 *src8=des7;
    63     char *des8=new char[20]; 
    64     retval[7]= Hbufc8ToChar(src8,des8,size1);	
    65 
    66     char *src9=des8;
    67     HBufC16 *des9=HBufC16::NewMaxL(20);
    68     retval[8]=CharToHbufc16(src9,des9);
    69 
    70     HBufC16 *src10=des9;
    71     string des10="";
    72     retval[9]= Hbufc16ToString(src10,des10,size2);				
    73 
    74     string src11=des10;
    75     RBuf16 des11;
    76     des11.CreateL(30);
    77     retval[10]= StringToRbuf16(src11,des11);
    78 
    79     RBuf16 src12;
    80     src12.Create(14);
    81     src12.Copy((unsigned short*)des11.Ptr(), 14);
    82     des11.Close();
    83     char *des12=new char[30];
    84     int size3=50;	
    85     retval[11]= Rbuf16ToChar(src12,des12,size3);
    86 
    87     char *src13=des12;
    88     RBuf16 des13;
    89     des13.CreateL(30);
    90     retval[12]=CharToRbuf16(src13,des13);
    91 
    92     string des14;
    93     retval[13]=Rbuf16ToString(des13,des14);
    94 
    95     string src15=des14;
    96     RBuf8 des15;
    97     des15.CreateL(30);
    98     retval[14]= StringToRbuf8(src15,des15);
    99 
   100     RBuf8 src16;
   101     src16.Create(des15);
   102     char * des16= new char[61];
   103     retval[15]=Rbuf8ToChar(src16,des16,size1);
   104 
   105     char *src17=des16;
   106     RBuf16 des17;
   107     des17.CreateL(30);
   108     retval[16]=CharToRbuf16(src17,des17);
   109 
   110     RBuf16 src18;
   111     src18.Create(des17);
   112     wchar_t *des18= new wchar_t[70];
   113     retval[17]=Rbuf16ToWchar(src18,des18,size1);
   114 
   115     wchar_t *src19=des18;
   116     RBuf8 des19;
   117     des19.CreateL(50);
   118     retval[18]=WcharToRbuf8(src19,des19);
   119 
   120     wstring src20;
   121     retval[19] = Rbuf8ToWstring(des19,src20);
   122 
   123     TBuf16 <100> des20;
   124     retval[20] = WstringToTbuf16(src20,des20);
   125 
   126     wchar_t* src21= new wchar_t[100];
   127     int size_new=30;
   128     retval[21] = Tbuf16ToWchar(des20,src21,size_new);
   129 
   130     RBuf16 des21;
   131     des21.CreateL(30);
   132     retval[22]= WcharToRbuf16(src21,des21);
   133 
   134     wstring src22;
   135     retval[23]= Rbuf16ToWstring(des21,src22);
   136 
   137     TBuf16 <100> des22;
   138     retval[24]= WstringToTbuf16(src22,des22);
   139 
   140     wchar_t* src23= new wchar_t[100];
   141     int size=100;
   142     retval[25]= Tbuf16ToWchar(des22,src23,size);
   143 
   144     RBuf8 des23;
   145     des23.CreateL(50);
   146     retval[26]= WcharToRbuf8(src23,des23);
   147 
   148     wstring src24;
   149     retval[27]= Rbuf8ToWstring(des23,src24);
   150 
   151     des23.Close();
   152     TBuf8 <100> des24;
   153     retval[28]= WstringToTbuf8(src24,des24);
   154 
   155     wchar_t* des25 = new wchar_t[150];                
   156     int size8=150;
   157     retval[29]= Tbuf8ToWchar(des24,des25,size8);
   158     
   159     for(int i=1; i<=29; i++)
   160         {
   161         if (retval[i]!= 0)
   162                 printf("Conversion failed for retval\n",retval[i]);
   163         }
   164 
   165     ret= strncmp((char *)src1.c_str(),(char *)des24.Ptr(),7);
   166     if(ret == ESuccess)
   167     {
   168     printf("integration_test_scenario_29 PASSED\n");
   169     }
   170     else
   171     {
   172     printf("integration_test_scenario_29 FAILED\n");
   173     assert_failed=true;
   174     }
   175     delete[] des2;
   176     delete[] des8;
   177     delete[] des12;
   178     delete[] aPtr;
   179     delete[] des16;
   180     delete[] des18;
   181     delete[] src21;
   182     delete[] src23;
   183     delete[] des25;
   184     delete des5;
   185     delete des7;
   186     delete des9;
   187     src12.Close();
   188     des13.Close();
   189     des15.Close();
   190     src16.Close();	
   191     des17.Close();	
   192     src18.Close();	
   193     des19.Close();
   194     des21.Close();
   195     }
   196     __UHEAP_MARKEND;
   197     testResultXml("integration_test_scenario29");
   198     return 0;
   199    
   200 }