File: test1

package info (click to toggle)
hspell 1.4-3.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 1,556 kB
  • sloc: ansic: 2,808; perl: 1,989; makefile: 209; sh: 109; awk: 15
file content (89 lines) | stat: -rwxr-xr-x 2,014 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/sh
# Test 1: verify that each and every word in the "words-correct" file is
# considered correct, and each and every word in "words-wrong" is considered
# incorrect. The various subtests use different spellchecking runtimes
# (hspell, aspell, hunspell) using the compiled data in the current directory.
#
# Important: run "make hspell he.rws" first.

# NOTE: This test should be run inside the hspell compilation directory,
# not in TESTDIR itself.
DIR=test

TMPLOG=/tmp/test1.log
dotest(){
	# Run the given "ispell -a"-like command and expect all the words to
	# be correct, or all incorrect, as requested.
	local TESTNAME="$1"
	local FILE="$2"
	local SECHEAD="$3"
	shift 3
	if test ! -s "$FILE"
	then
		return
	fi
	echo -n "Test 1/$TESTNAME ($SECHEAD): "

	"$@" < $FILE >$TMPLOG

	nwords=`wc -l <$FILE`
	nright=`grep -c '^[*+]' <$TMPLOG`
	nwrong=`grep -c '^[&#]' <$TMPLOG`
	case $SECHEAD in
	+*)	 # all should be right
		nall=$nright
		nnone=$nwrong;;
	-*)	 # all should be right
		nall=$nwrong
		nnone=$nright;;
	*)
		echo "TEST BUG: bad header $SECHEAD"
		return;;
	esac
	if test $nall -eq $nwords -a $nnone -eq 0
	then
		echo success.
	else
		echo "***** FAILED! *****"
		#cat $TMPLOG
	fi
}

TMPFILE=/tmp/test1.in
test_all(){
	TESTNAME="$1"
	shift
	>$TMPFILE
	SECHEAD=""
	section=0
	while read line
	do
		case $line in
		[+-]*)
			# end of previous section; check it
			dotest "$TESTNAME/$section" "$TMPFILE" "$SECHEAD" "$@"
			>$TMPFILE
			SECHEAD="$line"
			section=$((section+1))
			;;
		*)
			echo "$line" >>$TMPFILE
			;;
		esac
	done
	# end of previous section; check it
	dotest "$TESTNAME/$section" "$TMPFILE" "$SECHEAD" "$@"
	rm $TMPFILE
}

cat $DIR/test1.dat|
test_all hspell	./hspell -Dhebrew.wgz -a

cat $DIR/test1.dat|
test_all aspell	aspell --dict-dir=. -d he.rws -a

iconv -f iso-8859-8 -t utf-8 $DIR/test1.dat |
test_all hunspell	hunspell -i utf-8 -d `pwd`/he -a

#iconv -f iso-8859-8 -t utf-8 $DIR/test1.dat |
#test_all doubleaffixcompress	hunspell -i utf-8 -d `pwd`/hunspell/new_he -a