File: test.sh

package info (click to toggle)
ruby-bsearch 1.5-11
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 120 kB
  • sloc: ruby: 115; makefile: 23; sh: 23
file content (37 lines) | stat: -rw-r--r-- 961 bytes parent folder | download | duplicates (7)
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
#! /bin/sh

RUBYLIB="../"
export RUBYLIB

testcmd="ruby test.rb"

# 1000-dict:  usual dictionary with 1000 entries.
# 1-dict:     dictionary containing only one entry.
# 0-dict: empty dictionary.

for dict in 1000-dict 2-dict 1-dict 0-dict; do
    # prefix search.
    for pat in "" "a" "be" "st" "ta" "x" "Nonexistent"; do
	$testcmd "$pat"  $dict > tmp.dict.test
	egrep -in "^$pat" $dict > tmp.dict.egrep
	cmp tmp.dict.test tmp.dict.egrep || exit 1
    done

    # prefix search. iterate 50 times.
    for pat in `ruby sample.rb -50 $dict`; do
	$testcmd  "$pat"    $dict > tmp.dict.test
	egrep -in "^$pat" $dict > tmp.dict.egrep
	cmp tmp.dict.test tmp.dict.egrep || exit 1
    done

    # prefix search. for boundary entries.
    first=`head -1 $dict`
    last=`tail -1 $dict`
    for pat in $first $last; do
	$testcmd  "$pat"    $dict > tmp.dict.test
	egrep -in "^$pat" $dict > tmp.dict.egrep
	cmp tmp.dict.test tmp.dict.egrep || exit 1
    done
done

exit 0