Results 1 to 6 of 6

Thread: how to write test cases for a function

  1. #1
    Junior Member
    Join Date
    Apr 2007
    Answers
    1

    Smile how to write test cases for a function

    I met a question about how to write test cases for a function? for example, the function :
    bool match (string s, string p); if s matchs p, return true , otherwise return false. string p is kind of pattern (e.g. '?'--matchc one character; '*'-- match one or more characters)
    e.g S P expected result
    panic pani? true
    panic p* true
    panic ?nic false

    in my mind, I donot know how to classfy the test cases so that make the test case matrix.
    Could anyone help me out?

    Thanks in advance.


  2. #2
    Expert Member
    Join Date
    Apr 2008
    Answers
    1,859

    Re: how to write test cases for a function

    hi irisli

    i can give some suggestion regarding this

    For ex: the data i have taken the testdata as king

    1. s=king and p=king =pass
    2. s=king and p=kin? =pass
    3. s=king and p=k* =pass
    4. s=king and p=blank space =false
    5. s=king and p=!@#$% =false
    6. s=king and p=? =false
    7. s=king and p=* =false
    8. s=king and p=ki? =false
    9. s=king and p=*t =false
    10. s=kin and p=king =false
    like this you match the condition and prepare the test cases

    Thanks
    Deepasree


  3. #3
    Contributing Member
    Join Date
    Nov 2008
    Answers
    62

    Re: how to write test cases for a function

    hi deepasree,

    If i am taking tastdata as king and panic. Now how to check conditions and prepare the test cases. can you please explain me?

    Thanks,
    senthil Kumar venu


  4. #4
    Expert Member
    Join Date
    Apr 2008
    Answers
    1,859

    Re: how to write test cases for a function

    hi senthil,

    If you take test data for king here i am assigning the actual value of king to s and expected value p to k* and then checking whether the condition is s=p

    if s=king and p=k*then
    condition true
    else
    condition false
    end if

    Thanks
    Deepasree


  5. #5
    Contributing Member
    Join Date
    Nov 2008
    Answers
    62

    Re: how to write test cases for a function

    Hi deepasree,
    Thank you so much... i have one more question... if i i have taken test data as panic means

    if s=Panic and p=p*then
    condition true
    else
    condition false
    end if


    like this way to come test case... am i right... if i am wrong plese guide me...

    Thanks,
    senthil kumar venu


  6. #6
    Expert Member
    Join Date
    Apr 2008
    Answers
    1,859

    Re: how to write test cases for a function

    hi senthil,

    ya you have to test the functionality like this. Don't confuse test case with functionality

    Thanks
    Deepasree


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact