码迷,mamicode.com
首页 > 其他好文 > 详细

loadrunner中大小写字符转换函数封装:

时间:2015-06-14 19:45:42      阅读:370      评论:0      收藏:0      [点我收藏+]

标签:

//封装ConvertToXXX函数:

int ConvertToUpper(char * sInput, char * sNew)

{

 sInput = (char *)strupr(sInput);

 lr_save_string(sInput,sNew);

}

 

int ConvertToLower(char * sInput, char * sNew)

{

 sInput = (char *)strlwr(sInput);

 lr_save_string(sInput,sNew);

}

int ConvertToTitle(char * sInput, char * sNew)

{

 int i = 0, s = 0, l = 0;

 char buf1[50];

 char buf2[2];

 char n;


 strncpy(&n,sInput+i,1);

 sprintf(buf2,"%c",n);

 strupr(buf2);

 strcpy(buf1,buf2);

 i++;

 while(i < strlen(sInput))

 {

  strncpy(&n,sInput+i,1);

  sprintf(buf2,"%c",n);



  if(s == 1){

   strupr(buf2);

   strcat(buf1,buf2);

   s = 0;

  }


  else{

   strlwr(buf2);

   strcat(buf1,buf2);

  }



  if(strcmp(" ",buf2)==0)

  {

   s = 1;

  }

  i++;

 }

 lr_save_string(buf1,sNew);

}

技术分享

 

login()
{


 lr_save_string("testing is believing","str");

       ConvertToUpper(lr_eval_string("{str}"),"UpperStr");

       lr_output_message(lr_eval_string("{UpperStr}"));



    ConvertToLower(lr_eval_string("{str}"),"LowerStr");

       lr_output_message(lr_eval_string("{LowerStr}"));

 

       ConvertToTitle(lr_eval_string("{str}"),"TitleStr");

       lr_output_message(lr_eval_string("{TitleStr}"));

 技术分享

loadrunner中大小写字符转换函数封装:

标签:

原文地址:http://www.cnblogs.com/qmfsun/p/4575444.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!