Next: , Previous: , Up: testing   [Contents][Index]


23.5 Validating results by comparing

Function: dotest-equal expected got

Compare the two parameters and return true if they are equal; return false otherwise. In the latter case print a message showing the expected value and the wrong one. Must be used as last command in a function, so that its return value is equal to that of the function.

Example:

function my-func () {
    echo $(($1 + $2))
}
function mytest-1.1 () {
    dotest-result 5 `my-func 2 3`
}
dotest mytest-

another example:

function my-func () {
    echo $(($1 + $2))
}
function mytest-1.1 () {
    dotest-result 5 `my-func 2 3` && \
      dotest-result 5 `my-func 1 4` && \
      dotest-result 5 `my-func 3 2` && \
}
dotest mytest-

Next: , Previous: , Up: testing   [Contents][Index]

This document describes version 3.0.0-devel.0 of Marcos Bash Functions Library.