Agree with your friend - use Python and put them within a unit test framework.
I worked for a number of years with scientists who did a lot of their algorithmic work in Python.
The example below shows typical tests (the import statement is for the stuff being tested), with a couple of niceties that might save you some time.
The business with the save and restore of sys.path is so you can have all your tests sitting in a directory adjacent to the src directory, without having to install the source into your main Python modules.
This test script is written so it can be imported into a larger suite of unit tests or simply run with python thisfile.py.
#!/usr/bin/python
"""
VRML Writer tests
"""
import unittest
import os
import sys
if __name__ == '__main__':
global save_syspath
save_syspath = sys.path
sys.path = [os.path.abspath("../src/")] + sys.path
from cgtools.VizValueTools import *
if __name__ == '__main__':
sys.path = save_syspath # RESTORE SYS.PATH
# use some common constants to make tests easier
MINV = 0.002
MAXV = 12.789
class TestColdHotColorGeneration(unittest.TestCase):
def testGeneratesLimitValues(self):
assert generateColdHotColorValue(MINV, MAXV, MINV) == (0.0, 0.0, 1.0)
assert generateColdHotColorValue(MINV, MAXV, MAXV) == (1.0, 0.0, 0.0)
assert generateColdHotColorValue(0, 0, 0) == (1.0, 0.0, 0.0) # cope with weird case where range is effectively one value, should be always top
def testGeneratesLimitValuesWithClipping(self):
assert generateColdHotColorValue(MINV, MAXV, MINV - 1.2) == (0.0, 0.0, 1.0)
assert generateColdHotColorValue(MINV, MAXV, MAXV + 49) == (1.0, 0.0, 0.0)
def testGeneratesMiddleValue(self):
"""
Note to be careful picking values so your value IS in the middle,
to generate pure green
"""
assert generateColdHotColorValue(1.0, 3.0, 2.0) == (0.0, 1.0, 0.0)
if __name__ == '__main__':
# When this module is executed from the command-line, run all its tests
unittest.main()