How to write test cases for this function

Hi, Guys,
I met a interview questions today, the question is to test this bool function
bool match (string s, string p);
string p is a pattern string, that means include character such as '?' or '*'
e.g. if s = 'panic' and p='pani?', it will return true,
if s ='panic' and p ='p*', it will return true,
if s = 'panic' and p= '??' it will return false.

I don't know how to write down test cases and how to classify the test cases such as valid or invalid, boundary test , could anyone help me out?

Thanks in advance.

Questions by irisli

Showing Answers 1 - 9 of 9 Answers

deep_pinu

  • Jan 31st, 2008
 

Hi irisli

I cudnt understand your question, but still i wud suggest is
you should write test case having string- s as the super set of p-pattern. means p must have each char assigend to s.

can u pl. test , what kind of testing it is....white/black. so that we can find a solution to it.

  Was this answer useful?  Yes

vini_26

  • Feb 27th, 2008
 

Hi, these are the following test cases which you can write for the asked function..
Let me tell
you first what I understood from the question because according to that I have written the cases.
According to what I
saw, string s and string p are compared and resulted true only if both characters match. (even one character from s can match p).
The "?" and "*" is just like replacement for any one character.
s=panic , p = pani? ------ Valid
s=panic , p = pani* ------ Valid
s=panic , p = p? ------ Valid
s=panic , p = p* ------ Valid
s=panic , p = p*nic ------ Valid
s=panic , p = p*ni? ------ InValid
s=panic , p = ?pnic ------ InValid
s=panic , p = ?? ------ InValid
s=panic , p = *? ------ InValid
s=panic , p = ** ------ InValid
s=panic , p = pan?? ------ InValid
These are few test cases which
I think can be written..
Correct me if am wrong..

  Was this answer useful?  Yes

hi friend 


don`t worry you ask the help from the people who has known sql query very well because they know very well about the query how to writefor this 

In sql normally they use view for these set to test

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions