
Tests for each command in the package.

There is one top level test to run
> source('test_all.R')
The other files have .Rtest suffixes so the package check tests don't run
them separately.  The top level script sources each of these silently - we
do NOT want the individual test results to print and compare, only the
pass message at the end.  The individual test scripts are all stand-alone
and can be sourced from the shell.  They have separate branches if run
interactively from the shell or by the package check, for loading the
commands or the library as needed.  The files can be sourced from any
sister directory but not the top.

test_all.Rout.save has the expected result.

The file test_library.Rtest is for development.  It (re)loads the shared
library and source files from the console, but contains no tests.


TEST STRATEGY

Detectors
There are separate files for the semi-public top-level feature detector
commands: test_find_runs.Rtest, test_find_peaks.Rtest, test_find_flats.Rtest,
and test_find_lvlsec.Rtest.  THe test benches in general contain four types
of checks.  First, we use data available in an R distribution as the source
for interval spacing.  The expected features are based on the prototype
versions of these detectors, which differ substantially from the Dimodal
version.  Second, we construct artificial data where we can control which
features appear.  Examples include piecewise-linear waveforms for peaks and
collections of random variates with small or large variance to define flats.
Third, we define a common set of stress tests to present to each detector.
A table follows listing the tests and corresponding test cases.  Finally,
we create Break The Part (BTP) tests that mostly stress the detector's
interface, checking for bad parameters or unusual inputs.  Some of the
stress tests could also be considered BTP.

   Stress Tests
                   find_runs       find_peaks   find_flats      find_lvlsec
   const val       i TC16 r TC18   BTP13        TC16            i TC12 r TC11
     diff ramp     i TC17 r TC19   BTP19        TC17            TC14,15
   ramp            i TC32 r TC34   TC20         TC18            TC13
   sawtooth        i TC33 r TC35   TC10         TC19            TC16
   all NA          i BTP1 r BTP2   BTP17        TC20            BTP1-2
   NULL vector     BTP8            BTP18        BTP14           BTP3
   0 len vector    i BTP6 r BTP7   BTP16        BTP15           BTP4
   1 len vector    i TC31 r TC34   BTP14        BTP16           BTP5
   2 len vector
     const         i TC36 r TC39   BTP15        TC21            BTP6
     ramp          i TC37 r TC41   TC21         TC22            BTP7
   non-vector      i TC42 r TC44   TC32         TC23            TC17
   NA values
     at start      i TC17 r TC23   TC24         i TC25 r TC24   TC19
     at end        i TC19 r TC24   TC25         i TC27 r TC26   TC20
     in middle     i TC20 r TC12   TC26         i TC29 r TC28   TC21
     mixed         i TC7  r TC27   TC27         i TC31 r TC30   TC22
   NaN values
     at start             r TC28   TC28                r TC31   TC23
     at end               r TC29   TC29                r TC32   TC24
     in middle            r TC30   TC30                r TC33   TC25
     mixed                r TC14   TC31                r TC34   TC26
   Inf values             r TC14
   outliers                                     TC10-12
                                                BTP2-3,5-6
   one flat < minlen                            TC36

Significance Tests
test_sigtests.Rtest does quality checks on the feature evaluators in the
sigtests.R file.  The first group tests the models, peak height and flat
length.  The test cases combine back-and-forth conversions of a large
number of variations of the three parameters, for example generating the
probability of a feature and then converting that back to a critical value,
comparing the result to original.  A large set of test cases finds the
probability or critical value for a handful of given setups, comparing the
result to values from the prototype version; these mostly check that the
models were ported correctly.  The second group tests runs, either Dinrun.test
or Dirunlen.test.  The expected probabilities come from the prototype version.
The third group contains the excursion tests.  Finally we have a number of
BTP checks for each of the eight tests, per this table.

   BTP/Stress tests
                      pk tst/cv    ft tst/cv    nrun   runlen  perm   excur
   no value           PT1    PC1   FT1    FC1   KR1    RL1     PH1    EH1
   NA value           PT2    PC2   FT2    FC2   KR9    RL9     PH2    EH2
   NaN value          PT2    PC2   FT2    FC2   KR10   RL10    PH3    EH3
   NULL vector        PT3    PC3   FT3    FC3   KR2,3  RL2,3   PH7    EH7
   -Inf value         PT4    PC4   FT4    FC4                  PH4    EH4
   +Inf value         PT4    PC4   FT4    FC4                  PH5    EH5
   not numeric value  PT2    PC2   FT2    FC2   KR11   RL11    PH6    EH6
   NA n/stID/ht       PT7    PC7   FT7    FC7   KR4    RL4     PH8    EH8
   NaN n              PT7    PC7   FT7    FC7   KR4    RL4     PH8    EH8
   bad n              PT7    PC7   FT7    FC7   KR6    RL6     PH10   EH10
   non-integer n      PT6    PC6   FT6    FC6   KR6    RL6     PH9    EH9
   multiple n         PT6    PC6   FT6    FC6   KR6    RL6     PH9    EH8
   non-numeric n      PT7    PC7   FT7    FC7   KR6    RL6     PH10   EH10
   NA flp/endID/nperm PT9    PC9   FT9    FC9   KR4    RL4     PH11   EH11
   NaN flp            PT9    PC9   FT9    FC9   KR4    RL4     PH11   EH11
   flp <= 0           PT9    PC9   FT8    FC9   KR7    RL7     PH11   EH11
   flp real > 1.0     PT8    PC8   FT8    FC8   KR7    RL7            
   multiple flp       PT8    PC8   FT8    FC8   KR7    RL7     PH12   EH12
   flp > n            PT9    PC9   FT8    FC9   KR7    RL7            
   non-numeric flp    PT9    PC9   FT9    FC9   KR7    RL7     PH11   EH11
	 NULL stID/endID                              KR5    RL5            
   NA filter/feps     PT10   PC10  FT10   FC10  KR8    RL8            
   alt filters        PT10   PC10  FT10   FC10  KR8    RL8            
   bad filter         PT10   PC10  FT10   FC10  KR8    RL8            
   multiple filters   PT10   PC10  FT10   FC10  KR8    RL8            
   alt basedist                    FT11   FC11                        
   bad basedist                    FT11   FC11                        
   multiple basedist               FT11   FC11                        
   NA basedist                     FT11   FC11                        
   non-bool l.tail    PT11         FT12                        PH13   EH13

Top Level Functions
Each top level function, Dimodal, Diopt, and Ditrack, has a test bench in
the file test_<function>.Rtest.  For Diopt the tests focus on correct and
incorrect parameter values and the main modes of accessing and changing
options.  The Ditrack tests are not included in test_all because of the run
time; these are more stress tests for Dimodal than checks of the Ditrack
code.

Changepoints
The changepoint tests do not require any detectors be installed; they only
check the fusion of the results by creating a mock-up of library results.


CHARACTERIZATION

Files ending in .Rchar contain code used in evaluating Dimodal and its
tests.  They are sourced from the command line to characterize the analysis,
for example the stability of the excursion test.  Like the .Rtest files,
these will not be run during the R installation check.
















