← Commit list

4357569fd

Ron Yorston
Ron Yorston
2021-08-22
SUCCESS Duration: 152s

Subject

rev: correct output for long input lines

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

testsuite/rev.tests+46 -0
@@ -0,0 +1,46 @@
+#!/bin/sh
+# Copyright 2021 by Ron Yorston
+# Licensed under GPLv2, see file LICENSE in this source tree.
+
+. ./testing.sh
+
+# testing "test name" "commands" "expected result" "file input" "stdin"
+
+testing "rev works" \
+ "rev input" \
+"\
+1 enil
+
+3 enil
+" \
+ "line 1\n\nline 3\n" \
+ ""
+
+testing "rev file with missing newline" \
+ "rev input" \
+"\
+1 enil
+
+3 enil" \
+ "line 1\n\nline 3" \
+ ""
+
+testing "rev file with NUL character" \
+ "rev input" \
+"\
+nil
+3 enil
+" \
+ "lin\000e 1\n\nline 3\n" \
+ ""
+
+testing "rev file with long line" \
+ "rev input" \
+"\
++--------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------
+cba
+" \
+ "---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+--------------+\nabc\n" \
+ ""
+
+exit $FAILCOUNT
util-linux/rev.c+1 -0
@@ -109,6 +109,7 @@ int rev_main(int argc UNUSED_PARAM, char **argv)
strrev(buf, strlen(buf));
#endif
fputs_stdout(buf);
+ pos = 0;
}
fclose(fp);
} while (*argv);