![]() |
omdl
v0.9.7
OpenSCAD Mechanical Design Library
|
Run-time test and validation functions. More...
Collaboration diagram for Validation Functions:Files | |
| file | validation.scad |
| Methods for validating the results of functions. | |
Functions | |
| function | validate (d, cv, t, ev, p=4, pf=false) |
| Compare a computed test value with an known good result. More... | |
| module | validate_log (t) |
Output text t to the test log. More... | |
| module | validate_skip (fn) |
Output that function named fn has been skipped to the test log. More... | |
| function | table_validate_init (tr, gr) |
| Create data structure for related table validation functions. More... | |
| function | table_validate_fmt (id, td, v1, v2, v3) |
| Encode an entry for test table. More... | |
| function | table_validate_get_ids (db) |
Return a list of test identifiers in db. More... | |
| function | table_validate_get_ev (db, fn, id) |
| Return the expected value. More... | |
| function | table_validate_get_td (db, id) |
| Return the test description. More... | |
| function | table_validate_get_v1 (db, id) |
| Return the test argument value 1. More... | |
| function | table_validate_get_v2 (db, id) |
| Return the test argument value 2. More... | |
| function | table_validate_get_v3 (db, id) |
| Return the test argument value 3. More... | |
| module | table_validate_start (db, verbose=false) |
Test data structure db and output the start of test to the test log. More... | |
| module | table_validate (db, id, fn, argc, fr, t="equals", p=6) |
| Validate and log a test function return value against its expected value. More... | |
| function | map_validate_init (m, fn) |
| Create data structure for related map validation functions. More... | |
| function | map_validate_fmt (id, td, ev, v1, v2, v3) |
| Encode an entry for test map. More... | |
| function | map_validate_get_ids (db) |
Return a list of test identifiers in db. More... | |
| function | map_validate_get_fn (db) |
| Return the test function name. More... | |
| function | map_validate_get_td (db, id) |
| Return the test description. More... | |
| function | map_validate_get_ev (db, id) |
| Return the expected value. More... | |
| function | map_validate_get_v1 (db, id) |
| Return the test argument value 1. More... | |
| function | map_validate_get_v2 (db, id) |
| Return the test argument value 2. More... | |
| function | map_validate_get_v3 (db, id) |
| Return the test argument value 3. More... | |
| module | map_validate_start (db, verbose=false) |
Test data structure db and output the start of test to the test log. More... | |
| module | map_validate (db, id, argc, fr, t="equals", p=6) |
| Validate and log a test function return value against its expected value. More... | |
Variables | |
| validation_skip = [number_min, number_max, number_inf] | |
| Value signature assignment for log-value results table to skip a test. | |
Run-time test and validation functions.
| Requires: |
|---|
| include <omdl-base.scad>; |
| include <common/validation.scad>; |
| module map_validate | ( | db | , |
| id | , | ||
| argc | , | ||
| fr | , | ||
| t | = "equals", |
||
| p | = 6 |
||
| ) |
Validate and log a test function return value against its expected value.
| db | <datastruct> An initialized validation map data structure. |
| id | <string> The test identifier. |
| argc | <integer> The number of arguments to retrieve from db. |
| fr | The value returned from the tested function. |
| t | <string | boolean> The validation type. |
| p | <number> A numerical precision for approximate comparisons. |
See function validate() for more information on possible values for parameters t and p.
Map-based validation script
Map-based validation script output
Definition at line 810 of file validation.scad.
Here is the call graph for this function:| function map_validate_fmt | ( | id | , |
| td | , | ||
| ev | , | ||
| v1 | , | ||
| v2 | , | ||
| v3 | |||
| ) |
Encode an entry for test map.
| id | <string> The test identifier. |
| td | <string> The test description. |
| ev | The test expect value. |
| v1 | The test argument value 1. |
| v2 | The test argument value 1. |
| v3 | The test argument value 1. |
| function map_validate_get_ev | ( | db | , |
| id | |||
| ) |
Return the expected value.
| db | <datastruct> An initialized validation map data structure. |
| id | <string> The test identifier. |
Here is the caller graph for this function:| function map_validate_get_fn | ( | db | ) |
Return the test function name.
| db | <datastruct> An initialized validation map data structure. |
Here is the caller graph for this function:| function map_validate_get_ids | ( | db | ) |
Return a list of test identifiers in db.
| db | <datastruct> An initialized validation map data structure. |
| function map_validate_get_td | ( | db | , |
| id | |||
| ) |
Return the test description.
| db | <datastruct> An initialized validation map data structure. |
| id | <string> The test identifier. |
id.
Here is the caller graph for this function:| function map_validate_get_v1 | ( | db | , |
| id | |||
| ) |
Return the test argument value 1.
| db | <datastruct> An initialized validation map data structure. |
| id | <string> The test identifier. |
Here is the caller graph for this function:| function map_validate_get_v2 | ( | db | , |
| id | |||
| ) |
Return the test argument value 2.
| db | <datastruct> An initialized validation map data structure. |
| id | <string> The test identifier. |
Here is the caller graph for this function:| function map_validate_get_v3 | ( | db | , |
| id | |||
| ) |
Return the test argument value 3.
| db | <datastruct> An initialized validation map data structure. |
| id | <string> The test identifier. |
Here is the caller graph for this function:| function map_validate_init | ( | m | , |
| fn | |||
| ) |
Create data structure for related map validation functions.
| m | <map> The test data map. |
| fn | <string> The function name. |
| module map_validate_start | ( | db | , |
| verbose | = false |
||
| ) |
Test data structure db and output the start of test to the test log.
| db | <datastruct> An initialized validation map data structure. |
| verbose | <boolean> Be more verbose. |
Definition at line 699 of file validation.scad.
Here is the call graph for this function:| module table_validate | ( | db | , |
| id | , | ||
| fn | , | ||
| argc | , | ||
| fr | , | ||
| t | = "equals", |
||
| p | = 6 |
||
| ) |
Validate and log a test function return value against its expected value.
| db | <datastruct> An initialized validation table data structure. |
| id | <string> The test identifier. |
| fn | <string> The function name. |
| argc | <integer> The number of arguments to retrieve from db. |
| fr | The value returned from the tested function. |
| t | <string | boolean> The validation type. |
| p | <number> A numerical precision for approximate comparisons. |
See function validate() for more information on possible values for parameters t and p.
Table-based validation script
Table-based validation script output
Definition at line 552 of file validation.scad.
Here is the call graph for this function:| function table_validate_fmt | ( | id | , |
| td | , | ||
| v1 | , | ||
| v2 | , | ||
| v3 | |||
| ) |
Encode an entry for test table.
| id | <string> The test identifier. |
| td | <string> The test description. |
| v1 | The test argument value 1. |
| v2 | The test argument value 1. |
| v3 | The test argument value 1. |
| function table_validate_get_ev | ( | db | , |
| fn | , | ||
| id | |||
| ) |
Return the expected value.
| db | <datastruct> An initialized validation table data structure. |
| fn | <string> The function name. |
| id | <string> The test identifier. |
Here is the caller graph for this function:| function table_validate_get_ids | ( | db | ) |
Return a list of test identifiers in db.
| db | <datastruct> An initialized validation table data structure. |
| function table_validate_get_td | ( | db | , |
| id | |||
| ) |
Return the test description.
| db | <datastruct> An initialized validation table data structure. |
| id | <string> The test identifier. |
Here is the caller graph for this function:| function table_validate_get_v1 | ( | db | , |
| id | |||
| ) |
Return the test argument value 1.
| db | <datastruct> An initialized validation table data structure. |
| id | <string> The test identifier. |
Here is the caller graph for this function:| function table_validate_get_v2 | ( | db | , |
| id | |||
| ) |
Return the test argument value 2.
| db | <datastruct> An initialized validation table data structure. |
| id | <string> The test identifier. |
Here is the caller graph for this function:| function table_validate_get_v3 | ( | db | , |
| id | |||
| ) |
Return the test argument value 3.
| db | <datastruct> An initialized validation table data structure. |
| id | <string> The test identifier. |
Here is the caller graph for this function:| function table_validate_init | ( | tr | , |
| gr | |||
| ) |
Create data structure for related table validation functions.
| tr | <table> The test data table rows. |
| gr | <table> The expected result data table rows. |
| module table_validate_start | ( | db | , |
| verbose | = false |
||
| ) |
Test data structure db and output the start of test to the test log.
| db | <datastruct> An initialized validation table data structure. |
| verbose | <boolean> Be more verbose. |
Definition at line 438 of file validation.scad.
Here is the call graph for this function:| function validate | ( | d | , |
| cv | , | ||
| t | , | ||
| ev | , | ||
| p | = 4, |
||
| pf | = false |
||
| ) |
Compare a computed test value with an known good result.
| d | <string> A description. |
| cv | <value> A computed value to validate. |
| t | <string | boolean> The validation type. |
| ev | <value> The expected good value. |
| p | <number> A numerical precision for approximate comparisons. |
| pf | <boolean> Report result as pass or fail boolean value. |
| validation types | pass if (else fail) |
|---|---|
| "ae" | "almost" | cv almost equals ev |
| "eq" | "equals" | cv equals ev |
| "ne" | "not" | cv not equal to ev |
| "t" | "true" | true | cv is true |
| "f" | "false" | false | cv is false |
p. This specifies the number of digits of precision for each numerical comparison. A passing result indicates that cv equals ev to the number of decimal digits specified by p. The comparison is performed by the function almost_eq().Validate function script
Validate function script output
Here is the caller graph for this function:| module validate_log | ( | t | ) |
Output text t to the test log.
| t | <string> A message to output to log. |
Definition at line 323 of file validation.scad.
Here is the call graph for this function:
Here is the caller graph for this function:| module validate_skip | ( | fn | ) |
Output that function named fn has been skipped to the test log.
| fn | <string> The name of the skipped function. |
Definition at line 329 of file validation.scad.
Here is the call graph for this function: