在LoadRunner中转换字符串大小写的C语言函数
来源:互联网 发布:开淘宝店铺简介怎么写 编辑:程序博客网 时间:2024/05/21 14:01
封装ConvertToXXX函数:
//ConvertToUpper function
int ConvertToUpper(char * sInput, char * sNew)
{
sInput = (char *)strupr(sInput);
lr_save_string(sInput,sNew);
}
//ConvertToLower function
int ConvertToLower(char * sInput, char * sNew)
{
sInput = (char *)strlwr(sInput);
lr_save_string(sInput,sNew);
}
//ConvertToTitle function
int ConvertToTitle(char * sInput, char * sNew)
{
int i = 0, s = 0, l = 0;
char buf1[50];
char buf2[2];
char n;
// Copy a single character into the address of [n]
strncpy(&n,sInput+i,1);
// Copy the single character into buf2
sprintf(buf2,"%c",n);
// Convert the contents of buf2 to uppercase
strupr(buf2);
// Overwrite the contents of buf1 with buf2
strcpy(buf1,buf2);
i++;
while(i < strlen(sInput))
{
// Overwrite buf2 with one character
strncpy(&n,sInput+i,1);
sprintf(buf2,"%c",n);
// If the previous character was a space then make the current character upper case
if(s == 1){
strupr(buf2);
strcat(buf1,buf2);
s = 0;
}
// Otherwise convert to lower case and concatenate the current character into the string buf1
else{
strlwr(buf2);
strcat(buf1,buf2);
}
// If the current character is a space set the value of [s] to [1] so that the next character gets capitalised
if(strcmp(" ",buf2)==0)
{
s = 1;
}
i++;
}
lr_save_string(buf1,sNew);
}
使用ConvertToXXX转换函数:
Action()
{
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}"));
return 0;
}
输出:
Virtual User Script started at : 2010-01-30 17:53:13
Starting action vuser_init.
Web Turbo Replay of LoadRunner 9.50 SP1 for WINXP; WebReplay96 build 7045 (May 27 2009 14:28:58) [MsgId: MMSG-27143]
Run Mode: HTML [MsgId: MMSG-26000]
Run-Time Settings file: "D:/xlsoft/LR/MyTest/ConvertToXXXX//default.cfg" [MsgId: MMSG-27141]
Ending action vuser_init.
Running Vuser...
Starting iteration 1.
Starting action Action.
Action.c(63): TESTING IS BELIEVING
Action.c(66): testing is believing
Action.c(69): Testing Is Believing
Ending action Action.
Ending iteration 1.
Ending Vuser...
Starting action vuser_end.
Ending action vuser_end.
Vuser Terminated.
参考:
http://www.bish.co.uk/index.php?option=com_content&view=article&id=68%3Aloadrunner-c-functions-to-convert-the-case-of-a-captured-string&catid=34%3Arecent&Itemid=1
- 在LoadRunner中转换字符串大小写的C语言函数
- 在Makefile中转换大小写
- LoadRunner中转换字符串到URL编码
- c语言中uchar,在JAVA中转换
- Convert函数在SQL中转换日期
- STL中转换string大小写
- (c语言)字符串的大小写字母转化函数
- C语言 - 忽略大小写比较字符串函数的使用
- C语言 - 字符串大小写转换函数的使用
- java中转换为字符串的方法
- C++中转换函数
- SQL server中转换大小写快捷键
- PL/SQL Developer中转换大小写工具
- SQL server中转换大小写快捷键
- VS Code中转换大小写功能
- Java中转换字符串编码
- LoadRunner中常用的C语言函数
- C语言strcmp()函数:比较字符串(区分大小写)
- dos深入学习
- Can't connect to MySQL server on 'localhost' (10061)解决方法
- Ext之我见
- 对当下兽药营销的思考
- ASP.NET生命周期中的验证以及身份验证模块(理解以后可以自定义验证方法)
- 在LoadRunner中转换字符串大小写的C语言函数
- 迟到的纪念!ccie#25741 !!!
- 创业专家答疑系统
- PB工具Catalog视图与Feature管理(摘录)
- 下载fftw
- BrowserImage.cs
- 发布自己的html parse
- 股海沉浮:牢记股市中最常见的经典底部形态
- 回家前的2009年总结