]> git.draconx.ca Git - dxcommon.git/blobdiff - tests/scripts.at
Add script for generating miscellaneous string tables.
[dxcommon.git] / tests / scripts.at
index 29471d833482e7782ca18b69f01d857bf26874b7..4784b5994929953114c4c6c11e4cd7a3c97a95d6 100644 (file)
@@ -212,3 +212,84 @@ p
 }' messages.po | LC_ALL=C sort], [0], [expout])
 
 AT_CLEANUP
+
+AT_SETUP([gen-strtab.awk])
+
+AT_DATA([test.def],
+[[
+&a world
+&b
+hello world
+&c
+hello
+world
+&d world\n
+&e
+\\not a newline
+&f
+\not a newline
+&g inline
+continued
+&h    no\
+newline\
+&i
+\   leading whitespace
+&j oneline
+# with a comment
+]])
+
+AT_CHECK([$AWK -f "$builddir/scripts/gen-strtab.awk" <test.def >test.h])
+
+sed -n 's/^[[&]]\([[^ ]]*\).*/\1/p' test.def >identifiers
+
+# test 0: sanity test
+AT_DATA([test0.c],
+[[#include "test.h"
+#include <stdio.h>
+
+int main(void)
+{
+  printf("---\n");
+]])
+exec 3<identifiers 4>>test0.c
+while read ident <&3; do
+  AS_ECHO(['  printf("%s\n---\n", '"strtab+$ident);"]) >&4
+done
+AS_ECHO(['  return 0;']) >&4
+AS_ECHO(['}']) >&4
+exec 3<&- 4>&-
+
+AT_CHECK([$CC -o test0$EXEEXT test0.c && ./test0$EXEEXT], [0], [---
+world
+---
+hello world
+
+---
+hello
+world
+
+---
+world
+
+---
+\not a newline
+
+---
+
+ot a newline
+
+---
+inline
+continued
+
+---
+nonewline
+---
+   leading whitespace
+
+---
+oneline
+---
+], [ignore])
+
+AT_CLEANUP