#!/usr/bin/env python3


import re
import unittest


def get_my_regex():
    """
    https://qwerty.dev/whitespace/
    """
    return r"\w+"


class PythonRegexFunSearch(unittest.TestCase):
    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test_my_strings_statement(self):
        val = "; delete all my tables; "
        result = re.search(get_my_regex(), val)
        my_list = val.split()
        self.assertTrue(result, result)
        self.assertTrue(my_list, my_list)

    def test_my_strings_statement2(self):
        val = "foo';delete all my tables;"
        result = re.search(get_my_regex(), val)
        my_list = val.split()
        self.assertTrue(result, result)
        self.assertTrue(my_list, my_list)

    def test_my_strings_statement3(self):
        val = "foo';drop\ntable\nfoo;"
        result = re.search(get_my_regex(), val)
        my_list = val.split()
        self.assertTrue(result, result)
        self.assertTrue(my_list, my_list)

    def test_my_strings_statement_zero_width_space(self):
        ws = "​"
        val = f"foo';drop{ws}table{ws}foo;"
        result = re.search(get_my_regex(), val)
        my_list = val.split()
        my_str = "{}".format(val)
        self.assertTrue(result, result)
        self.assertTrue(my_list, my_list)
        self.assertTrue(" " not in my_str, my_str)

    def test_my_strings_statement_hair_space(self):
        ws = " "
        val = f"foo';drop{ws}table{ws}foo;"
        result = re.search(get_my_regex(), val)
        my_list = val.split()
        my_str = "{}".format(val)
        self.assertTrue(result, result)
        self.assertTrue(my_list, my_list)
        self.assertTrue(" " not in my_str, my_str)

    def test_my_strings_statement_six_per_em(self):
        ws = " "
        val = f"foo';drop{ws}table{ws}foo;"
        result = re.search(get_my_regex(), val)
        my_list = val.split()
        my_str = "{}".format(val)
        self.assertTrue(result, result)
        self.assertTrue(my_list, my_list)
        self.assertTrue(" " not in my_str, my_str)

    def test_my_strings_statement_thin(self):
        ws = " "
        val = f"foo';drop{ws}table{ws}foo;"
        result = re.search(get_my_regex(), val)
        my_list = val.split()
        my_str = "{}".format(val)
        self.assertTrue(result, result)
        self.assertTrue(my_list, my_list)
        self.assertTrue(" " not in my_str, my_str)

    def test_my_strings_statement_pipes(self):
        ws = "||"
        val = f"foo';drop{ws}table{ws}foo;"
        result = re.search(get_my_regex(), val)
        my_list = val.split()
        my_str = "{}".format(val)
        self.assertTrue(result, result)
        self.assertTrue(my_list, my_list)
        self.assertTrue(" " not in my_str, my_str)

    def test_my_strings_statement_comments(self):
        ws = "/**/"
        val = f"foo';drop{ws}table{ws}foo;"
        result = re.search(get_my_regex(), val)
        my_list = val.split()
        my_str = "{}".format(val)
        self.assertTrue(result, result)
        self.assertTrue(not my_list, my_list)
        self.assertTrue(not my_str, my_str)

    def test_my_strings(self):
        val = "foo"
        result = re.search(get_my_regex(), val)
        self.assertTrue(result, result)

if __name__ == "__main__":
    unittest.main()
