commit:     7f27dfa0ca0969837a9a40df49281ec7a2dae035
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sat Jun 10 07:40:16 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Jun 10 07:42:07 2023 +0000
URL:        
https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=7f27dfa0

test-functions: Add a test for the ebegin() function

The test determines whether ebegin() appends at least one <newline>
character to the message (following the ASCII ellipsis).

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>

 test-functions | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/test-functions b/test-functions
index aed6620..513deb3 100755
--- a/test-functions
+++ b/test-functions
@@ -68,6 +68,25 @@ test_chdir_noop() {
        iterate_tests 2 "$@"
 }
 
+test_ebegin() {
+       _eprint() {
+               shift
+               _ends_with_newline "$*"
+               ok=$(( $? == 0 ))
+       }
+
+       ok=0
+       set -- "message"
+       ebegin "$1"
+
+       if [ "${ok}" -eq 0 ]; then
+               printf 'not '
+       fi
+       printf 'ok %d - ebegin %s (expecting terminating newline)\n' 
"$((testnum + 1))" "$1"
+
+       return "$(( ok ? 0 : 1 ))"
+}
+
 test_is_older_than() {
        set -- \
                1  N/A           N/A \
@@ -451,6 +470,7 @@ rc=0
 
 test_chdir || rc=1
 test_chdir_noop || rc=1
+( test_ebegin ) || rc=1; testnum=$((testnum + 1))
 test_is_older_than || rc=1
 test_get_bootparam || rc=1
 test_esyslog || rc=1

Reply via email to