TEST CASES FORMATION

How test cases are formed ?

Is there any algorithm which produces these many test cases ?

Test cases can be randomly generated. These randomly generated test cases are mostly to check if a submitted code can produce correct answers in a given time. Then there are corner cases, I believe those are manually written. You can read more here.

Edit:

Refer to @kuruma’s answer, it has a much more detailed explanation.

Hello,

The link @junior94 gave you, unfortunately, does not add much stuff to what he told you, so, as a setter, I might give my feedback to you.

The corner cases, or tricky test cases, that are responsible for the TLE and WA veredicts, are usually in between, 5-10 cases that are carefully hand-written and designed “by a human, for a human”.

Tipically, such cases will exploit either corner cases (0, prime numbers, negative numbers, a specific ordering of a list or limits of a given range, etc.) and of course the limit cases, for instance, if there are as input two numbers, say N and K, with N <= 99999999 and K <= 20, it is guaranteed that the case N = 99999999 and K = 20 will be tested, and it’s the setter who must assure that such case is in fact tested.

All of the remaining cases, are mostly to cross check for efficiency/ performance and for a well designed code, i.e., you may have some variables on your code that pass a given test, but, if you forget to declare them on the right place, or to reset its value, that error can and will propagate to other cases, which will obviously be caught.

It’s not much of a secret and there’s no specific algorithm for it…Instead it depends on the algorithm you intend to use to solve your own problem and ofc it relies on testing corner cases and limit cases very well

Best regards,

Bruno

1 Like

@vaibhav2992 Here is a very good question regarding your query on stackoverflow. You will find number of tool listed to generate test cases.

Test Case Generation Tools

Although corner cases are usually manually written to fail user’s solution.

//