#
# Part of the ht://Dig package   <http://www.htdig.org/>
# Copyright (c) 1999 The ht://Dig Group
# For copyright details, see the file COPYING in your distribution
# or the GNU Public License version 2 or later
# <http://www.gnu.org/copyleft/gpl.html>
#
# $Id: t_htsearch,v 1.5 1999/10/05 16:03:32 loic Exp $
#

. $srcdir/t_htdig

config=$testdir/conf/htdig.conf
tmp=/tmp/t_htsearch$$

try() {
    comment="$1"
    shift
    query="$1"
    shift
    $htsearch -c $config "$query" > $tmp
    for pattern
    do
	if grep "$pattern" $tmp > /dev/null 
	then :
	else
	    fail "$htsearch -c $config '$query' > $tmp:
    $comment"
	fi
    done
}

try "Simple search for 'also'" \
    "words=also" \
    '3 matches' 'site2.html' 'script.html' 'site4.html'

try "Implicit and search with two words 'also movies'" \
    "method=and&words=also+movies" \
    '1 match' 'site2.html'

try "Explicit and search with two words 'also movies'" \
    "method=boolean&words=also+and+movies" \
    '1 match' 'site2.html'

try "Implicit or search for 'also distribution'" \
    "method=or&words=also+distribution" \
    '4 matches' 'site2.html' 'script.html' 'site4.html' 'site1.html'

try "Explicit or search for 'also distribution'" \
    "method=boolean&words=also+or+distribution" \
    '4 matches' 'site2.html' 'script.html' 'site4.html' 'site1.html'

try "Boolean and/or mixed 'also or distribution and ltd'" \
    "method=boolean&words=also+or+distribution+and+ltd" \
    '4 matches' 'site2.html' 'script.html' 'site4.html' 'site1.html'

try "Boolean explicit priority '(also or distribution) and ltd'" \
    "method=boolean&words=(also+or+distribution)+and+ltd" \
    '2 matches' 'script.html' 'site1.html'

rm -f $tmp

exit 0
