diff options
Diffstat (limited to 'tests/t0005-errors.sh')
| -rwxr-xr-x | tests/t0005-errors.sh | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/t0005-errors.sh b/tests/t0005-errors.sh new file mode 100755 index 0000000..458b4c8 --- /dev/null +++ b/tests/t0005-errors.sh @@ -0,0 +1,22 @@ +#!/bin/sh +set -eu +out="${TMPDIR-/tmp}/mcpu-cpp-error-$$.out" +err="${TMPDIR-/tmp}/mcpu-cpp-error-$$.err" +bad="${TMPDIR-/tmp}/mcpu-cpp-nonucs2-$$.c" +trap 'rm -f "$out" "$err" "$bad"' EXIT HUP INT TERM + +if "$MCPU_CPP" --no-config "$srcdir/data/unbalanced.c" -o "$out" 2>"$err"; then + exit 1 +fi +grep 'unbalanced #lang/#endlang' "$err" >/dev/null + +# A valid UTF-8 scalar outside UCS-2 is harmless inside a comment. +"$MCPU_CPP" --no-config "$srcdir/data/nonucs2.c" -o "$out" +grep '^int x;$' "$out" >/dev/null + +# The same scalar in program text is rejected after comment removal. +printf 'int x = \360\237\230\200;\n' > "$bad" +if "$MCPU_CPP" --no-config "$bad" -o "$out" 2>"$err"; then + exit 1 +fi +grep 'character outside UCS-2' "$err" >/dev/null |
