Write test cases for char * my_itoa(int n) method? What if this function is mission critical? How will you test it? How can you speed up the implementation?
Answer :
char * my_itoa(int n) method For this function : First I will pass correct argument and checks weather it is functioning correctly or not for correct arguments. I will pass float as argument, and check weather type casting is happening or not. I will pass char as argument, check proper exception is instantiated or not. I will pass Null as argument. I will pass more then integer range value. I will pass two integers as arguments.
Like that I will test this function… this is more like unit test cases.. developed by developer…
Above code can be tested using black box technique. Identify what needs to be tested. 1. Integer parameter accepted by a character type function pointer. 2. Return value will be character type. 3. Accepts single paramter. 4. what input it should accept and what it should not accept. 5. What should be the return value after calling the function. 6. what should be the behavior if the same fucntion called in a loop. 7. identifying any duplication of the above function. If you get above details, test cases can be designed based on this.