Last active
March 19, 2017 20:24
-
-
Save jaylett/8bf43bcce4bbb2ccb5ec93aa74e2c050 to your computer and use it in GitHub Desktop.
Basic Omega tests for $highlight{}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/xapian-applications/omega/docs/omegascript.rst b/xapian-applications/omega/docs/omegascript.rst | |
index e00d7aa7b611..942172424c81 100644 | |
--- a/xapian-applications/omega/docs/omegascript.rst | |
+++ b/xapian-applications/omega/docs/omegascript.rst | |
@@ -221,7 +221,7 @@ $fmt | |
$freq{term} | |
frequency of a term | |
-$highlight{TEXT,LIST,[OPEN,[CLOSE]]} | |
+$highlight{TEXT,LIST[,OPEN[,CLOSE]]} | |
html escape string (<>&, etc) and highlight any terms from ``LIST`` | |
that appear in ``TEXT`` by enclosing them in ``OPEN`` and ``CLOSE``. | |
If ``OPEN`` is specified, but close is omitted, ``CLOSE`` defaults to | |
@@ -230,8 +230,8 @@ $highlight{TEXT,LIST,[OPEN,[CLOSE]]} | |
``<b style="color:XXXXX;background-color:#YYYYYY">`` (where ``YYYYYY`` | |
cycles through ``ffff66`` ``99ff99`` ``99ffff`` ``ff66ff`` ``ff9999`` | |
``990000`` ``009900`` ``996600`` ``006699`` ``990099`` and ``XXXXX`` | |
- is ``black`` is ``YYYYYY`` contains an ``f``, and otherwise ``white``) | |
- and ``CLOSE`` is ``</b>``. | |
+ is ``black`` if ``YYYYYY`` contains an ``f``, and otherwise ``white``) | |
+ and ``CLOSE`` is set to ``</b>``. | |
$hit | |
MSet index of current doc (first document in MSet is 0, so if | |
diff --git a/xapian-applications/omega/omegatest b/xapian-applications/omega/omegatest | |
index f660ee021796..de0719bbc6b4 100755 | |
--- a/xapian-applications/omega/omegatest | |
+++ b/xapian-applications/omega/omegatest | |
@@ -58,8 +58,8 @@ testcase() { | |
output=`$FAKETIME ${FAKE_NOW+"$FAKE_NOW"} "$OMEGA" "$@"` | |
if [ "$output" != "$expected" ] ; then | |
echo "$OMEGA $@:" | |
- echo " expected: «$expected»" | |
- echo " received: «$output»" | |
+ echo " expected: $expected" | |
+ echo " received: $output" | |
failed=`expr $failed + 1` | |
fi | |
} | |
@@ -402,6 +402,16 @@ testcase "A${tab}AZ${tab}Z" A=1 A=2 A=3 AZ=1 AZ=2 Z=xxx | |
testcase "${tab}abc" =1 abc=1 | |
testcase "${tab}abc${tab}def" =1 abc=1 def=7 | |
+# Feature tests for $highlight{}. | |
+printf '$highlight{$cgi{text},$cgi{list}}' > "$TEST_TEMPLATE" | |
+testcase 'A <b style="color:black;background-color:#ffff66">list</b> of <b style="color:black;background-color:#99ff99">words</b>' P=text list="list${tab}words" text="A list of words" open="<b>" close="</b>" | |
+printf '$highlight{$cgi{text},$cgi{list},$cgi{open}}' > "$TEST_TEMPLATE" | |
+testcase 'A list of <b>words</b>' P=text list="words" text="A list of words" open="<b>" | |
+testcase 'A list of <span>words</span>' P=text list="words" text="A list of words" open="<span>" | |
+printf '$highlight{$cgi{text},$cgi{list},$cgi{open},$cgi{close}}' > "$TEST_TEMPLATE" | |
+testcase 'A list of <b>words</b>' P=text list="words" text="A list of words" open="<b>" close="</b>" | |
+testcase 'A *list* of *words*' P=text list="words${tab}list" text="A list of words" open="*" close="*" | |
+ | |
rm "$OMEGA_CONFIG_FILE" "$TEST_INDEXSCRIPT" "$TEST_TEMPLATE" | |
rm -rf "$TEST_DB" | |
if [ "$failed" = 0 ] ; then |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment