Ticket #29 (closed defect: fixed)
Improve unit testing of epdf
Reported by: | smidl | Owned by: | vbarta |
---|---|---|---|
Priority: | major | Milestone: | Tests of basic classes of BDM |
Component: | bdm core | Version: | |
Keywords: | Cc: | smidl@…, vbar@… |
Description
At present, epdfs are tested independently and randomly in files: testEpdf, testSmp, emix_test, enorm_test, egiw_test
Most of the tests for offsprings of epdf can be unified into a common structure that can be parameterized via libconfig by a set of .cfg files.
The main test would read a cfg file, that would contain:
epdf = {class = "epdf_offspring",...}; //UI for the epdf to test
mean = [...]; //theoretical mean
covariance = (rows,cols, data); //theoretical covariance matrix
support = ...; // significant part of its support on which to integrate
== optionally (numbers below are defaults) ===
nbins = [100]; //number of bins for numerical integration
nsamples = 1000; // number of samples to generate
=== optionally ====
marginal = {class="epdf",...}; //theoretical marginal
conditional = {class"mpdf", ...}; //theoretical conditional
The code itself would:
- build the pdf
- compare if theoretical moments agree with outputs of mean() and variance()
- perform numerical integration on given support and check if it is close to 1. (done e.g. in egiw.cpp)
- generate nsamples samples using sample() and check if their expected value is close (done in testSmp.cpp)
- if theoretical marginal and conditional densities are given, compare them with output of marginal() and condition()
Is this reasonable? My doubts are with the fact that some private functions of the class will not be tested in this setup - perhaps breaking the idea of unit-testing.
An alternative would be to design a generic functions for those test in a file epdf_common.h and include it in all unittests of classes.
Opinions?