热爱测试,主要研究性能测试和自动化测试方面的技术,希望与同样对测试有热情的你一同进步成长

LoadRunner中字符串的操作

上一篇 / 下一篇  2008-02-26 10:08:55 / 个人分类:性能测试

51Testing软件测试网{?Bi)MaJc-o/j ~

      LoadRunner中常用的字符串操作函数有:51Testing软件测试网7V?P5^t,^:I#e?

               strcpy(destination_string, source_string);

vvM*eJ(J!G H0

              strcat(string_that_gets_appended, string_that_is_appended);51Testing软件测试网 fI ks u8m

              atoi(string_to_convert_to_int); //returns the integer value

+P` X\fvw5W0

              itoa(integer_to_conver_to_string, destination_string, base); // base is 1051Testing软件测试网*Ry;]D3Va4I.I#}

              strcmp(string1, string2); // returns 0 if both strings are equal

2Z+TL)I&m0B!i;]-B7yV&LE0

对各函数的定义:

$D4b m/cz.j:~#u0

            strcpy( ):拷贝一个字符串到另一个字符串中.

JSK#LU.Q&I Z0

             strcat( ):添加一个字符串到另一个字符串的末尾。51Testing软件测试网CaM+iA7[2qp%y/P6x#]w

            strcmp( ):比较两个字符串,如果相等返回0。51Testing软件测试网1N^U$ID,Jze

            atoi():转换一个ASCII字符串为一个整型。

%T5a{0F)Rc.r0

            itoa():根据给定的进制,转换一个整型数据为ASCII字符串51Testing软件测试网P$o;_5F@;cf

下面的例子使用了上面这些函数:51Testing软件测试网5T7SCt1e`QJy&kP

            

&C)C6N$PS$_jK0

Actions()51Testing软件测试网8t"SIb,za6J0v+s

{

'fC2i7\g0

       char MyString1[20] = "";

.bx2@&BYhtn0

       char MyString2[20] = "";

f+S2_,Z3X`^jy0

       char MyString3[20] = "Mercury2";51Testing软件测试网?{'gD*l(ZjR

       char Cstring[10] = "12345";

w^MMA0

       int Cint;51Testing软件测试网?(Ft[,b

 51Testing软件测试网 ^'v%U(s,r

 

k e yE ?:r8] vA%B-]0

       // MyString1 is empty51Testing软件测试网4`[Tjc/[)\;_

       //51Testing软件测试网i%Ty#E O:ENc,X5Y/pj

       lr_output_message(">>>>>>>>>> MyString1 = %s",MyString1);51Testing软件测试网A*OPxC6u}$_LOg

 51Testing软件测试网.fq4}*Aq-k4A

       // copy "Mercury1" into MyString151Testing软件测试网:h0{5w{d

       //

e#{ f*\6Kg0

       strcpy(MyString1,"Mercury1");51Testing软件测试网AW8[T.r(m?

 51Testing软件测试网q$sMj ]1a-pr X

       // Now MyString1 contains "Mercury1"

+M W C0u |I*J5?0

       //

1? ] W[]m Wn0

       lr_output_message(">>>>>>>>>> MyString1 = %s",MyString1);

~hRs#?5?0

 

/mV&]XZ0

 51Testing软件测试网Ew(DE4@u0[

       // Copy MyString3 into MyString251Testing软件测试网 Q b;E#x6P"V0t1~ m

       //

y P%]T9I0

       lr_output_message(">>>>>>>>>> MyString2 = %s",MyString2);51Testing软件测试网"Wz*Pg pV8B,r&g

       strcpy(MyString2,MyString3);

-WAD4h;W!b0

       lr_output_message(">>>>>>>>>> MyString2 = %s",MyString2);51Testing软件测试网[^:q:@*j$m%gsV[

 

rw#Xe9R:v0

 

+N `oT y|9CqrTpx0

       // Catenate MyString2 to MyString1

pnyg S\0

       //

(V"M ZLI%Mk O0

       strcat(MyString1,MyString2);

&h[U(c p;j-z0iP[0

       lr_output_message(">>>>>>>>>> MyString1 = %s",MyString1);51Testing软件测试网t-l4wn;cs#u

 51Testing软件测试网9O%?{u(p l:_]

       // Cstring is converted to integer Cint

%Y]m6ZqQI a0

       //

eB(as`G'G0

       lr_output_message(">>>>>>>>>> Cstring = %s",Cstring);

y1MI1OI dTsH0

       Cint = atoi(Cstring);

wX;eTk0

       lr_output_message(">>>>>>>>>> Cint = %d",Cint);51Testing软件测试网 C\8J#PBy2z!y,W$e

 

w$W&KV/O,s,p%q0

       // Cint is converted to string51Testing软件测试网T+^[yxS `4D X

       Cint = 100;51Testing软件测试网-]"Kg@ X"j_

       itoa(Cint,Cstring,10);51Testing软件测试网Z S#r*X VR6U:H

       lr_output_message(">>>>>>>>>> Cstring = %s",Cstring);51Testing软件测试网c;b}(fU

 51Testing软件测试网#oSKAd`n3vp

       return 0;

Kc1q{8cf I[0

}

Je9Gz2y0

 51Testing软件测试网2w)uzT'm:Ks3?F$n

51Testing软件测试网W0^L,}"Oz:M?7l;T

 51Testing软件测试网O1x*xG Y@'v


TAG: 性能测试

大熊的个人空间 引用 删除 xbyl1314   /   2010-07-14 13:48:51
-3
 

评分:0

我来说两句

Open Toolbar