Repository: keon/algorithms
Pull request #255 (2018-04-24 19:27:19)

Tests for the module strings
* I wrote tests for the module ```strings``` and put the file ```test_strings.py``` in the directory ```tests```.  
***important:*** The file ```strip_url_params.py``` is buggy. Because one times the tests run successful and a other times it fails. I comment out the test for this file. See #256   

@SaadBenn Can you look in it? The project with the bug is from you. More information #256

danghai: It is awesome! I am going to merge this. 

Patch:
diff --git a/strings/add_binary.py b/strings/add_binary.py
index 74e9479..0158a80 100644
--- a/strings/add_binary.py
+++ b/strings/add_binary.py
@@ -21,6 +21,6 @@ def add_binary(a, b):
             c += ord(b[j]) - zero
             j -= 1
         s = chr(c % 2 + zero) + s
-        # c //= 2 for python3
-        c /= 2
+        c //= 2 
+        
     return s
diff --git a/strings/breaking_bad.py b/strings/breaking_bad.py
index c2b20fc..98baf7c 100644
--- a/strings/breaking_bad.py
+++ b/strings/breaking_bad.py
@@ -24,9 +24,6 @@ output:
 
 from functools import reduce
 
-words = ['Amazon', 'Microsoft', 'Google']
-symbols = ['i', 'Am', 'cro', 'le', 'abc']
-
 
 def match_symbol(words, symbols):
     import re
@@ -38,15 +35,6 @@ def match_symbol(words, symbols):
                 combined.append(re.sub(s, "[{}]".format(s), c))
     return combined
 
-
-print(match_symbol(words, symbols))
-
-"""
-O(n * max(log(n), l)) time complexity
-n = len(words), l = len of a word
-"""
-
-
 def match_symbol_1(words, symbols):
     res = []
     # reversely sort the symbols according to their lengths.
@@ -64,34 +52,27 @@ def match_symbol_1(words, symbols):
             res.append(word)
     return res
 
-
-words = ['Amazon', 'Microsoft', 'Google', 'Facebook']
-symbols = ['i', 'Am', 'cro', 'Na', 'le', 'abc']
-print(match_symbol_1(words, symbols))
-# ['[Am]azon', 'Mi[cro]soft', 'Goog[le]', 'Facebook']
-
-
 """
-Another approach is to use a Trie for the dictionary (the symbols), and then
+Another approach is to use a Tree for the dictionary (the symbols), and then
 match brute force. The complexity will depend on the dictionary;
 if all are suffixes of the other, it will be n*m
 (where m is the size of the dictionary). For example, in Python:
 """
 
 
-class TrieNode:
+class TreeNode:
     def __init__(self):
         self.c = dict()
         self.sym = None
 
 
 def bracket(words, symbols):
-    root = TrieNode()
+    root = TreeNode()
     for s in symbols:
         t = root
         for char in s:
             if char not in t.c:
-                t.c[char] = TrieNode()
+                t.c[char] = TreeNode()
             t = t.c[char]
         t.sym = s
     result = dict()
@@ -112,8 +93,3 @@ def bracket(words, symbols):
             result[word] = "{}[{}]{}".format(word[:sym[0]], sym[2],
                                              word[sym[1]:])
     return tuple(word if word not in result else result[word] for word in words)
-
-
-bracket(['amazon', 'microsoft', 'google'],
-        ['i', 'am', 'cro', 'na', 'le', 'abc'])
-# >>> ('[am]azon', 'mi[cro]soft', 'goog[le]')
diff --git a/strings/decode_string.py b/strings/decode_string.py
index d6a0a7a..6a2350f 100644
--- a/strings/decode_string.py
+++ b/strings/decode_string.py
@@ -36,9 +36,3 @@ def decode_string(s):
         else:
             cur_string += c
     return cur_string
