summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile1
-rw-r--r--tests/test_swab_negative.c19
2 files changed, 20 insertions, 0 deletions
diff --git a/tests/Makefile b/tests/Makefile
index fbfd178..9fc8287 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -87,6 +87,7 @@ RUNTIME_TARGETS= \
87 test_strncpy_static_write \ 87 test_strncpy_static_write \
88 test_swab_dynamic_read \ 88 test_swab_dynamic_read \
89 test_swab_dynamic_write \ 89 test_swab_dynamic_write \
90 test_swab_negative \
90 test_swab_static_read \ 91 test_swab_static_read \
91 test_ttyname_r_dynamic \ 92 test_ttyname_r_dynamic \
92 test_ttyname_r_static \ 93 test_ttyname_r_static \
diff --git a/tests/test_swab_negative.c b/tests/test_swab_negative.c
new file mode 100644
index 0000000..f9c182b
--- /dev/null
+++ b/tests/test_swab_negative.c
@@ -0,0 +1,19 @@
1#include "common.h"
2
3#include <unistd.h>
4
5int main(int argc, char** argv) {
6 char src[8] = "ABCDEFG";
7 char dst[8] = {0};
8
9 /* Positive case: normal swab works */
10 swab(src, dst, 6);
11 puts(dst);
12
13 /* Negative n: POSIX says swab does nothing, must NOT trap */
14 swab(src, dst, -1);
15 swab(src, dst, -100);
16
17 puts(dst);
18 return ret;
19}