mercredi 8 septembre 2021

How do the test cases run in an online compiler in coding tests/problems? [closed]

Note:- I wish to provide C,C++,Java,Python,Go languages support
I am confused on how to implement the backend part of this I have the user's code in frontend as mentioned in the 'Solution'.

Let's take an example: Q: Write a prog to add two numbers.

Solution(in Go):

func add(num1,num2 int) int {
   return num1+num2
}

Now, Let's say I have defined a list of testcases for this problem
(4,5) = 9; (5,9) = 14; (-4,6) = 2;
What I want is to run all these pre defined test cases and if the code fails, return the specific case, else, success.

So, What's the idea here? should I append the user's code to a main.go file? should I run go test?
What is the best way to store & run the test cases?
If someone can explain the entire flow after I get user's code till I give a response, it will be really appreciated!
Thanks for your time :)

Aucun commentaire:

Enregistrer un commentaire