[SilkTest]关于ANYTYPE的处理
上一篇 / 下一篇 2009-03-14 22:50:59 / 精华(2) / 个人分类:蓝天测试
前几天,一朋友问到如何处理SilkTest中参数的ANYTYPE类型的问题,其实这个很方便,用TypeOf就可以区分,后来他又问到如何区分LIST OF ANYTYPE和LIST OF LIST ANYTYPE的问题,在这两者的区分上或许存在着一点小小的技巧,而且在实际项目中也经常会遇到在一个函数用处理多种/复杂的数据类型,因此想把这段代码分享给大家,希望对大家有点用处。51Testing软件测试网+D#v2`U e;A2J R
函数代码:
:hTT c ujuOM0 [+]VOID GetDataType (ANYTYPE atType)51Testing软件测试网2e/[lR$i
[+] //Desc&History51Testing软件测试网Q n{GHt
[ ] //**********************************************************
.L,Jjlj4g8H'^0 [ ] // Function Name: GetDataType51Testing软件测试网 asDy/a^mqL$b
[ ] // Description: The example of handling any data type
f|k#vw1W#D0 [ ] // Argument: ANYTYPE atType--Any data type
.B(mE d s8I'vP0 [ ] // Pre Condition: None51Testing软件测试网&I%we4D%Y7z@RJ
[ ] // Return: None51Testing软件测试网3D(ghX.J
[ ] // Tester: LantianWei(wan1314yl@126.com)
Zop7{Z0 [ ] // Date: Mar 09, 200951Testing软件测试网!URb6\ B}
[ ] //
DZ3J&B'`!rB0 [+] // History:
f(i#qww;t2hs0 [ ] // None
8\;W1ZL QP5e0 [ ] //***********************************************************
3dcc2w0S B8V0 [ ]51Testing软件测试网,F t*p}3^|+K
[+] switch (TypeOf(atType))51Testing软件测试网-^+^'{;JW1A7?#LDvdv
[+] case LIST OF ANYTYPE51Testing软件测试网Heq ZV
[+]if(TypeOf(atType[1])==LIST OF ANYTYPE)
.m!['y ZXf*zl0 [ ] Print("The data type is LIST OF LIST OF ANYTYPE
函数代码:
:hTT c ujuOM0 [+]VOID GetDataType (ANYTYPE atType)51Testing软件测试网2e/[lR$i
[+] //Desc&History51Testing软件测试网Q n{GHt
[ ] //**********************************************************
.L,Jjlj4g8H'^0 [ ] // Function Name: GetDataType51Testing软件测试网 asDy/a^mqL$b
[ ] // Description: The example of handling any data type
f|k#vw1W#D0 [ ] // Argument: ANYTYPE atType--Any data type
.B(mE d s8I'vP0 [ ] // Pre Condition: None51Testing软件测试网&I%we4D%Y7z@RJ
[ ] // Return: None51Testing软件测试网3D(ghX.J
[ ] // Tester: LantianWei(wan1314yl@126.com)
Zop7{Z0 [ ] // Date: Mar 09, 200951Testing软件测试网!URb6\ B}
[ ] //
DZ3J&B'`!rB0 [+] // History:
f(i#qww;t2hs0 [ ] // None
8\;W1ZL QP5e0 [ ] //***********************************************************
3dcc2w0S B8V0 [ ]51Testing软件测试网,F t*p}3^|+K
[+] switch (TypeOf(atType))51Testing软件测试网-^+^'{;JW1A7?#LDvdv
[+] case LIST OF ANYTYPE51Testing软件测试网Heq ZV
[+]if(TypeOf(atType[1])==LIST OF ANYTYPE)
.m!['y ZXf*zl0 [ ] Print("The data type is LIST OF LIST OF ANYTYPE
- ")51Testing软件测试网0W}]~{z/Lp
[ ] //Do something as you want
[W6s i M ve0 [ ] //...51Testing软件测试网1G'u0l:oq{
[+] else51Testing软件测试网+U#[/M-FQ)zw5Hg/B
[ ] Print("The data type is LIST OF ANYTYPE
- ")
U,W*{p!Y"rf#V d0 [ ] //Do something as you want
"[)J:f"g.bpC7Z0 [ ] //...
u5O-m4[1QbA0 [+] case STRING51Testing软件测试网?}'aTK)Ty}5y-}2n
[ ] Print("The data type is STRING