diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/018.sh | 22 | ||||
| -rw-r--r-- | tests/019.sh | 28 | ||||
| -rw-r--r-- | tests/test_output.sh | 2 |
3 files changed, 51 insertions, 1 deletions
diff --git a/tests/018.sh b/tests/018.sh new file mode 100644 index 0000000..eb86a5e --- /dev/null +++ b/tests/018.sh @@ -0,0 +1,22 @@ +set -e + +bash ../../test_output.sh "" <<'EOF' +int main() { + ""; + return 0; +} +EOF + +bash ../../test_output.sh "" <<'EOF' +int main() { + "abc"; + return 0; +} +EOF + +bash ../../test_output.sh "" <<'EOF' +int main() { + "\"foo\"bar\\\n\""; + return 0; +} +EOF diff --git a/tests/019.sh b/tests/019.sh new file mode 100644 index 0000000..d31f154 --- /dev/null +++ b/tests/019.sh @@ -0,0 +1,28 @@ +set -e + +bash ../../test_output.sh "" <<'EOF' +int printf(); + +int main() { + printf(""); + return 0; +} +EOF + +bash ../../test_output.sh "Hello, World!" <<'EOF' +int printf(); + +int main() { + printf("Hello, World!\n"); + return 0; +} +EOF + +bash ../../test_output.sh '"Hello, World!"' <<'EOF' +int printf(); + +int main() { + printf("\"Hello, World!\"\n"); + return 0; +} +EOF diff --git a/tests/test_output.sh b/tests/test_output.sh index f4a4a20..2c8fb29 100644 --- a/tests/test_output.sh +++ b/tests/test_output.sh @@ -16,7 +16,7 @@ fi expected="$1" -if [[ "$output" -ne "$expected" ]]; then +if [[ "$output" != "$expected" ]]; then echo "invalid output: expected '$expected', but got '$output'" >&2 exit 1 fi |
