GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  Testing  >  Test Cases

 Print  |  
Question:  how to write test cases for this function

Answer: 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.


February 02, 2008 02:26:01 #2
 vini_26   Member Since: February 2008    Total Comments: 1 

RE: how to write test cases for this function
 
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..
     

 

Back To Question