Anna Schumaker
3cf730a5cc
This takes the input string, casefolds it, and then adds some extra glob operators to it so we can do a case insensitive substring search by default. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
21 lines
793 B
Python
21 lines
793 B
Python
# Copyright 2022 (c) Anna Schumaker
|
|
"""Tests our string formatting functions."""
|
|
import unittest
|
|
from emmental import format
|
|
|
|
|
|
class TestFormatter(unittest.TestCase):
|
|
"""Tests our formatting functions."""
|
|
|
|
def test_search(self):
|
|
"""Test formatting a case-insensitive search query."""
|
|
self.assertIsNone(format.search(""))
|
|
self.assertIsNone(format.search(" "))
|
|
self.assertEqual(format.search(" TeSt "), "*test*")
|
|
self.assertEqual(format.search("*Test*"), "*test*")
|
|
self.assertEqual(format.search("^Test*"), "test*")
|
|
self.assertEqual(format.search("^*Test*"), "*test*")
|
|
self.assertEqual(format.search("*Test$"), "*test")
|
|
self.assertEqual(format.search("^"), "*")
|
|
self.assertEqual(format.search("$"), "*")
|