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


23.6 Validating results by output

Function: dotest-output
Function: dotest-output string

Read all the available lines from stdin accumulating them into a local variable, separated by \n; then compare the input with string, or the empty string if string is not present, and return true if they are equal, false otherwise.

Example of test for a function that echoes its three parameters:

function my-lib-function () {
    echo $1 $2 $3
}
function mytest-1.1 () {
    my-lib-function a b c | dotest-output "a b c"
}
dotest mytest

Example of test for a function that is supposed to print nothing:

function my-lib-function () {
    test "$1" != "$2" && echo error
}
function mytest-1.1 () {
    my-lib-function a a | dotest-output
}
dotest mytest

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

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