omdl  v0.6.1
OpenSCAD Mechanical Design Library
Validation

Function validation methods. More...

+ Collaboration diagram for Validation:

Files

file  validation.scad
 Function validation methods.
 

Functions

function validate (d, cv, t, ev, p=4, pf=false)
 Compare a computed test value with an known good result. More...
 

Detailed Description

Function validation methods.

Example

Result

ECHO: "[ INFO ] root(); passed: 'test-a f1(farg)'"
ECHO:
ECHO: "root()"
ECHO: "##########################################################################"
ECHO: "# [ WARNING ] FAILED: 'test-b f1(farg)'. Got '1'. Expected to equal '3' #"
ECHO: "##########################################################################"
ECHO: "[ INFO ] root(); passed: 'test-c'"
ECHO:
ECHO: "root()"
ECHO: "#########################################################################################################################################"
ECHO: "# [ WARNING ] FAILED: 'test-d'. Got '[[90.001], [[45.009], true]]'. Expected to almost equal '[[90.002], [[45.01], true]]' to 4 digits #"
ECHO: "#########################################################################################################################################"

Function Documentation

function validate ( ,
cv  ,
,
ev  ,
= 4,
pf  = false 
)

Compare a computed test value with an known good result.

Parameters
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.
Returns
<string|boolean> Validation result indicating if the test passed or failed.
validation types pass if (else fail)
"almost" cv almost equals ev
"equals" cv equals ev
"not" cv not equal to ev
"true" | true cv is true
"false" | false cv is false
Note
When performing an "almost" equal validation, the comparison precision is controlled by 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_equal().