Testing your code

By default, when you compile your code, it is run against the sample test cases. However, if you want to test your code with more test cases, you can manually define these by using the custom input section.

Note: The format of your custom input must always be the same as what is given in the Input format section in the problem. To understand the format, refer to the following image.


Why use custom input to test your code?

Using custom input to test your code is especially helpful when your code passes the sample test cases but does not pass the internal test cases and you need more input points to debug it.

What kind of results does this additional test give?

It gives you the following information:

  • Result
  • Time taken to compile and test the code
  • Memory used
  • Language in which the code is written
  • Custom input entered by you
  • Output of your code after it was compiled and run
  • Compilation log with details
  • Execution log with details
When to test against custom input?

You can test against custom input in the following scenarios:

Use case 1:  Your code displays an error during compilation

A compilation error is a gross error when it comes to programming. You can test your code against custom input to ensure that your code does not have any semantic or syntactical errors, which are usually the cause of compilation errors.


Use case 2:  When a correct answer is available and you want to be sure that the output of your code matches it

In some problems, the recruiter may add a correct answer to make you aware of the exact output that is required. In such cases, you may want to test your code against custom input to ensure that the output matches the correct answer.


Running your code against customized input

To run your code against customized input, follow these steps:

  1. Click custom_input_button.jpg
  2. Enter your input in the text box.
  3. Click Compile & Test.

Note: When you run your code against custom input, it will not be run against the sample and internal test cases. For more information about the sample and internal test cases, see Test cases.