diff options
-rwxr-xr-x | testsuite/rev.tests | 46 | ||||
-rw-r--r-- | util-linux/rev.c | 1 |
2 files changed, 47 insertions, 0 deletions
diff --git a/testsuite/rev.tests b/testsuite/rev.tests new file mode 100755 index 000000000..dd65dcd3b --- /dev/null +++ b/testsuite/rev.tests | |||
@@ -0,0 +1,46 @@ | |||
1 | #!/bin/sh | ||
2 | # Copyright 2021 by Ron Yorston | ||
3 | # Licensed under GPLv2, see file LICENSE in this source tree. | ||
4 | |||
5 | . ./testing.sh | ||
6 | |||
7 | # testing "test name" "commands" "expected result" "file input" "stdin" | ||
8 | |||
9 | testing "rev works" \ | ||
10 | "rev input" \ | ||
11 | "\ | ||
12 | 1 enil | ||
13 | |||
14 | 3 enil | ||
15 | " \ | ||
16 | "line 1\n\nline 3\n" \ | ||
17 | "" | ||
18 | |||
19 | testing "rev file with missing newline" \ | ||
20 | "rev input" \ | ||
21 | "\ | ||
22 | 1 enil | ||
23 | |||
24 | 3 enil" \ | ||
25 | "line 1\n\nline 3" \ | ||
26 | "" | ||
27 | |||
28 | testing "rev file with NUL character" \ | ||
29 | "rev input" \ | ||
30 | "\ | ||
31 | nil | ||
32 | 3 enil | ||
33 | " \ | ||
34 | "lin\000e 1\n\nline 3\n" \ | ||
35 | "" | ||
36 | |||
37 | testing "rev file with long line" \ | ||
38 | "rev input" \ | ||
39 | "\ | ||
40 | +--------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+--------------- | ||
41 | cba | ||
42 | " \ | ||
43 | "---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+--------------+\nabc\n" \ | ||
44 | "" | ||
45 | |||
46 | exit $FAILCOUNT | ||
diff --git a/util-linux/rev.c b/util-linux/rev.c index d439b4da8..63b005c67 100644 --- a/util-linux/rev.c +++ b/util-linux/rev.c | |||
@@ -109,6 +109,7 @@ int rev_main(int argc UNUSED_PARAM, char **argv) | |||
109 | strrev(buf, strlen(buf)); | 109 | strrev(buf, strlen(buf)); |
110 | #endif | 110 | #endif |
111 | fputs_stdout(buf); | 111 | fputs_stdout(buf); |
112 | pos = 0; | ||
112 | } | 113 | } |
113 | fclose(fp); | 114 | fclose(fp); |
114 | } while (*argv); | 115 | } while (*argv); |