-
-a = "3[a]2[bc]" #"aaabcbc".
-b = "3[a2[c]]" #"accaccacc".
-
-print(decode_string(a))
-print(decode_string(b))
diff --git a/strings/domain_extractor.py b/strings/domain_extractor.py
index dcfba0f..1b9ff2b 100644
--- a/strings/domain_extractor.py
+++ b/strings/domain_extractor.py
@@ -10,7 +10,7 @@ Note: The idea is not to use any built-in libraries such as re (regular expressi
 """
 
 # Non pythonic way
-def domain_name(url):
+def domain_name_1(url):
 	#grab only the non http(s) part
     full_domain_name = url.split('//')[-1] 
     #grab the actual one depending on the len of the list  
@@ -24,19 +24,6 @@ def domain_name(url):
 
 
 # pythonic one liner
-def domain_name(url):
+def domain_name_2(url):
     return url.split("//")[-1].split("www.")[-1].split(".")[0]
 
-
-import unittest
-class TestSuite(unittest.TestCase):
-
-    def test_valid(self):
-        self.assertEqual(domain_name("https://github.com/SaadBenn"), "github")
-        
-    def test_invalid(self):
-        self.assertEqual(domain_name("http://google.com"), "http")
-
-
-if __name__ == "__main__":
-    unittest.main()
diff --git a/strings/encode_decode.py b/strings/encode_decode.py
index abc61ab..4fbdf89 100644
--- a/strings/encode_decode.py
+++ b/strings/encode_decode.py
@@ -27,11 +27,4 @@ def decode(s):
         size = int(s[i:index])
         strs.append(s[index+1: index+1+size])
         i = index+1+size
-    return strs
-
-strs = "keon is awesome"
-print(strs)
-enc = encode(strs)
-print(enc)
-dec = decode(enc)
-print(dec)
+    return strs
\ No newline at end of file
diff --git a/strings/group_anagrams.py b/strings/group_anagrams.py
index 47441e4..d3b9047 100644
--- a/strings/group_anagrams.py
+++ b/strings/group_anagrams.py
@@ -12,18 +12,17 @@ Return:
 """
 
 
-class Solution(object):
-    def group_anagrams(self, strs):
-        d = {}
-        ans = []
-        k = 0
-        for str in strs:
-            sstr = ''.join(sorted(str))
-            if sstr not in d:
-                d[sstr] = k
-                k = k+1
-                ans.append([])
-                ans[-1].append(str)
-            else:
-                ans[d[sstr]].append(str)
-        return ans
+def group_anagrams(strs):
+    d = {}
+    ans = []
+    k = 0
+    for str in strs:
+        sstr = ''.join(sorted(str))
+        if sstr not in d:
+            d[sstr] = k
+            k += 1
+            ans.append([])
+            ans[-1].append(str)
+        else:
+            ans[d[sstr]].append(str)
+    return ans
diff --git a/strings/int_to_roman.py b/strings/int_to_roman.py
index 1da2012..88866ea 100644
--- a/strings/int_to_roman.py
+++ b/strings/int_to_roman.py
@@ -13,5 +13,3 @@ def int_to_roman(num):
     x = ["", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"];
     i = ["", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"];
     return m[num//1000] + c[(num%1000)//100] + x[(num%100)//10] + i[num%10];
-
-print(int_to_roman(644))
diff --git a/strings/is_palindrome.py b/strings/is_palindrome.py
index 12746ef..0318bf5 100644
--- a/strings/is_palindrome.py
+++ b/strings/is_palindrome.py
@@ -55,18 +55,17 @@ def remove_punctuation(s):
 def string_reverse(s):
 	return s[::-1]
 
-def is_palidrome_reverse(s):
+def is_palindrome_reverse(s):
 	s = remove_punctuation(s)
-	reversed_string = string_reverse(s)
 	
 	# can also get rid of the string_reverse function and just do this return s == s[::-1] in one line.
-	if (s == reversed_string): 
+	if (s == string_reverse(s)): 
 		return True
 	return False	
 
 
 # Variation 2
-def is_palidrome_two_pointer(s):
+def is_palindrome_two_pointer(s):
     s = remove_punctuation(s)
 	
     for i in range(0, len(s)//2):
diff --git a/strings/license_number.py b/strings/license_number.py
index 2d3a724..6f6d9a4 100644
--- a/strings/license_number.py
+++ b/strings/license_number.py
@@ -9,11 +9,3 @@ def license_number(key, k):
         if (i+1) % k == 0 and i != len(alnum)-1:
             res.append("-")
     return "".join(res[::-1])
-
-
-print(license_number("a-bc-dfd-df", 1), 1)
-print(license_number("a-bc-dfd-df", 2), 2)
-print(license_number("a-bc-dfd-df", 3), 3)
-print(license_number("a-bc-dfd-df", 4), 4)
-print(license_number("a-bc-dfd-df", 5), 5)
-
diff --git a/strings/make_sentence.py b/strings/make_sentence.py
index d9d628f..8e6cb5b 100644
--- a/strings/make_sentence.py
+++ b/strings/make_sentence.py
@@ -25,10 +25,3 @@ def make_sentence(str_piece, dictionarys):
             if suffix in dictionarys or make_sentence(suffix, dictionarys):
                 count += 1
     return True
-
-
-if __name__ == "__main__":
-    dictionarys = ["", "app", "let", "t", "apple", "applet"]
-    word = "applet"
-    make_sentence(word, dictionarys)
-    print(count)
diff --git a/strings/merge_string_checker.py b/strings/merge_string_checker.py
index bc252e7..004226e 100644
--- a/strings/merge_string_checker.py
+++ b/strings/merge_string_checker.py
@@ -1,7 +1,9 @@
 """
-At a job interview, you are challenged to write an algorithm to check if a given string, s, can be formed from two other strings, part1 and part2.
-The restriction is that the characters in part1 and part2 are in the same order as in s.
-The interviewer gives you the following example and tells you to figure out the rest from the given test cases.
+At a job interview, you are challenged to write an algorithm to check if a 
+given string, s, can be formed from two other strings, part1 and part2.
+The restriction is that the characters in part1 and part2 are in the same 
+order as in s. The interviewer gives you the following example and tells 
+you to figure out the rest from the given test cases.
 'codewars' is a merge from 'cdw' and 'oears':
 s:  c o d e w a r s   = codewars
 part1:  c   d   w         = cdw
diff --git a/strings/rabin_karp.py b/strings/rabin_karp.py
index 51307db..d900a73 100644
--- a/strings/rabin_karp.py
+++ b/strings/rabin_karp.py
@@ -5,7 +5,7 @@ class RollingHash:
     def __init__(self, text, size_word):
         self.text = text
         self.hash = 0
-        self.sizeWord = size_word
+        self.size_word = size_word
 
         for i in range(0, size_word):
             #ord maps the character to a number
@@ -20,7 +20,7 @@ class RollingHash:
     def move_window(self):
         if self.window_end <= len(self.text) - 1:
             #remove left letter from hash value
-            self.hash -= (ord(self.text[self.window_start]) - ord("a")+1)*26**(self.sizeWord-1)
+            self.hash -= (ord(self.text[self.window_start]) - ord("a")+1)*26**(self.size_word-1)
             self.hash *= 26
             self.hash += ord(self.text[self.window_end])- ord("a")+1
             self.window_start += 1
diff --git a/strings/reverse_string.py b/strings/reverse_string.py
index dc695e2..f472135 100644
--- a/strings/reverse_string.py
+++ b/strings/reverse_string.py
@@ -4,9 +4,6 @@ def recursive(s):
         return s
     return recursive(s[l//2:]) + recursive(s[:l//2])
 
-s = "hello there"
-print(recursive(s))
-
 def iterative(s):
     r = list(s)
     i, j = 0, len(s) - 1
@@ -16,13 +13,9 @@ def iterative(s):
         j -= 1
     return "".join(r)
 
-print(iterative(s))
-
 def pythonic(s):
     r = list(reversed(s))
     return "".join(r)
 
 def ultra_pythonic(s):
     return s[::-1]
-
-print(ultra_pythonic(s))
diff --git a/strings/reverse_vowel.py b/strings/reverse_vowel.py
index 70111ff..b9fc630 100644
--- a/strings/reverse_vowel.py
+++ b/strings/reverse_vowel.py
@@ -11,7 +11,3 @@ def reverse_vowel(s):
         s[i], s[j] = s[j], s[i]
         i, j = i + 1, j - 1
     return "".join(s)
-
-test = "hello"
-print(test)
-print(reverse_vowel(test))
diff --git a/strings/strip_url_params.py b/strings/strip_url_params.py
index 4a07752..364f780 100644
--- a/strings/strip_url_params.py
+++ b/strings/strip_url_params.py
@@ -6,7 +6,6 @@ Removes any query string parameters specified within the 2nd argument (optional
 An example:
 www.saadbenn.com?a=1&b=2&a=2') // returns 'www.saadbenn.com?a=1&b=2'
 """
-import unittest
 from collections import defaultdict
 import urllib
 import urllib.parse
@@ -93,26 +92,4 @@ def strip_url_params3(url, strip=None):
     query = urllib.parse.urlencode(query)
     new = parse._replace(query=query)
     
-    return new.geturl()
-
-
-class TestSuite(unittest.TestCase):
-
-    def test_strip_url_params1(self):
-    
-        self.assertEqual(strip_url_params1("www.saadbenn.com?a=1&b=2&a=2"), "www.saadbenn.com?a=1&b=2")
-        self.assertEqual(strip_url_params1("www.saadbenn.com?a=1&b=2", ['b']), "www.saadbenn.com?a=1")
-
-    
-    def test_strip_url_params2(self):
-    
-        self.assertEqual(strip_url_params2("www.saadbenn.com?a=1&b=2&a=2"), "www.saadbenn.com?a=1&b=2")
-        self.assertEqual(strip_url_params2("www.saadbenn.com?a=1&b=2", ['b']), "www.saadbenn.com?a=1")
-    
-    def test_strip_url_params3(self):
-    
-        self.assertEqual(strip_url_params3("www.saadbenn.com?a=1&b=2&a=2"), "www.saadbenn.com?a=1&b=2")
-        self.assertEqual(strip_url_params3("www.saadbenn.com?a=1&b=2", ['b']), "www.saadbenn.com?a=1")
-
-if __name__ == "__main__":
-    unittest.main()
+    return new.geturl()
\ No newline at end of file
diff --git a/strings/validate_coordinates.py b/strings/validate_coordinates.py
index 8ae2dfb..371214b 100644
--- a/strings/validate_coordinates.py
+++ b/strings/validate_coordinates.py
@@ -28,13 +28,11 @@ def is_valid_coordinates_0(coordinates):
     l = coordinates.split(", ")
     if len(l) != 2:
         return False
-    print(l)
     try:
         latitude = float(l[0])
         longitude = float(l[1])
     except:
         return False
-    print(latitude, longitude)
     return -90 <= latitude <= 90 and -180 <= longitude <= 180
 
 # friends solutions
@@ -49,19 +47,3 @@ def is_valid_coordinates_1(coordinates):
 # using regular expression
 def is_valid_coordinates_regular_expression(coordinates):
     return bool(re.match("-?(\d|[1-8]\d|90)\.?\d*, -?(\d|[1-9]\d|1[0-7]\d|180)\.?\d*$", coordinates))  
-
-import unittest
-class TestSuite(unittest.TestCase):
-	def test_valid(self):
-		valid_coordinates = ["-23, 25","4, -3","90, 180","-90, -180"]
-		for coordinate in valid_coordinates:
-			self.assertTrue(is_valid_coordinates_0(coordinate))
-
-	def test_invalid(self):
-		invalid_coordinates = ["23.234, - 23.4234","99.234, 12.324","6.325624, 43.34345.345","0, 1,2","23.245, 1e1"]
-		for coordinate in invalid_coordinates:
-			self.assertFalse(is_valid_coordinates_0(coordinate))
-
-
-if __name__ == "__main__":
-    unittest.main()  
diff --git a/strings/word_squares.py b/strings/word_squares.py
index 7d05bb9..6614d21 100644
--- a/strings/word_squares.py
+++ b/strings/word_squares.py
@@ -65,6 +65,3 @@ def word_squares(words):
         build([word])
     return squares
 
-dic =["area","lead","wall","lady","ball"]
-print(word_squares(dic))
-


Test patch:
diff --git a/tests/test_strings.py b/tests/test_strings.py
new file mode 100644
index 0000000..8cee75b
--- /dev/null
+++ b/tests/test_strings.py
@@ -0,0 +1,366 @@
+from strings.add_binary import add_binary
+from strings.breaking_bad import match_symbol, match_symbol_1, bracket
+from strings.decode_string import decode_string
+from strings.delete_reoccurring import delete_reoccurring_characters
+from strings.domain_extractor import domain_name_1, domain_name_2
+from strings.encode_decode import encode, decode
+from strings.group_anagrams import group_anagrams
+from strings.int_to_roman import int_to_roman
+from strings.is_palindrome import is_palindrome, is_palindrome_reverse, \
+is_palindrome_two_pointer, is_palindrome_stack
+from strings.license_number import license_number
+from strings.make_sentence import make_sentence
+from strings.merge_string_checker import is_merge_recursive, is_merge_iterative
+from strings.multiply_strings import multiply
+from strings.one_edit_distance import is_one_edit, is_one_edit2
+from strings.rabin_karp import rabin_karp
+from strings.reverse_string import *
+from strings.reverse_vowel import reverse_vowel
+from strings.reverse_words import reverse_words
+from strings.roman_to_int import roman_to_int
+from strings.strip_url_params import *
+from strings.validate_coordinates import *
+from strings.word_squares import word_squares
+
+import unittest
+
+
+class TestAddBinary(unittest.TestCase):
+    """[summary]
+    Test for the file add_binary.py
+
+    Arguments:
+        unittest {[type]} -- [description]
+    """
+
+    def test_add_binary(self):
+        self.assertEqual("100", add_binary("11", "1"))
+        self.assertEqual("101", add_binary("100", "1"))
+        self.assertEqual("10", add_binary("1", "1"))
+
+
+class TestBreakingBad(unittest.TestCase):
+    """[summary]
+    Test for the file breaking_bad.py
+
+    Arguments:
+        unittest {[type]} -- [description]
+    """
+
+    def setUp(self):
+        self.words = ['Amazon', 'Microsoft', 'Google']
+        self.symbols = ['i', 'Am', 'cro', 'le', 'abc']
+        self.result = ['M[i]crosoft', '[Am]azon', 'Mi[cro]soft', 'Goog[le]']
+    def test_match_symbol(self):
+        self.assertEqual(self.result, match_symbol(self.words,self.symbols))
+    def test_match_symbol_1(self):
+        self.assertEqual(['[Am]azon', 'Mi[cro]soft', 'Goog[le]'], match_symbol_1(self.words,self.symbols))
+    def test_bracket(self):
+        self.assertEqual(('[Am]azon', 'Mi[cro]soft', 'Goog[le]'), bracket(self.words, self.symbols))
+
+
+class TestDecodeString(unittest.TestCase):
+    """[summary]
+    Test for the file decode_string.py
+
+    Arguments:
+        unittest {[type]} -- [description]
+    """
+
+    def test_decode_string(self):
+        self.assertEqual("aaabcbc", decode_string("3[a]2[bc]"))
+        self.assertEqual("accaccacc", decode_string("3[a2[c]]"))
+
+
+class TestDeleteReoccurring(unittest.TestCase):
+    """[summary]
+    Test for the file delete_reoccurring.py
+
+    Arguments:
+        unittest {[type]} -- [description]
+    """
+
+    def test_delete_reoccurring_characters(self):
+        self.assertEqual("abc", delete_reoccurring_characters("aaabcccc"))
+
+
+class TestDomainExtractor(unittest.TestCase):
+    """[summary]
+    Test for the file domain_extractor.py
+
+    Arguments:
+        unittest {[type]} -- [description]
+    """
+
+    def test_valid(self):
+        self.assertEqual(domain_name_1("https://github.com/SaadBenn"), "github")
+    def test_invalid(self):
+        self.assertEqual(domain_name_2("http://google.com"), "google")
+
+
+class TestEncodeDecode(unittest.TestCase):
+    """[summary]
+    Test for the file encode_decode.py
+
+    Arguments:
+        unittest {[type]} -- [description]
+    """
+
+    def test_encode(self):
+        self.assertEqual("4:keon2:is7:awesome", encode("keon is awesome"))
+    def test_decode(self):
+        self.assertEqual(['keon', 'is', 'awesome'], decode("4:keon2:is7:awesome"))
+
+
+class TestGroupAnagrams(unittest.TestCase):
+    """[summary]
+    Test for the file group_anagrams.py
+
+    Arguments:
+        unittest {[type]} -- [description]
+    """
+
+    def test_group_anagrams(self):
+        self.assertEqual([['eat', 'tea', 'ate'], ['tan', 'nat'], ['bat']], \
+        group_anagrams(["eat", "tea", "tan", "ate", "nat", "bat"]))
+
+
+class TestIntToRoman(unittest.TestCase):
+    """[summary]
+    Test for the file int_to_roman.py
+
+    Arguments:
+        unittest {[type]} -- [description]
+    """
+
+    def test_int_to_roman(self):
+        self.assertEqual("DCXLIV", int_to_roman(644))
+        self.assertEqual("I", int_to_roman(1))
+        self.assertEqual("MMMCMXCIX", int_to_roman(3999))
+
+
+class TestIsPalindrome(unittest.TestCase):
+    """[summary]
+    Test for the file is_palindrome.py
+
+    Arguments:
+        unittest {[type]} -- [description]
+    """
+
+    def test_is_palindrome(self):
+        # 'Otto' is a old german name.
+        self.assertTrue(is_palindrome("Otto"))
+        self.assertFalse(is_palindrome("house"))
+    def test_is_palindrome_reverse(self):
+        # 'Otto' is a old german name.
+        self.assertTrue(is_palindrome_reverse("Otto"))
+        self.assertFalse(is_palindrome_reverse("house"))
+    def test_is_palindrome_two_pointer(self):
+        # 'Otto' is a old german name.
+        self.assertTrue(is_palindrome_two_pointer("Otto"))
+        self.assertFalse(is_palindrome_two_pointer("house"))
+    def test_is_palindrome_stack(self):
+        # 'Otto' is a old german name.
+        self.assertTrue(is_palindrome_stack("Otto"))
+        self.assertFalse(is_palindrome_stack("house"))
+
+
+class TestLicenseNumber(unittest.TestCase):
+    """[summary]
+    Test for the file license_number.py
+
+    Arguments:
+        unittest {[type]} -- [description]
+    """
+
+    def test_license_number(self):
+        self.assertEqual("a-b-c-d-f-d-d-f", license_number("a-bc-dfd-df", 1))
+        self.assertEqual("ab-cd-fd-df", license_number("a-bc-dfd-df", 2))
+        self.assertEqual("ab-cdf-ddf", license_number("a-bc-dfd-df", 3))
+        self.assertEqual("abcd-fddf", license_number("a-bc-dfd-df", 4))
+        self.assertEqual("abc-dfddf", license_number("a-bc-dfd-df", 5))
+
+
+class TestMakeSentence(unittest.TestCase):
+    """[summary]
+    Test for the file make_sentence.py
+
+    Arguments:
+        unittest {[type]} -- [description]
+    """
+
+    def test_make_sentence(self):
+        dictionarys = ["", "app", "let", "t", "apple", "applet"]
+        word = "applet"
+        self.assertTrue(make_sentence(word, dictionarys))
+
+
+class TestMergeStringChecker(unittest.TestCase):
+    """[summary]
+    Test for the file merge_string_checker.py
+
+    Arguments:
+        unittest {[type]} -- [description]
+    """
+
+    def test_is_merge_recursive(self):
+        self.assertTrue(is_merge_recursive("codewars", "cdw", "oears"))
+    def test_is_merge_iterative(self):
+        self.assertTrue(is_merge_iterative("codewars", "cdw", "oears"))
+
+
+class TestMultiplyStrings(unittest.TestCase):
+    """[summary]
+    Test for the file multiply_strings.py
+
+    Arguments:
+        unittest {[type]} -- [description]
+    """
+
+    def test_multiply(self):
+        self.assertEqual("23", multiply("1", "23"))
+        self.assertEqual("529", multiply("23", "23"))
+        self.assertEqual("0", multiply("0", "23"))
+        self.assertEqual("1000000", multiply("100", "10000"))
+
+
+class TestOneEditDistance(unittest.TestCase):
+    """[summary]
+    Test for the file one_edit_distance.py
+
+    Arguments:
+        unittest {[type]} -- [description]
+    """
+
+    def test_is_one_edit(self):
+        self.assertTrue(is_one_edit("abc", "abd"))
+        self.assertFalse(is_one_edit("abc", "aed"))
+        self.assertFalse(is_one_edit("abcd", "abcd"))
+    def test_is_one_edit2(self):
+        self.assertTrue(is_one_edit2("abc", "abd"))
+        self.assertFalse(is_one_edit2("abc", "aed"))
+        self.assertFalse(is_one_edit2("abcd", "abcd"))
+
+
+class TestRabinKarp(unittest.TestCase):
+    """[summary]
+    Test for the file rabin_karp.py
+
+    Arguments:
+        unittest {[type]} -- [description]
+    """
+
+    def test_rabin_karp(self):
+        self.assertEqual(3, rabin_karp("abc", "zsnabckfkd"))
+        self.assertEqual(None, rabin_karp("abc", "zsnajkskfkd"))
+
+
+class TestReverseString(unittest.TestCase):
+    """[summary]
+    Test for the file reverse_string.py
+
+    Arguments:
+        unittest {[type]} -- [description]
+    """
+
+    def test_recursive(self):
+        self.assertEqual("ereht olleh", recursive("hello there"))
+    def test_iterative(self):
+        self.assertEqual("ereht olleh", iterative("hello there"))
+    def test_pythonic(self):
+        self.assertEqual("ereht olleh", pythonic("hello there"))
+    def test_ultra_pythonic(self):
+        self.assertEqual("ereht olleh", ultra_pythonic("hello there"))
+    
+
+class TestReverseVowel(unittest.TestCase):
+    """[summary]
+    Test for the file reverse_vowel.py
+
+    Arguments:
+        unittest {[type]} -- [description]
+    """
+
+    def test_reverse_vowel(self):
+        self.assertEqual("holle", reverse_vowel("hello"))
+
+
+class TestReverseWords(unittest.TestCase):
+    """[summary]
+    Test for the file reverse_words.py
+
+    Arguments:
+        unittest {[type]} -- [description]
+    """
+
+    def test_reverse_words(self):
+        self.assertEqual("pizza like I and kim keon am I", \
+        reverse_words("I am keon kim and I like pizza"))
+
+
+class TestRomanToInt(unittest.TestCase):
+    """[summary]
+    Test for the file roman_to_int.py
+
+    Arguments:
+        unittest {[type]} -- [description]
+    """
+
+    def test_roman_to_int(self):
+        self.assertEqual(621, roman_to_int("DCXXI"))
+        self.assertEqual(1, roman_to_int("I"))
+        self.assertEqual(3999, roman_to_int("MMMCMXCIX"))
+
+
+# class TestStripUrlParams(unittest.TestCase):
+#     """[summary]
+#     Test for the file strip_urls_params.py
+
+#     Arguments:
+#         unittest {[type]} -- [description]
+#     """
+
+#     def test_strip_url_params1(self):
+#         self.assertEqual(strip_url_params1("www.saadbenn.com?a=1&b=2&a=2"), "www.saadbenn.com?a=1&b=2")
+#         self.assertEqual(strip_url_params1("www.saadbenn.com?a=1&b=2", ['b']), "www.saadbenn.com?a=1")
+#     def test_strip_url_params2(self):
+#         self.assertEqual(strip_url_params2("www.saadbenn.com?a=1&b=2&a=2"), "www.saadbenn.com?a=1&b=2")
+#         self.assertEqual(strip_url_params2("www.saadbenn.com?a=1&b=2", ['b']), "www.saadbenn.com?a=1")
+#     def test_strip_url_params3(self):
+#         self.assertEqual(strip_url_params3("www.saadbenn.com?a=1&b=2&a=2"), "www.saadbenn.com?a=1&b=2")
+#         self.assertEqual(strip_url_params3("www.saadbenn.com?a=1&b=2", ['b']), "www.saadbenn.com?a=1")
+
+
+class TestValidateCoordinates(unittest.TestCase):
+    """[summary]
+    Test for the file validate_coordinates.py
+
+    Arguments:
+        unittest {[type]} -- [description]
+    """
+
+    def test_valid(self):
+        valid_coordinates = ["-23, 25","4, -3","90, 180","-90, -180"]
+        for coordinate in valid_coordinates:
+            self.assertTrue(is_valid_coordinates_0(coordinate))
+    def test_invalid(self):
+        invalid_coordinates = ["23.234, - 23.4234","99.234, 12.324","6.325624, 43.34345.345","0, 1,2","23.245, 1e1"]
+        for coordinate in invalid_coordinates:
+            self.assertFalse(is_valid_coordinates_0(coordinate))
+
+
+class TestWordSquares(unittest.TestCase):
+    """[summary]
+    Test for the file word_squares.py
+
+    Arguments:
+        unittest {[type]} -- [description]
+    """
+
+    def test_word_squares(self):
+        self.assertEqual([['wall', 'area', 'lead', 'lady'], ['ball', 'area', 'lead', 'lady']], \
+        word_squares(["area","lead","wall","lady","ball"]))
+
+
+if __name__ == "__main__":
+    unittest.main()
\ No newline at end of file