- 
	
	
		
			
			
				Junior Member
			
			
			
			
				
					
						
					
				
			
			 
			
				
				
				
				
				
					    
				
			
		 
		
			
				
				
				
					
 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.
						
					 
					
				 
			 
			
			
		 
	 
		
	
 
                                             
- 
	
	
		
			
			
				Expert Member
			
			
			
			
				
					
						
					
						
					
				
			
			 
			
				
				
				
				
				
					    
				
			
		 
		
			
				
				
				
					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
						
					 
					
				 
			 
			
			
		 
	 
		
	
 
                                             
- 
	
	
		
			
			
				Contributing Member
			
			
			
			
				
					
						
					
				
			
			 
			
				
				
				
				
				
					    
				
			
		 
		
			
				
				
				
					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
						
					 
					
				 
			 
			
			
		 
	 
		
	
 
                                             
- 
	
	
		
			
			
				Expert Member
			
			
			
			
				
					
						
					
						
					
				
			
			 
			
				
				
				
				
				
					    
				
			
		 
		
			
				
				
				
					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
						
					 
					
				 
			 
			
			
		 
	 
		
	
 
                                             
- 
	
	
		
			
			
				Contributing Member
			
			
			
			
				
					
						
					
				
			
			 
			
				
				
				
				
				
					    
				
			
		 
		
			
				
				
				
					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
						
					 
					
				 
			 
			
			
		 
	 
		
	
 
                                             
- 
	
	
		
			
			
				Expert Member
			
			
			
			
				
					
						
					
						
					
				
			
			 
			
				
				
				
				
				
					    
				
			
		 
		
			
				
				
				
					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
 
		-  
 
	
	
	Forum Rules