#! /bin/sh # -*- Mode: Shell-script -*- # strtable.test --- test string-table functionality # # Time-stamp: "2007-07-04 11:31:31 bkorb" # Author: Bruce Korb # Last Modified: $Date: 2007/07/04 20:51:14 $ # by: bkorb ## ## This file is part of AutoGen. ## AutoGen copyright (c) 1992-2007 by Bruce Korb - all rights reserved ## ## AutoGen is free software: you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by the ## Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## AutoGen is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ## See the GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License along ## with this program. If not, see . ## # $Id: strtable.test,v 1.7 2007/07/04 20:51:14 bkorb Exp $ # ---------------------------------------------------------------------- . ./defs # # # # # # # # # # TEMPLATE FILE # # # # # # # # # echo creating ${testname}.tpl cat > ${testname}.tpl <<_EOF_ [= AutoGen5 template test =] [= (string-table-new "scribble") (out-push-new) (define ix 0) (define ct 0) =][= FOR str IN that was the week that was =][= (set! ct (+ ct 1)) (set! ix (string-table-add "scribble" (get "str"))) =] scribble + [= (. ix) =],[= ENDFOR =] NULL }; [= (out-suspend "main") (emit-string-table "scribble") (emit (sprintf "\n#define STRING_CT %d\n" ct)) (ag-fprintf 0 "\nchar const *ap[%d] = {" (+ ct 1)) (out-resume "main") (out-pop #t) =] _EOF_ # # # # # # # # # # EXPECTED OUTPUT FILE # # # # # # # set -x echo creating ${testname}.base # this is the output we should expect to see cat > ${testname}.base <<'_EOF_' static char const scribble[18] = "that\0" "was\0" "the\0" "week\0"; #define STRING_CT 6 char const *ap[7] = { scribble + 0, scribble + 5, scribble + 9, scribble + 13, scribble + 0, scribble + 5, NULL }; _EOF_ ${AGexe} -b ${testname} -T ${testname}.tpl --no-defin || \ failure ${AGexe} failed cmp -s ${testname}.base ${testname}.test || \ failure "bad output: `diff -c ${testname}.base ${testname}.test`" cleanup ## Local Variables: ## Mode: shell-script ## indent-tabs-mode: nil ## sh-indentation: 2 ## End: # end of strtable.test