In your Coding Questions, test cases are the different types of inputs to your code to test your defined logic and produce the output. A test case is termed “passed” when the output from your code exactly matches the expected output. Else, the status “Wrong Answer” is indicated against the test case.
Depending on the complexity of your Question, the test setter may define one or more test cases to validate your logic. These test cases are automatically executed when you run your code, and the results help you to understand whether your coding solution is able to address the edge scenarios in the test cases and generate the expected output.
Following is an illustration of a Coding Question in a HackerRank Test. When the code is run, the test cases are executed with the input from code to display the results and the output.
Typically, the score or grade for a coding problem is calculated and assigned based on the number of test cases that succeed to produce the expected output. Refer the How are my coding questions graded or scored topic for more information.
For Coding Questions, your test setter may include the following types of test cases to validate your code against the expected output:
- Sample Test Cases - These are model test cases for initial validation of your logic to help you gain a better understanding of the problem. The sample test cases may or may not include a score for successful execution.
- Hidden Test Cases - These are the test cases which thoroughly validate your logic for various corner cases and involve specific scores for successful execution.