From 8faa7a0ab64d0ca571848d5b5d242b93b9d3ff39 Mon Sep 17 00:00:00 2001 From: William Melody Date: Mon, 25 Jan 2016 17:20:10 -0800 Subject: [PATCH] Add `_compare()` function to test_helper.bash. --- test/test_helper.bash | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/test_helper.bash b/test/test_helper.bash index e3b03b6..c0e3a8b 100644 --- a/test/test_helper.bash +++ b/test/test_helper.bash @@ -24,3 +24,22 @@ teardown() { rm "${HOSTS_PATH}" fi } + +############################################################################### +# Helpers +############################################################################### + +# _compare() +# +# Usage: +# _compare +# +# Descriotion: +# Compare the content of a variable against an expected value. When used +# within a `@test` block the output is only displayed when the test fails. +_compare() { + local _expected="${1:-}" + local _actual="${2:-}" + printf "expected:\n%s\n" "${_expected}" + printf "actual:\n%s\n" "${_actual}" +}