summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES1
-rw-r--r--tdict.c12
-rwxr-xr-xtestit.sh41
3 files changed, 50 insertions, 4 deletions
diff --git a/CHANGES b/CHANGES
index 0ac2b31..283c144 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,5 @@
1.17 -> 2.0:
+ - devzero2000: add tdict to the unit test: augment make check with some tdict tests
- devzero2000: add test2 to the unit test: augment make check with some test2 tests
- devzero2000: fix: add missing automake per target test* LDFLAGS
- devzero2000: require, as in autogen.sh, a minimal automake version for bootstrap
diff --git a/tdict.c b/tdict.c
index b2e0859..33cbf5a 100644
--- a/tdict.c
+++ b/tdict.c
@@ -44,7 +44,7 @@ exit:
static struct poptOption options[] = {
{ "debug", 'd', POPT_BIT_SET|POPT_ARGFLAG_TOGGLE, &_debug, 1,
"Set debugging.", NULL },
- { "verbose", 'v', POPT_BIT_SET|POPT_ARGFLAG_TOGGLE, &_verbose, 1,
+ { "verbose", 'v', POPT_BIT_SET|POPT_ARGFLAG_TOGGLE, &_verbose, 0,
"Set verbosity.", NULL },
POPT_AUTOALIAS
@@ -121,8 +121,14 @@ int main(int argc, const char ** argv)
ec = 0;
exit:
- fprintf(stdout, "===== poptBits N:%u M:%u K:%u (%uKb) total(%u) = hits(%u) + misses(%u)\n",
- _poptBitsN, _poptBitsM, _poptBitsK, (((_poptBitsM/8)+1)+1023)/1024, e.total, e.hits, e.misses);
+ /* XXX : depends on the /usr/share/dict/words contents so no default*/
+ if (rc >= 0) {
+ if (_debug) {
+ fprintf(stdout, "===== poptBits N:%u M:%u K:%u (%uKb) ",
+ _poptBitsN, _poptBitsM, _poptBitsK, (((_poptBitsM/8)+1)+1023)/1024);
+ }
+ fprintf(stdout, "total(%u) = hits(%u) + misses(%u)\n", e.total, e.hits, e.misses);
+ }
if (avbits) free(avbits);
optCon = poptFreeContext(optCon);
#if defined(HAVE_MCHECK_H) && defined(HAVE_MTRACE)
diff --git a/testit.sh b/testit.sh
index 0ecd7be..9cc53b4 100755
--- a/testit.sh
+++ b/testit.sh
@@ -22,6 +22,7 @@ run() {
echo Running test $name.
result=`HOME=$builddir $builddir/$prog $* 2>&1`
+
if [ "$answer" != "$result" ]; then
echo "Test \"$prog $*\" failed with: \"$result\" != \"$answer\" "
exit 2
@@ -59,7 +60,9 @@ test1=${builddir}/test1
echo "Running tests in `pwd`"
#make -q testcases
-
+###################
+# Begin test1 test
+###################
run test1 "test1 - 1" "arg1: 1 arg2: (none)" --arg1
run test1 "test1 - 2" "arg1: 0 arg2: foo" --arg2 foo
run test1 "test1 - 3" "arg1: 1 arg2: something" --arg1 --arg2 something
@@ -188,6 +191,12 @@ Help options:
-?, --help Show this help message
--usage Display brief usage message" --help
+###################
+# End test1 test
+###################
+###################
+# Begin test2 test
+###################
run test2 "test2 - 1" "\
dbusername popt-DBUserName dbpassword (null)
txhost (null) txsslport 443 txstoreid 0 pathofkeyfile popt-key-file
@@ -495,6 +504,36 @@ username (null) password poptsecret firstname (null) lastname (null)
addr1 (null) addr2 (null) city (null) state (null) postal (null)
country (null) email (null) dayphone popt-dayphone fax popt-fax" --pwd poptsecret --twotest2 -Z popt-fax -V popt-dayphone
run test2 "test2 - 52" "Have your way. Have Fun" -Y "Have your way. Have Fun"
+###################
+# End test2 test
+###################
+###################
+# Begin tdict test
+###################
+if [ -f /usr/share/dict/words ]
+then
+run tdict "tdict - 1" "\
+===== Some words are in /usr/share/dict/words
+a: YES
+b: YES
+rpm: YES
+dpkg: YES
+ipkg: NO
+total(5) = hits(4) + misses(1)" a b rpm dpkg ipkg
+run tdict "tdict - 2" "\
+Usage: tdict [-?] [-d|--debug] [-v|--verbose] [-?|--help] [--usage]" --usage
+run tdict "tdict - 3" "\
+Usage: tdict [OPTION...]
+ -d, --debug Set debugging.
+ -v, --verbose Set verbosity.
+
+Help options:
+ -?, --help Show this help message
+ --usage Display brief usage message" --help
+fi
+###################
+# End tdict test
+###################
#run_diff test3 "test3 - 51" test3-data/01.input test3-data/01.answer
#run_diff test3 "test3 - 52" test3-data/02.input test3-data/02.answer