Skip to content

CLASS ndi.mock.ctest

   ndi.mock.ctest - calculator test class, provides methods for testing ndi.calculator objects


Superclasses

none

Properties

Property Description
base_scope structure with the base scope information for the class

Methods

Method Description
calc_path CALC_PATH return the path to the ndi.calculator object
clean_mock_docs remove mock/test documents
compare_mock_docs compare an expected calculation answer with an actual answer
ctest object that provides methods for testing ndi.calculator objects
default_scope default scope types for ndi.mock.ctest object
generate_mock_docs generate tests for ndi.calc.* objects
load_mock_expected_output load expected NDI document answer for a calculation
mock_expected_filename file of expected NDI document answer for a calculation
mock_path return the path to the stored mock example output documents
plot plot a calculation test document
test perform a test of an ndi.calculator object
write_mock_expected_output write

Methods help

calc_path - CALC_PATH return the path to the ndi.calculator object

P = CALC_PATH(CTEST_OBJ)

  Return the path of an ndi.calculator object.

clean_mock_docs - remove mock/test documents



compare_mock_docs - compare an expected calculation answer with an actual answer

[B, ERRORMSG] = COMPARE_MOCK_DOCS(CTEST_OBJ, EXPECTED_DOC, ACTUAL_DOC, SCOPE)

  Given an NDI document with the expected answer to a calculation (EXPECTED_DOC),
  the ACTUAL_DOC computed, and the SCOPE (a string: 'standard', 'low_noise','high_noise'),
  this function computes whether the ACTUAL_DOC is within an allowed tolerance of
  EXPECTED_DOC.

  B is 1 if the differences in the documents are within the tolerance of the class.
  Otherwise, B is 0.
  If B is 0, ERRORMSG is a string that indicates where the ACTUAL_DOC is out of tolerance.

  In this abstract class, B is always 1 and ERRORMSG is always an empty string.

  Developer's note: this method should be overridden in each calculator object.

ctest - object that provides methods for testing ndi.calculator objects

CTEST_OBJ = ndi.mock.ctest()

  Create an ndi.mock.ctest object.

    Documentation for ndi.mock.ctest/ctest
       doc ndi.mock.ctest

default_scope - default scope types for ndi.mock.ctest object

BASE_SCOPE = ndi.mock.ctest.default_scope();

  Return a default base_scope structure for an ndi.mock.ctest object.

generate_mock_docs - generate tests for ndi.calc. objects*

[DOCS, DOC_OUTPUT, DOC_EXPECTED_OUTPUT] = GENERATE_MOCK_DOCS(CSTEST_OBJ,...
     SCOPE, NUMBER_OF_TESTS)

  SCOPE should be one of 'standard', 'low_noise', or 'high_noise'.
    'standard' performs tests on specific hard-coded inputs.
    'low_noise' performs tests on specific hard-coded inputs with small amounts
       of noise added. 
    'high_noise' performs tests on specific hard-coded inputs with large amounts
       of noise added.

  NUMBER_OF_TESTS is the number of tests to generate.

load_mock_expected_output - load expected NDI document answer for a calculation

DOC = LOAD_MOCK_EXPECTED_OUTPUT(CTEST_OBJ, N)

  Load the Nth stored ndi.document that contains the expected answer for the
  Nth standard mock test.

mock_expected_filename - file of expected NDI document answer for a calculation

FNAME = MOCK_EXPECTED_FILENAME(CTEST_OBJ, N)

  Return the filename for the Nth stored ndi.document that contains the expected
  answer for the Nth standard mock test.

mock_path - return the path to the stored mock example output documents

MP = MOCK_PATH(CTEST_OBJ)

  Returns the path to the mock document example outputs.
  The returned path ends in a file separator.

plot - plot a calculation test document

H = PLOT(CTEST_OBJ, DOCUMENT)

  Plot the ndi.document DOCUMENT in the current axes.

  In the abstract class, nothing is done.

test - perform a test of an ndi.calculator object

[B, ERRORMSG] = test(CTEST_OBJ, SCOPE, NUMBER_OF_TESTS, PLOT_IT)

  Perform tests of the calculator for a certain SCOPE.

  B is a NUMBER_OF_TESTS x NUMBER_OF_TESTS array of whether the comparisons 
    of the expected output of test i and actual output of test j are equal.
    Generally, b(i,i) should be 1 for all tests, and b(i,j) for i~=j should
    be 0, although results might be close enough for some comparisons to be
    equal even if there are no errors.

  ERRORMSG{i,j} is any error message given if the comparison between the
    expected outcome of test i and the actual outcome of test j.

  B_EXPECTED is the result of the comparisons between the expected
    outcome of test i and the expected outcome of test j. Some tests
    might have the same expected outcome, which can be useful for
    interpreting the results in B.

  SCOPE should be one of 'standard', 'low_noise', or 'high_noise'.
    'standard' performs tests on specific hard-coded inputs.
    'low_noise' performs tests on specific hard-coded inputs with small amounts
       of noise added. 
    'high_noise' performs tests on specific hard-coded inputs with large amounts
       of noise added.

  NUMBER_OF_TESTS indicates the number of tests to perform.
  PLOT_IT indicates (0/1) whether or not the results should be plotted.


  Step 1: generate_mock_docs

write_mock_expected_output - write

B = WRITE_MOCK_EXPECTED_OUTPUT(CTEST_OBJ, NUMBER, DOC)

  Set the expected mock document for mock calculation NUMBER to
  be the ndi.document DOC.

  This function will not overwrite an existing expected mock document. 
  It must be deleted manually to ensure programmer really wants to overwrite it.