A methodology for mathematical software testing is presented which is applicable to classes of approximation and optimisation software. For testing purposes, a software implementation of an algorithm is regarded as a ''black box''. Reference data sets are input to the software, and the results provided are compared with reference results. It is described how reference data sets and results can be generated using a data generator, software which, when given reference results a priori, produces reference data sets corresponding to them. The emphasis is on least-squares software, but the concepts have broader application. Factors affecting comparison are considered and quality metrics for quantifying performance of the software under test described.