致力于软件自动化测试的研究和探索

[SilkTest]关于ANYTYPE的处理

上一篇 / 下一篇  2009-03-14 22:50:59 / 精华(2) / 个人分类:蓝天测试

   前几天,一朋友问到如何处理SilkTest中参数的ANYTYPE类型的问题,其实这个很方便,用TypeOf就可以区分,后来他又问到如何区分LIST OF ANYTYPELIST OF LIST ANYTYPE的问题,在这两者的区分上或许存在着一点小小的技巧,而且在实际项目中也经常会遇到在一个函数用处理多种/复杂的数据类型,因此想把这段代码分享给大家,希望对大家有点用处。51Testing软件测试网+D#v2`U e;A2JR
    函数代码:
:hTTc 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@ R J
            [ ] // Return:    None51Testing软件测试网3D(ghX.J
            [ ] // Tester:    LantianWei(wan1314yl@126.com)
Zo p7{Z0            [ ] // Date:    Mar 09, 200951Testing软件测试网!URb6\ B}
            [ ] // 
DZ3J&B'`!r B0            [+] // History: 
f(i#qww;t2hs0                [ ] //     None 
8\;W1ZLQ P5e0            [ ] //***********************************************************
3dcc2w0S B8V0        [ ]51Testing软件测试网,F t*p}3^|+K
        [+] switch (TypeOf(atType))51Testing软件测试网-^+^'{;J W1A7?#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)z w5Hg/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")
_1`f_2?7J.X0                    [ ] //Do something as you want51Testing软件测试网 N/@ qDW'Pg/|9K)r
                    [ ] //...51Testing软件测试网x wj+i {lu3X
            [ ] //case ...51Testing软件测试网%j5F8\*q*h6bYr
            [+] default51Testing软件测试网`$K(^ d4L}6XD1g Q
                [ ] LogError("Data type is unknown!")
B/b ]8P;L_FI"q"H N0 
J.[:^ bMN#l0     使用代码:51Testing软件测试网`$n n$b@j#c2nX
       [+]testcase test() appstate none
q0vMd?'c([0           [+] List of ANYTYPE lat={...}
4w4uNfG ]u0               [ ] "Lantianwei"51Testing软件测试网9G#]9\2IT:c{ ~([9{'m@
               [ ] 12351Testing软件测试网 tb&~2s&U [
               [ ] TRUE
4u%J6J!p{\ M0           [+] List of list of ANYTYPE llat={...}51Testing软件测试网ZS4~6uf~
               [ ] {"aa",23,"Lantianwei"}51Testing软件测试网C&i8N?F r
               [ ] {123,23,66}51Testing软件测试网gJ8V4e*J!HVXb
               [ ] {TRUE}51Testing软件测试网;O%~"h"B4j;?U4I7e
           [ ] STRING s="Lantianwei"
l+g$pv/s*`9ek+?$i0           [ ]
+S$nd gn1ut0           [ ] GetDataType(lat)51Testing软件测试网h(}0sv@+Kd rZt@
           [ ] GetDataType(llat)51Testing软件测试网bu"d^5D+V/tzSJ
           [ ] GetDataType(s)51Testing软件测试网)n2K$a?,An(x#T

TAG: SilkTest

 

评分:0

我来说两句

Open Toolbar