Esempio n. 1
0
    def dna_test(self, suffix, solution_length):
        """
        assumes chr2* files are in the current directory, containing
        DNA strings. Reads the files with the given suffix, runs
        longest_substring on them, and checks the length of the
        solution.
        """
        s_file = open('data/chr2_first_' + str(suffix))
        t_file = open('data/chr2a_first_' + str(suffix))
        s = s_file.readline()
        t = t_file.readline()

        start_time = time.time()
        ans = substring.longest_substring(s, t)
        end_time = time.time()

        self.assertEqual(len(ans), solution_length)
        print 'time for test', str(suffix) + ': ', end_time - start_time, 'seconds'
    def dna_test(self, suffix, solution_length):
        """
        assumes chr2* files are in the current directory, containing
        DNA strings. Reads the files with the given suffix, runs
        longest_substring on them, and checks the length of the
        solution.
        """
        s_file = open('data/chr2_first_' + str(suffix))
        t_file = open('data/chr2a_first_' + str(suffix))
        s = s_file.readline()
        t = t_file.readline()

        start_time = time.time()
        ans = substring.longest_substring(s, t)
        end_time = time.time()

        self.assertEqual(len(ans), solution_length)
        print('time for test',
              str(suffix) + ': ', end_time - start_time, 'seconds')
Esempio n. 3
0
 def test1(self):
     ans = substring.longest_substring('','')
     self.assertEqual(ans, '')
Esempio n. 4
0
 def test4(self):
     ans = substring.longest_substring('the quick brown fox','THE QUICK BROWN FOX')
     self.assertEqual(ans, ' ')
Esempio n. 5
0
 def test3(self):
     ans = substring.longest_substring('aaa','aaa')
     self.assertEqual(ans, 'aaa')
 def test4(self):
     ans = substring.longest_substring('the quick brown fox',
                                       'THE QUICK BROWN FOX')
     self.assertEqual(ans, ' ')
 def test3(self):
     ans = substring.longest_substring('aaa', 'aaa')
     self.assertEqual(ans, 'aaa')
 def test1(self):
     ans = substring.longest_substring('', '')
     self.assertEqual(ans, '')