]> git.draconx.ca Git - dxcommon.git/blobdiff - tests/scripts.at
gen-strtab.awk: Add options to tweak the output.
[dxcommon.git] / tests / scripts.at
index 41dfbb43760bcf95cd87792db5101e851cd1d882..f4a4a105fb057ede633b10df765502855e9e3066 100644 (file)
@@ -1,4 +1,4 @@
-dnl Copyright © 2021-2022 Nick Bowler
+dnl Copyright © 2021-2023 Nick Bowler
 dnl
 dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
 dnl This is free software: you are free to do what the fuck you want to.
@@ -302,6 +302,34 @@ oneline
 
 AT_CLEANUP
 
+AT_SETUP([gen-strtab.awk @nozero option])
+AT_KEYWORDS([gen-strtab awk script scripts])
+
+AT_DATA([test0.def],
+[[&hello hello
+]])
+AT_CHECK([$AWK -f "$builddir/scripts/gen-strtab.awk" <test0.def >test0.h])
+
+AT_DATA([test1.def],
+[[@nozero
+&hello hello
+]])
+AT_CHECK([$AWK -f "$builddir/scripts/gen-strtab.awk" <test1.def >test1.h])
+
+AT_DATA([test.c],
+[[#include <stdio.h>
+#include HEADER
+int main(void) { printf("%d %s\n", hello, strtab+hello); return 0; }
+]])
+AT_CHECK([$CC -DHEADER='"test0.h"' -o test0$EXEEXT test.c && ./test0$EXEEXT],
+  [0], [[0 hello
+]])
+AT_CHECK([$CC -DHEADER='"test1.h"' -o test1$EXEEXT test.c && ./test1$EXEEXT],
+  [0], [[1 hello
+]])
+
+AT_CLEANUP
+
 AT_SETUP([gen-tree.awk])
 AT_KEYWORDS([gen-tree awk script scripts])