Silktest has MatchStr function to compare one string with another. Here you can use pattern. But Silktest does not have a built-in function to match a item by a pattern with a List of items. I have used this scenario in many places of the code. Code snippet is given below.
4Test Code: To Match a string against List
[-] public Integer MatchList(String sPattern, LIST OF STRING lsInput) [ ] //To match one string with any item in list of strings [ ] //Returns the item value(integer) [ ] Integer iCount, iItem [ ] String sData, sTemp [ ] Integer iReturn = 0 [ ] [ ] iCount = ListCount(lsInput) [-] for iItem=1 to iCount [-] if (MatchStr(sPattern,lsInput[iItem])) [ ] iReturn = iItem [ ] break [ ] [ ] return iReturn
No comments:
Post a Comment