tags:

views:

148

answers:

6

I have a number of C functions which implement mathematical formulae. To-date these have been tested for mathematical "soundness" by passing parameters through command line applications or compiling DLL's for applications like Excel. Is there an easy way of doing this testing over the web?

Ideally something along the lines of:

  • compile a library
  • spend five minutes defining a web form which calls this code
  • testers can view the webpage, input parameters and review the output

A simple example of a calculation could be to calculate the "accrued interest" of a bond:

Inputs: current date, maturity date, coupon payment frequency (integer), coupon amount (double)

Outputs: the accrued interest (double)

+1  A: 

The quickest thing I can think of is to have these C programs compiled on the server. And create a PHP page that received command-line parameters and then execute compiled program on the server, parsing the output. Technologies other than PHP would also work just fine. What you need to figure out, for specific technology, are:

  • How to start a process
  • How to redirect standard input/output

I have also seen number of web site which let users submit their C code and then it get compiled on the server. After that the program will be given some input file and give output. The output of program is then verified with correct answer. For example visit this site, http://acm.timus.ru/

m3rLinEz
+6  A: 

You should have a look into automated testing. Manual tests will all have to be repeated every time you change something in your code. Automated tests are the solution for your kind of tests. Let testers write test cases with the accompanying results, then make them into unit tests.

See also: unit testing

Thorsten79
True, but this doesn't answer the question.
Avi
Sometimes a person just asks the wrong question.
Norman Ramsey
A: 

Or similarly, create a Perl CGI that checks input values and then passes them through to the C program. BTW This should only be done for testing and not for final deployment.

You should really automate the testing to check your behaviour is as expected over a wide range of values.

Or shouldn't you be testing this in an environment that is as close as possible to the final deployment environment?

cheers,

Rob

Rob Wells
A: 

This is what you're looking for:

http://codepad.org/

It will execute C, C++, D, Haskell, Lua, and many others online, and display the results.

If you've got a large library to compile it may get unwieldy, but testing a function briefly is simply a matter of pasting the code and hitting "Submit".

Max
+1  A: 

If you're going to do this, you should be sure that every web interaction is captured in a permanent database of tests. Then you can use this database to

  • Automatically re-run all tests if the software changes

  • Possibly find inconsistencies that result if a person gives you the wrong answer

In other words, the web form should be the front end to a persistent infrastructure for testing, not a means of running tests that disappear just after they are viewed.

Norman Ramsey
A: 

This sounds much like FIT. You could probably make a new fixture for it, or for one of the other language ports like the Python one, that calls a C library with your function. This would take advantage of the work that's gone into making FIT convenient, the kind of work Norman Ramsey recommends in his answer.

Darius Bacon