@@ -34,6 +34,28 @@ class TestWebUtils(SearxTestCase):
3434 query = 'a test'
3535 self.assertEqual(webutils.highlight_content(content, query), content)
3636
37+ data = (
38+ ('" test "',
39+ 'a test string',
40+ 'a <span class="highlight">test</span> string'),
41+ ('"a"',
42+ 'this is a test string',
43+ 'this is<span class="highlight"> a </span>test string'),
44+ ('a test',
45+ 'this is a test string that matches entire query',
46+ 'this is <span class="highlight">a test</span> string that matches entire query'),
47+ ('this a test',
48+ 'this is a string to test.',
49+ ('<span class="highlight">this</span> is<span class="highlight"> a </span>'
50+ 'string to <span class="highlight">test</span>.')),
51+ ('match this "exact phrase"',
52+ 'this string contains the exact phrase we want to match',
53+ ('<span class="highlight">this</span> string contains the <span class="highlight">exact</span>'
54+ ' <span class="highlight">phrase</span> we want to <span class="highlight">match</span>'))
55+ )
56+ for query, content, expected in data:
57+ self.assertEqual(webutils.highlight_content(content, query), expected)
58+
3759
3860class TestUnicodeWriter(SearxTestCase):
3961